diff options
author | Andrew White <pixeltrix@users.noreply.github.com> | 2017-01-03 15:50:06 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-03 15:50:06 +0000 |
commit | ec7255a2d6f49f7f7b305c10a50f65bfd2a1511e (patch) | |
tree | 6f8c50e8bf9e628720b90b6c5cea16f7f5b7531d /activerecord/test | |
parent | 33e60514aed85b3076f2636d5f1ccfb513aace1c (diff) | |
parent | cdf8a2b49307953fbcd93df9fdec3c23063740b1 (diff) | |
download | rails-ec7255a2d6f49f7f7b305c10a50f65bfd2a1511e.tar.gz rails-ec7255a2d6f49f7f7b305c10a50f65bfd2a1511e.tar.bz2 rails-ec7255a2d6f49f7f7b305c10a50f65bfd2a1511e.zip |
Merge pull request #27537 from Le6ow5k1/sti
Cache results of computing model type
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/inheritance_test.rb | 14 | ||||
-rw-r--r-- | activerecord/test/cases/reflection_test.rb | 8 |
2 files changed, 14 insertions, 8 deletions
diff --git a/activerecord/test/cases/inheritance_test.rb b/activerecord/test/cases/inheritance_test.rb index 9ad4664567..e570e9ac1d 100644 --- a/activerecord/test/cases/inheritance_test.rb +++ b/activerecord/test/cases/inheritance_test.rb @@ -58,21 +58,21 @@ class InheritanceTest < ActiveRecord::TestCase end def test_compute_type_success - assert_equal Author, ActiveRecord::Base.send(:compute_type, "Author") + assert_equal Author, Company.send(:compute_type, "Author") end def test_compute_type_nonexistent_constant e = assert_raises NameError do - ActiveRecord::Base.send :compute_type, "NonexistentModel" + Company.send :compute_type, "NonexistentModel" end - assert_equal "uninitialized constant ActiveRecord::Base::NonexistentModel", e.message - assert_equal "ActiveRecord::Base::NonexistentModel", e.name + assert_equal "uninitialized constant Company::NonexistentModel", e.message + assert_equal "Company::NonexistentModel", e.name end def test_compute_type_no_method_error ActiveSupport::Dependencies.stub(:safe_constantize, proc { raise NoMethodError }) do assert_raises NoMethodError do - ActiveRecord::Base.send :compute_type, "InvalidModel" + Company.send :compute_type, "InvalidModel" end end end @@ -90,7 +90,7 @@ class InheritanceTest < ActiveRecord::TestCase ActiveSupport::Dependencies.stub(:safe_constantize, proc { raise e }) do exception = assert_raises NameError do - ActiveRecord::Base.send :compute_type, "InvalidModel" + Company.send :compute_type, "InvalidModel" end assert_equal error.message, exception.message end @@ -99,7 +99,7 @@ class InheritanceTest < ActiveRecord::TestCase def test_compute_type_argument_error ActiveSupport::Dependencies.stub(:safe_constantize, proc { raise ArgumentError }) do assert_raises ArgumentError do - ActiveRecord::Base.send :compute_type, "InvalidModel" + Company.send :compute_type, "InvalidModel" end end end diff --git a/activerecord/test/cases/reflection_test.rb b/activerecord/test/cases/reflection_test.rb index a90058e8bb..0ef51272b9 100644 --- a/activerecord/test/cases/reflection_test.rb +++ b/activerecord/test/cases/reflection_test.rb @@ -100,7 +100,13 @@ class ReflectionTest < ActiveRecord::TestCase end def test_reflection_klass_for_nested_class_name - reflection = ActiveRecord::Reflection.create(:has_many, nil, nil, { class_name: "MyApplication::Business::Company" }, ActiveRecord::Base) + reflection = ActiveRecord::Reflection.create( + :has_many, + nil, + nil, + { class_name: "MyApplication::Business::Company" }, + Customer + ) assert_nothing_raised do assert_equal MyApplication::Business::Company, reflection.klass end |