diff options
author | Yves Senn <yves.senn@gmail.com> | 2014-07-22 15:04:29 +0200 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2014-07-22 15:04:29 +0200 |
commit | aa3740ebd24e9c00c1611d91b4ebcc7f19e849be (patch) | |
tree | 39f6f7c82ef2e5935b4b81590bfddc21ff4dfe06 /activerecord/test | |
parent | bb3b2d0b092af3c311ca06c5481b45ee6ee1b5b1 (diff) | |
parent | 6d327dbc0cd7969375e14a56c0a9bc6a7c847056 (diff) | |
download | rails-aa3740ebd24e9c00c1611d91b4ebcc7f19e849be.tar.gz rails-aa3740ebd24e9c00c1611d91b4ebcc7f19e849be.tar.bz2 rails-aa3740ebd24e9c00c1611d91b4ebcc7f19e849be.zip |
Merge pull request #16231 from Envek/type_in_references
* Allow to specify a type for foreign key column in migrations
* unified the docs
* some cleanup in CHANGELOG
Diffstat (limited to 'activerecord/test')
3 files changed, 20 insertions, 1 deletions
diff --git a/activerecord/test/cases/adapters/postgresql/uuid_test.rb b/activerecord/test/cases/adapters/postgresql/uuid_test.rb index d7ff81a382..66006d718f 100644 --- a/activerecord/test/cases/adapters/postgresql/uuid_test.rb +++ b/activerecord/test/cases/adapters/postgresql/uuid_test.rb @@ -233,7 +233,7 @@ class PostgresqlUUIDTestInverseOf < ActiveRecord::TestCase t.string 'title' end connection.create_table('pg_uuid_comments', id: :uuid) do |t| - t.uuid :uuid_post_id, default: 'uuid_generate_v4()' + t.references :uuid_post, type: :uuid t.string 'content' end end diff --git a/activerecord/test/cases/migration/change_table_test.rb b/activerecord/test/cases/migration/change_table_test.rb index a6d506b04a..3e9d957ed3 100644 --- a/activerecord/test/cases/migration/change_table_test.rb +++ b/activerecord/test/cases/migration/change_table_test.rb @@ -72,6 +72,20 @@ module ActiveRecord end end + def test_references_column_type_with_polymorphic_and_type + with_change_table do |t| + @connection.expect :add_reference, nil, [:delete_me, :taggable, polymorphic: true, type: :string] + t.references :taggable, polymorphic: true, type: :string + end + end + + def test_remove_references_column_type_with_polymorphic_and_type + with_change_table do |t| + @connection.expect :remove_reference, nil, [:delete_me, :taggable, polymorphic: true, type: :string] + t.remove_references :taggable, polymorphic: true, type: :string + end + end + def test_timestamps_creates_updated_at_and_created_at with_change_table do |t| @connection.expect :add_timestamps, nil, [:delete_me] diff --git a/activerecord/test/cases/migration/references_statements_test.rb b/activerecord/test/cases/migration/references_statements_test.rb index e9545f2cce..b8b4fa1135 100644 --- a/activerecord/test/cases/migration/references_statements_test.rb +++ b/activerecord/test/cases/migration/references_statements_test.rb @@ -55,6 +55,11 @@ module ActiveRecord assert index_exists?(table_name, :tag_id, name: 'index_taggings_on_tag_id') end + def test_creates_reference_id_with_specified_type + add_reference table_name, :user, type: :string + assert column_exists?(table_name, :user_id, :string) + end + def test_deletes_reference_id_column remove_reference table_name, :supplier assert_not column_exists?(table_name, :supplier_id, :integer) |