aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorMehmet Emin İNAÇ <mehmetemininac@gmail.com>2015-04-05 01:23:11 +0300
committerMehmet Emin İNAÇ <mehmetemininac@gmail.com>2015-04-06 11:10:24 +0300
commit8c1180731f26e09a5163cfe96b7726c9e425207b (patch)
tree29113e0f7fd800406ef1ca792d296859af5a36e9 /activerecord/test
parenta05f3e5f96f7a8aa55483d91becdbe49b81833fd (diff)
downloadrails-8c1180731f26e09a5163cfe96b7726c9e425207b.tar.gz
rails-8c1180731f26e09a5163cfe96b7726c9e425207b.tar.bz2
rails-8c1180731f26e09a5163cfe96b7726c9e425207b.zip
use singular table name if pluralize_table_names is setted as false while creating foreign key
test case for use singular table name if pluralize_table_names is setted as false while creating foreign key refactor references foreign key addition tests use singular table name while removing foreign key merge foreign key singular table name methods remove unnecessary drop table from test
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