aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2014-07-01 15:21:39 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2014-07-01 15:21:39 -0300
commitad778bc422b338a7ef4de613a5919667ce2196ba (patch)
treeebc9e61e85784ec6222bb029a50df89434eb89d8 /activerecord/test
parent7bd62061601ec53c1d79ed9639ed64a93ea4e043 (diff)
parentbc7030cb3f0e19b94a79db48b37cac954841ecf4 (diff)
downloadrails-ad778bc422b338a7ef4de613a5919667ce2196ba.tar.gz
rails-ad778bc422b338a7ef4de613a5919667ce2196ba.tar.bz2
rails-ad778bc422b338a7ef4de613a5919667ce2196ba.zip
Merge pull request #15999 from eileencodes/add-regression-tests-for-keys-on-nested-associations
Add regression tests for keys on nested associations
Diffstat (limited to 'activerecord/test')
-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)