diff options
author | Rhett Sutphin <rsutphin@zem.local> | 2008-07-14 02:01:52 +0100 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2008-07-14 02:01:52 +0100 |
commit | d72c66532f959846cdc2d7fb1dc1ef6ba87bdcb1 (patch) | |
tree | f683d74335a43b992e9a1f9e5979d95e1ec12342 /activerecord/test/cases | |
parent | 697ee1a50dea7580a7240535d3ad89d2d090721a (diff) | |
download | rails-d72c66532f959846cdc2d7fb1dc1ef6ba87bdcb1.tar.gz rails-d72c66532f959846cdc2d7fb1dc1ef6ba87bdcb1.tar.bz2 rails-d72c66532f959846cdc2d7fb1dc1ef6ba87bdcb1.zip |
Make fixture accessors work when fixture name is not same as the table name. [#124 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
Diffstat (limited to 'activerecord/test/cases')
-rwxr-xr-x | activerecord/test/cases/fixtures_test.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/activerecord/test/cases/fixtures_test.rb b/activerecord/test/cases/fixtures_test.rb index aca7cfb367..0ea24868f1 100755 --- a/activerecord/test/cases/fixtures_test.rb +++ b/activerecord/test/cases/fixtures_test.rb @@ -15,6 +15,7 @@ require 'models/pirate' require 'models/treasure' require 'models/matey' require 'models/ship' +require 'models/book' class FixturesTest < ActiveRecord::TestCase self.use_instantiated_fixtures = true @@ -373,6 +374,34 @@ class CheckSetTableNameFixturesTest < ActiveRecord::TestCase end end +class FixtureNameIsNotTableNameFixturesTest < ActiveRecord::TestCase + set_fixture_class :items => Book + fixtures :items + # Set to false to blow away fixtures cache and ensure our fixtures are loaded + # and thus takes into account our set_fixture_class + self.use_transactional_fixtures = false + + def test_named_accessor + assert_kind_of Book, items(:dvd) + end +end + +class FixtureNameIsNotTableNameMultipleFixturesTest < ActiveRecord::TestCase + set_fixture_class :items => Book, :funny_jokes => Joke + fixtures :items, :funny_jokes + # Set to false to blow away fixtures cache and ensure our fixtures are loaded + # and thus takes into account our set_fixture_class + self.use_transactional_fixtures = false + + def test_named_accessor_of_differently_named_fixture + assert_kind_of Book, items(:dvd) + end + + def test_named_accessor_of_same_named_fixture + assert_kind_of Joke, funny_jokes(:a_joke) + end +end + class CustomConnectionFixturesTest < ActiveRecord::TestCase set_fixture_class :courses => Course fixtures :courses |