aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/reflection_test.rb
diff options
context:
space:
mode:
authoreileencodes <eileencodes@gmail.com>2014-07-01 08:19:04 -0400
committereileencodes <eileencodes@gmail.com>2014-07-01 14:00:05 -0400
commitbc7030cb3f0e19b94a79db48b37cac954841ecf4 (patch)
tree26cb86c46b5502b01c0d7d1f781aa92eedebc4fc /activerecord/test/cases/reflection_test.rb
parentda57d0b2d4375c09f56c9d94ef78a3d2ce8f4c62 (diff)
downloadrails-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/test/cases/reflection_test.rb')
-rw-r--r--activerecord/test/cases/reflection_test.rb32
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)