aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/primary_keys_test.rb
diff options
context:
space:
mode:
authorPrathamesh Sonpatki <csonpatki@gmail.com>2016-08-21 19:55:32 +0530
committerRafael Mendonça França <rafaelmfranca@gmail.com>2017-04-26 22:59:35 -0700
commitebeae19917bfed29f0ce7efa013ae950d22953f3 (patch)
treeb86a76e70b1226665932496b5fa353d84a134810 /activerecord/test/cases/primary_keys_test.rb
parentf67ddb0ffebb6e3e2bb88536c27975a4cc92de55 (diff)
downloadrails-ebeae19917bfed29f0ce7efa013ae950d22953f3.tar.gz
rails-ebeae19917bfed29f0ce7efa013ae950d22953f3.tar.bz2
rails-ebeae19917bfed29f0ce7efa013ae950d22953f3.zip
Don't use same table between primary_keys tests and composite_primary_keys tests
- The test `PrimaryKeyAnyTypeTest#test_any_type_primary_key` was failing if ran after running all tests from `CompositePrimaryKeyTest`. - This was happening because `CompositePrimaryKeyTest` was changing the primary key of the barcodes table which was cached in schema cache. - As we were always going to drop the `barcodes` table at the end of tests in both `PrimaryKeyTest` and `CompositePrimaryKeyTest`, solved this issue by using different table name for tests in `CompositePrimaryKeyTest`.
Diffstat (limited to 'activerecord/test/cases/primary_keys_test.rb')
-rw-r--r--activerecord/test/cases/primary_keys_test.rb14
1 files changed, 7 insertions, 7 deletions
diff --git a/activerecord/test/cases/primary_keys_test.rb b/activerecord/test/cases/primary_keys_test.rb
index 5ded619716..80cbfdba06 100644
--- a/activerecord/test/cases/primary_keys_test.rb
+++ b/activerecord/test/cases/primary_keys_test.rb
@@ -311,7 +311,7 @@ class CompositePrimaryKeyTest < ActiveRecord::TestCase
def setup
@connection = ActiveRecord::Base.connection
@connection.schema_cache.clear!
- @connection.create_table(:barcodes, primary_key: ["region", "code"], force: true) do |t|
+ @connection.create_table(:uber_barcodes, primary_key: ["region", "code"], force: true) do |t|
t.string :region
t.integer :code
end
@@ -322,11 +322,11 @@ class CompositePrimaryKeyTest < ActiveRecord::TestCase
end
def teardown
- @connection.drop_table(:barcodes, if_exists: true)
+ @connection.drop_table(:uber_barcodes, if_exists: true)
end
def test_composite_primary_key
- assert_equal ["region", "code"], @connection.primary_keys("barcodes")
+ assert_equal ["region", "code"], @connection.primary_keys("uber_barcodes")
end
def test_composite_primary_key_out_of_order
@@ -337,7 +337,7 @@ class CompositePrimaryKeyTest < ActiveRecord::TestCase
def test_primary_key_issues_warning
model = Class.new(ActiveRecord::Base) do
def self.table_name
- "barcodes"
+ "uber_barcodes"
end
end
warning = capture(:stderr) do
@@ -346,9 +346,9 @@ class CompositePrimaryKeyTest < ActiveRecord::TestCase
assert_match(/WARNING: Active Record does not support composite primary key\./, warning)
end
- def test_dumping_composite_primary_key
- schema = dump_table_schema "barcodes"
- assert_match %r{create_table "barcodes", primary_key: \["region", "code"\]}, schema
+ def test_collectly_dump_composite_primary_key
+ schema = dump_table_schema "uber_barcodes"
+ assert_match %r{create_table "uber_barcodes", primary_key: \["region", "code"\]}, schema
end
def test_dumping_composite_primary_key_out_of_order