diff options
author | eileencodes <eileencodes@gmail.com> | 2014-07-01 08:19:04 -0400 |
---|---|---|
committer | eileencodes <eileencodes@gmail.com> | 2014-07-01 14:00:05 -0400 |
commit | bc7030cb3f0e19b94a79db48b37cac954841ecf4 (patch) | |
tree | 26cb86c46b5502b01c0d7d1f781aa92eedebc4fc /activerecord | |
parent | da57d0b2d4375c09f56c9d94ef78a3d2ce8f4c62 (diff) | |
download | rails-bc7030cb3f0e19b94a79db48b37cac954841ecf4.tar.gz rails-bc7030cb3f0e19b94a79db48b37cac954841ecf4.tar.bz2 rails-bc7030cb3f0e19b94a79db48b37cac954841ecf4.zip |
Add regression tests for keys on nested associations
This adds the regressions tests from issue #15893 to
master. It's checking that both strings and symbols are
accepted as keys for nested associations.
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/test/cases/reflection_test.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/activerecord/test/cases/reflection_test.rb b/activerecord/test/cases/reflection_test.rb index acbd065649..b41a7ee787 100644 --- a/activerecord/test/cases/reflection_test.rb +++ b/activerecord/test/cases/reflection_test.rb @@ -412,6 +412,38 @@ class ReflectionTest < ActiveRecord::TestCase assert_equal 'product_categories', reflection.join_table end + def test_includes_accepts_symbols + hotel = Hotel.create! + department = hotel.departments.create! + department.chefs.create! + + assert_nothing_raised do + assert_equal department.chefs, Hotel.includes([departments: :chefs]).first.chefs + end + end + + def test_includes_accepts_strings + hotel = Hotel.create! + department = hotel.departments.create! + department.chefs.create! + + assert_nothing_raised do + assert_equal department.chefs, Hotel.includes(['departments' => 'chefs']).first.chefs + end + end + + def test_reflect_on_association_accepts_symbols + assert_nothing_raised do + assert_equal Hotel.reflect_on_association(:departments).name, :departments + end + end + + def test_reflect_on_association_accepts_strings + assert_nothing_raised do + assert_equal Hotel.reflect_on_association("departments").name, :departments + end + end + private def assert_reflection(klass, association, options) assert reflection = klass.reflect_on_association(association) |