aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorYves Senn <yves.senn@gmail.com>2015-04-06 10:40:14 +0200
committerYves Senn <yves.senn@gmail.com>2015-04-06 10:42:44 +0200
commit51eacc71c7d2a6d0fc23556b32e12a21ee49b948 (patch)
tree5d49984b4a332be6656e4031a8140ae9c48d1609 /activerecord/test
parente527688d19f7f11780a6d01a45e6625c34eb8e7d (diff)
parent8c1180731f26e09a5163cfe96b7726c9e425207b (diff)
downloadrails-51eacc71c7d2a6d0fc23556b32e12a21ee49b948.tar.gz
rails-51eacc71c7d2a6d0fc23556b32e12a21ee49b948.tar.bz2
rails-51eacc71c7d2a6d0fc23556b32e12a21ee49b948.zip
Merge pull request #19652 from vngrs/pluralize_foreign_key_table_name_bug
use singular table name if pluralize_table_names is setted as false whil...
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/migration/references_foreign_key_test.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/activerecord/test/cases/migration/references_foreign_key_test.rb b/activerecord/test/cases/migration/references_foreign_key_test.rb
index 17ac72a109..87348d0f90 100644
--- a/activerecord/test/cases/migration/references_foreign_key_test.rb
+++ b/activerecord/test/cases/migration/references_foreign_key_test.rb
@@ -105,6 +105,28 @@ module ActiveRecord
@connection.remove_reference :testings, :testing_parent, foreign_key: true
end
end
+
+ test "foreign key methods respect pluralize_table_names" do
+ begin
+ original_pluralize_table_names = ActiveRecord::Base.pluralize_table_names
+ ActiveRecord::Base.pluralize_table_names = false
+ @connection.create_table :testing
+ @connection.change_table :testing_parents do |t|
+ t.references :testing, foreign_key: true
+ end
+
+ fk = @connection.foreign_keys("testing_parents").first
+ assert_equal "testing_parents", fk.from_table
+ assert_equal "testing", fk.to_table
+
+ assert_difference "@connection.foreign_keys('testing_parents').size", -1 do
+ @connection.remove_reference :testing_parents, :testing, foreign_key: true
+ end
+ ensure
+ ActiveRecord::Base.pluralize_table_names = original_pluralize_table_names
+ @connection.drop_table "testing", if_exists: true
+ end
+ end
end
end
end