diff options
author | Rhett Sutphin <rhett@detailedbalance.net> | 2008-04-30 16:59:22 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2008-04-30 16:59:22 -0500 |
commit | b4c33711c52dc78e6ff63469a5caa89f9a67c61a (patch) | |
tree | cc28996175324640f38008d469d69c94a5e74030 /activerecord | |
parent | c353794dff580c8aa63b357b2857c1fadff3104b (diff) | |
download | rails-b4c33711c52dc78e6ff63469a5caa89f9a67c61a.tar.gz rails-b4c33711c52dc78e6ff63469a5caa89f9a67c61a.tar.bz2 rails-b4c33711c52dc78e6ff63469a5caa89f9a67c61a.zip |
Fixed fixture caching with prefixed or suffixed tables.
Signed-off-by: Joshua Peek <josh@joshpeek.com>
Diffstat (limited to 'activerecord')
-rwxr-xr-x | activerecord/lib/active_record/fixtures.rb | 6 | ||||
-rwxr-xr-x | activerecord/test/cases/fixtures_test.rb | 4 |
2 files changed, 7 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/fixtures.rb b/activerecord/lib/active_record/fixtures.rb index f5b2e73da9..7d5fd35dae 100755 --- a/activerecord/lib/active_record/fixtures.rb +++ b/activerecord/lib/active_record/fixtures.rb @@ -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 diff --git a/activerecord/test/cases/fixtures_test.rb b/activerecord/test/cases/fixtures_test.rb index 182f4f0f0b..2787b9a39d 100755 --- a/activerecord/test/cases/fixtures_test.rb +++ b/activerecord/test/cases/fixtures_test.rb @@ -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 |