aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/inheritance.rb
diff options
context:
space:
mode:
authorJamis Buck <jamisbuck@gmail.com>2015-10-28 13:14:33 -0600
committerJamis Buck <jamisbuck@gmail.com>2015-10-29 11:23:58 -0600
commit0c843640b49e9ca41232d1402f26780e4f511275 (patch)
tree9ac25533a6e4ab8a80bb4ba6f2e022ccda19e3b1 /activerecord/lib/active_record/inheritance.rb
parentd74c89ac16aa87f3bc166450e8d4b87382da17a4 (diff)
downloadrails-0c843640b49e9ca41232d1402f26780e4f511275.tar.gz
rails-0c843640b49e9ca41232d1402f26780e4f511275.tar.bz2
rails-0c843640b49e9ca41232d1402f26780e4f511275.zip
FixtureSet.fixture_class_names should have no default value
Look at `TestFixtures.set_fixture_class`. As documented, it accepts a mapping of fixture identifiers (string or symbol) to Classes (the model classes that implement the named fixture). Look now at the initialization of `TestFixtures.fixture_class_names`. It defines a Hash, which will return a string by default (where the string is the estimated class name of the given fixture identifier). Now look at TestFixtures.load_fixtures. It calls `FixtureSet.create_fixtures`, passing in the mapping of `fixture_class_names`. Following this on to `FixtureSet.create_fixtures`, this instantiates a `FixtureSet::ClassCache`, passing in the map of class names. `ClassCache`, in turn, calls `insert_class` for each value in the cache. (Recall that `set_fixture_class` puts Class objects in there, while the default proc for the mapping puts String objects.) Look finally at `insert_class`. If the value is present, it checks to see if the value is a subclass of `AR::Base`. Fair enough...but wait! What if the value is a String? You get an exception, because a String instance cannot be compared with a Class. Judging from the implementation, it seems like the expected behavior here is for `fixture_class_names` to have no default proc. Look-ups are supposed to happen via `ClassCache`, with `fixture_class_names` existing solely as a repository for explicitly-registered class mappings. That is what this change does.
Diffstat (limited to 'activerecord/lib/active_record/inheritance.rb')
0 files changed, 0 insertions, 0 deletions