mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Fixed fixture caching with prefixed or suffixed tables.
Signed-off-by: Joshua Peek <josh@joshpeek.com>
This commit is contained in:
committed by
Joshua Peek
parent
c353794dff
commit
b4c33711c5
@@ -469,8 +469,8 @@ class Fixtures < (RUBY_VERSION < '1.9' ? YAML::Omap : Hash)
|
||||
fixtures.size > 1 ? fixtures : fixtures.first
|
||||
end
|
||||
|
||||
def self.cache_fixtures(connection, fixtures)
|
||||
cache_for_connection(connection).update(fixtures.index_by { |f| f.table_name })
|
||||
def self.cache_fixtures(connection, fixtures_map)
|
||||
cache_for_connection(connection).update(fixtures_map)
|
||||
end
|
||||
|
||||
def self.instantiate_fixtures(object, table_name, fixtures, load_instances = true)
|
||||
@@ -526,7 +526,7 @@ class Fixtures < (RUBY_VERSION < '1.9' ? YAML::Omap : Hash)
|
||||
end
|
||||
end
|
||||
|
||||
cache_fixtures(connection, fixtures)
|
||||
cache_fixtures(connection, fixtures_map)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -96,6 +96,10 @@ class FixturesTest < ActiveRecord::TestCase
|
||||
|
||||
second_row = ActiveRecord::Base.connection.select_one("SELECT * FROM prefix_topics_suffix WHERE author_name = 'Mary'")
|
||||
assert_nil(second_row["author_email_address"])
|
||||
|
||||
# This checks for a caching problem which causes a bug in the fixtures
|
||||
# class-level configuration helper.
|
||||
assert_not_nil topics, "Fixture data inserted, but fixture objects not returned from create"
|
||||
ensure
|
||||
# Restore prefix/suffix to its previous values
|
||||
ActiveRecord::Base.table_name_prefix = old_prefix
|
||||
|
||||
Reference in New Issue
Block a user