diff options
author | Yves Senn <yves.senn@gmail.com> | 2012-10-28 18:05:30 +0100 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2012-10-28 20:40:37 +0100 |
commit | e4790a2c5b99704f430c837d8f22fec418f2c8af (patch) | |
tree | d774ad70503daabeaba3233a0da1f7fcf94a7e17 /activerecord/test/cases/migration | |
parent | b104157314e95115b74e7ddd968f9c7734309a6e (diff) | |
download | rails-e4790a2c5b99704f430c837d8f22fec418f2c8af.tar.gz rails-e4790a2c5b99704f430c837d8f22fec418f2c8af.tar.bz2 rails-e4790a2c5b99704f430c837d8f22fec418f2c8af.zip |
raise `ArgumentError` when redefining the primary key column. Closes #6378
Diffstat (limited to 'activerecord/test/cases/migration')
-rw-r--r-- | activerecord/test/cases/migration/change_schema_test.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/activerecord/test/cases/migration/change_schema_test.rb b/activerecord/test/cases/migration/change_schema_test.rb index 17c1634444..86451289e7 100644 --- a/activerecord/test/cases/migration/change_schema_test.rb +++ b/activerecord/test/cases/migration/change_schema_test.rb @@ -132,6 +132,26 @@ module ActiveRecord assert_equal %w(foo testingid), connection.columns(:testings).map(&:name).sort end + def test_create_table_raises_when_redefining_primary_key_column + error = assert_raise(ArgumentError) do + connection.create_table :testings do |t| + t.column :id, :string + end + end + + assert_equal "you can't redefine the primary key column 'id'. To define a custom primary key, pass { id: false } to create_table.", error.message + end + + def test_create_table_raises_when_redefining_custom_primary_key_column + error = assert_raise(ArgumentError) do + connection.create_table :testings, primary_key: :testing_id do |t| + t.column :testing_id, :string + end + end + + assert_equal "you can't redefine the primary key column 'testing_id'. To define a custom primary key, pass { id: false } to create_table.", error.message + end + def test_create_table_with_timestamps_should_create_datetime_columns connection.create_table table_name do |t| t.timestamps |