public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Fixed fixture caching with prefixed or suffixed tables.

Signed-off-by: Joshua Peek <josh@joshpeek.com>
rsutphin (author)
Wed Apr 30 14:59:22 -0700 2008
josh (committer)
Wed Apr 30 14:59:22 -0700 2008
commit  b4c33711c52dc78e6ff63469a5caa89f9a67c61a
tree    cc28996175324640f38008d469d69c94a5e74030
parent  c353794dff580c8aa63b357b2857c1fadff3104b
...
469
470
471
472
473
 
 
474
475
476
...
526
527
528
529
 
530
531
532
...
469
470
471
 
 
472
473
474
475
476
...
526
527
528
 
529
530
531
532
0
@@ -469,8 +469,8 @@ class Fixtures < (RUBY_VERSION < '1.9' ? YAML::Omap : Hash)
0
     fixtures.size > 1 ? fixtures : fixtures.first
0
   end
0
 
0
-  def self.cache_fixtures(connection, fixtures)
0
-    cache_for_connection(connection).update(fixtures.index_by { |f| f.table_name })
0
+  def self.cache_fixtures(connection, fixtures_map)
0
+    cache_for_connection(connection).update(fixtures_map)
0
   end
0
 
0
   def self.instantiate_fixtures(object, table_name, fixtures, load_instances = true)
0
@@ -526,7 +526,7 @@ class Fixtures < (RUBY_VERSION < '1.9' ? YAML::Omap : Hash)
0
             end
0
           end
0
 
0
-          cache_fixtures(connection, fixtures)
0
+          cache_fixtures(connection, fixtures_map)
0
         end
0
       end
0
     end
...
96
97
98
 
 
 
 
99
100
101
...
96
97
98
99
100
101
102
103
104
105
0
@@ -96,6 +96,10 @@ class FixturesTest < ActiveRecord::TestCase
0
 
0
       second_row = ActiveRecord::Base.connection.select_one("SELECT * FROM prefix_topics_suffix WHERE author_name = 'Mary'")
0
       assert_nil(second_row["author_email_address"])
0
+
0
+      # This checks for a caching problem which causes a bug in the fixtures 
0
+      # class-level configuration helper.
0
+      assert_not_nil topics, "Fixture data inserted, but fixture objects not returned from create"
0
     ensure
0
       # Restore prefix/suffix to its previous values
0
       ActiveRecord::Base.table_name_prefix = old_prefix

Comments