aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/test')
-rwxr-xr-xactiverecord/test/base_test.rb11
-rw-r--r--activerecord/test/migration_test.rb9
2 files changed, 20 insertions, 0 deletions
diff --git a/activerecord/test/base_test.rb b/activerecord/test/base_test.rb
index c9e2d30a9e..4f591e2cac 100755
--- a/activerecord/test/base_test.rb
+++ b/activerecord/test/base_test.rb
@@ -296,31 +296,42 @@ class BasicsTest < Test::Unit::TestCase
assert_equal "master_credit_cards", MasterCreditCard.table_name
ActiveRecord::Base.pluralize_table_names = false
+ [Category, Smarts, CreditCard, MasterCreditCard].each{|c| c.reset_table_name}
assert_equal "category", Category.table_name
assert_equal "smarts", Smarts.table_name
assert_equal "credit_card", CreditCard.table_name
assert_equal "master_credit_card", MasterCreditCard.table_name
ActiveRecord::Base.pluralize_table_names = true
+ [Category, Smarts, CreditCard, MasterCreditCard].each{|c| c.reset_table_name}
ActiveRecord::Base.table_name_prefix = "test_"
+ Category.reset_table_name
assert_equal "test_categories", Category.table_name
ActiveRecord::Base.table_name_suffix = "_test"
+ Category.reset_table_name
assert_equal "test_categories_test", Category.table_name
ActiveRecord::Base.table_name_prefix = ""
+ Category.reset_table_name
assert_equal "categories_test", Category.table_name
ActiveRecord::Base.table_name_suffix = ""
+ Category.reset_table_name
assert_equal "categories", Category.table_name
ActiveRecord::Base.pluralize_table_names = false
ActiveRecord::Base.table_name_prefix = "test_"
+ Category.reset_table_name
assert_equal "test_category", Category.table_name
ActiveRecord::Base.table_name_suffix = "_test"
+ Category.reset_table_name
assert_equal "test_category_test", Category.table_name
ActiveRecord::Base.table_name_prefix = ""
+ Category.reset_table_name
assert_equal "category_test", Category.table_name
ActiveRecord::Base.table_name_suffix = ""
+ Category.reset_table_name
assert_equal "category", Category.table_name
ActiveRecord::Base.pluralize_table_names = true
+ [Category, Smarts, CreditCard, MasterCreditCard].each{|c| c.reset_table_name}
end
def test_destroy_all
diff --git a/activerecord/test/migration_test.rb b/activerecord/test/migration_test.rb
index 317ac3720b..702fef7436 100644
--- a/activerecord/test/migration_test.rb
+++ b/activerecord/test/migration_test.rb
@@ -299,9 +299,11 @@ if ActiveRecord::Base.connection.supports_migrations?
def test_schema_info_table_name
ActiveRecord::Base.table_name_prefix = "prefix_"
ActiveRecord::Base.table_name_suffix = "_suffix"
+ Reminder.reset_table_name
assert_equal "prefix_schema_info_suffix", ActiveRecord::Migrator.schema_info_table_name
ActiveRecord::Base.table_name_prefix = ""
ActiveRecord::Base.table_name_suffix = ""
+ Reminder.reset_table_name
assert_equal "schema_info", ActiveRecord::Migrator.schema_info_table_name
end
@@ -309,6 +311,7 @@ if ActiveRecord::Base.connection.supports_migrations?
assert_equal "table", ActiveRecord::Migrator.proper_table_name('table')
assert_equal "table", ActiveRecord::Migrator.proper_table_name(:table)
assert_equal "reminders", ActiveRecord::Migrator.proper_table_name(Reminder)
+ Reminder.reset_table_name
assert_equal Reminder.table_name, ActiveRecord::Migrator.proper_table_name(Reminder)
# Use the model's own prefix/suffix if a model is given
@@ -316,17 +319,21 @@ if ActiveRecord::Base.connection.supports_migrations?
ActiveRecord::Base.table_name_suffix = "_ARsuffix"
Reminder.table_name_prefix = 'prefix_'
Reminder.table_name_suffix = '_suffix'
+ Reminder.reset_table_name
assert_equal "prefix_reminders_suffix", ActiveRecord::Migrator.proper_table_name(Reminder)
Reminder.table_name_prefix = ''
Reminder.table_name_suffix = ''
+ Reminder.reset_table_name
# Use AR::Base's prefix/suffix if string or symbol is given
ActiveRecord::Base.table_name_prefix = "prefix_"
ActiveRecord::Base.table_name_suffix = "_suffix"
+ Reminder.reset_table_name
assert_equal "prefix_table_suffix", ActiveRecord::Migrator.proper_table_name('table')
assert_equal "prefix_table_suffix", ActiveRecord::Migrator.proper_table_name(:table)
ActiveRecord::Base.table_name_prefix = ""
ActiveRecord::Base.table_name_suffix = ""
+ Reminder.reset_table_name
end
def test_add_drop_table_with_prefix_and_suffix
@@ -334,6 +341,7 @@ if ActiveRecord::Base.connection.supports_migrations?
ActiveRecord::Base.table_name_prefix = 'prefix_'
ActiveRecord::Base.table_name_suffix = '_suffix'
+ Reminder.reset_table_name
WeNeedReminders.up
assert Reminder.create("content" => "hello world", "remind_at" => Time.now)
@@ -343,6 +351,7 @@ if ActiveRecord::Base.connection.supports_migrations?
assert_raises(ActiveRecord::StatementInvalid) { Reminder.find(:first) }
ActiveRecord::Base.table_name_prefix = ''
ActiveRecord::Base.table_name_suffix = ''
+ Reminder.reset_table_name
end
end