From bc7030cb3f0e19b94a79db48b37cac954841ecf4 Mon Sep 17 00:00:00 2001 From: eileencodes Date: Tue, 1 Jul 2014 08:19:04 -0400 Subject: 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. --- activerecord/test/cases/reflection_test.rb | 32 ++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'activerecord/test/cases') 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) -- cgit v1.2.3