Fixed fixture caching with prefixed or suffixed tables.

Signed-off-by: Joshua Peek <josh@joshpeek.com>
This commit is contained in:
Rhett Sutphin
2008-04-30 16:59:22 -05:00
committed by Joshua Peek
parent c353794dff
commit b4c33711c5
2 changed files with 7 additions and 3 deletions

View File

@@ -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

View File

@@ -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