aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/fixtures_test.rb
diff options
context:
space:
mode:
authorAlexey Muranov <muranov@math.univ-toulouse.fr>2011-12-19 16:00:24 +0100
committerAlexey Muranov <alexey.muranov@gmail.com>2011-12-30 10:34:01 +0100
commit6468ff41971b69be9c02f33d05e94e4f8845266b (patch)
treecb50681bb59422a3ff346177b4cdc281ce68ca55 /activerecord/test/cases/fixtures_test.rb
parente43b2b35c7042c87fd18e3ecd55c14eabd5746ba (diff)
downloadrails-6468ff41971b69be9c02f33d05e94e4f8845266b.tar.gz
rails-6468ff41971b69be9c02f33d05e94e4f8845266b.tar.bz2
rails-6468ff41971b69be9c02f33d05e94e4f8845266b.zip
Test fixtures with custom model and table names
Test using fixtures with random names and model names, that is not following naming conventions but using set_fixture_class instead. It is expected that the table name be defined in the model, but this is not explicitly tested here. This will need to be fixed.
Diffstat (limited to 'activerecord/test/cases/fixtures_test.rb')
-rw-r--r--activerecord/test/cases/fixtures_test.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/activerecord/test/cases/fixtures_test.rb b/activerecord/test/cases/fixtures_test.rb
index ba09df4b7d..d60e278d1d 100644
--- a/activerecord/test/cases/fixtures_test.rb
+++ b/activerecord/test/cases/fixtures_test.rb
@@ -1,6 +1,7 @@
require 'cases/helper'
require 'models/admin'
require 'models/admin/account'
+require 'models/admin/randomly_named_c1'
require 'models/admin/user'
require 'models/binary'
require 'models/book'
@@ -14,6 +15,7 @@ require 'models/matey'
require 'models/parrot'
require 'models/pirate'
require 'models/post'
+require 'models/randomly_named_c1'
require 'models/reply'
require 'models/ship'
require 'models/task'
@@ -745,3 +747,29 @@ class FixtureLoadingTest < ActiveRecord::TestCase
ActiveRecord::TestCase.try_to_load_dependency(:works_out_fine)
end
end
+
+class CustomNameForFixtureOrModelTest < ActiveRecord::TestCase
+ ActiveRecord::Fixtures.reset_cache
+
+ set_fixture_class :randomly_named_a9 =>
+ ClassNameThatDoesNotFollowCONVENTIONS,
+ :'admin/randomly_named_a9' =>
+ Admin::ClassNameThatDoesNotFollowCONVENTIONS,
+ 'admin/randomly_named_b0' =>
+ Admin::ClassNameThatDoesNotFollowCONVENTIONS
+
+ fixtures :randomly_named_a9, 'admin/randomly_named_a9',
+ :'admin/randomly_named_b0'
+
+ def test_named_accessor_for_randomly_named_fixture_and_class
+ assert_kind_of ClassNameThatDoesNotFollowCONVENTIONS,
+ randomly_named_a9(:first_instance)
+ end
+
+ def test_named_accessor_for_randomly_named_namespaced_fixture_and_class
+ assert_kind_of Admin::ClassNameThatDoesNotFollowCONVENTIONS,
+ admin_randomly_named_a9(:first_instance)
+ assert_kind_of Admin::ClassNameThatDoesNotFollowCONVENTIONS,
+ admin_randomly_named_b0(:second_instance)
+ end
+end