aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/reflection_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/test/reflection_test.rb')
-rw-r--r--activerecord/test/reflection_test.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/activerecord/test/reflection_test.rb b/activerecord/test/reflection_test.rb
index cc06d31299..1ed5c2610c 100644
--- a/activerecord/test/reflection_test.rb
+++ b/activerecord/test/reflection_test.rb
@@ -111,6 +111,15 @@ class ReflectionTest < Test::Unit::TestCase
assert_equal 'accounts', Firm.reflect_on_association(:account).table_name
end
+ def test_belongs_to_inferred_foreign_key_from_assoc_name
+ Company.belongs_to :foo
+ assert_equal "foo_id", Company.reflect_on_association(:foo).primary_key_name
+ Company.belongs_to :bar, :class_name => "Xyzzy"
+ assert_equal "bar_id", Company.reflect_on_association(:bar).primary_key_name
+ Company.belongs_to :baz, :class_name => "Xyzzy", :foreign_key => "xyzzy_id"
+ assert_equal "xyzzy_id", Company.reflect_on_association(:baz).primary_key_name
+ end
+
def test_association_reflection_in_modules
assert_reflection MyApplication::Business::Firm,
:clients_of_firm,