diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-11 00:09:29 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-11 00:09:29 +0300 |
commit | 4f584f7b63332ac0ffc5e533a1dde89b0c365728 (patch) | |
tree | 7654fbc027d2038a3fc140281437d99c8b1bd7b7 /spec/rubocop/cop/migration | |
parent | 82ea71eb4f4a7cc5583ddbc3d6ab2444b3d4213a (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/rubocop/cop/migration')
-rw-r--r-- | spec/rubocop/cop/migration/add_limit_to_text_columns_spec.rb | 21 | ||||
-rw-r--r-- | spec/rubocop/cop/migration/prevent_strings_spec.rb | 21 |
2 files changed, 42 insertions, 0 deletions
diff --git a/spec/rubocop/cop/migration/add_limit_to_text_columns_spec.rb b/spec/rubocop/cop/migration/add_limit_to_text_columns_spec.rb index 514260a4306..39ca9ace73d 100644 --- a/spec/rubocop/cop/migration/add_limit_to_text_columns_spec.rb +++ b/spec/rubocop/cop/migration/add_limit_to_text_columns_spec.rb @@ -73,6 +73,27 @@ describe RuboCop::Cop::Migration::AddLimitToTextColumns do end end + context 'when text array columns are defined without a limit' do + it 'registers no offense' do + expect_no_offenses(<<~RUBY) + class TestTextLimits < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def up + create_table :test_text_limits, id: false do |t| + t.integer :test_id, null: false + t.text :name, array: true, default: [], null: false + end + + add_column :test_text_limits, :email, :text, array: true + add_column_with_default :test_text_limits, :role, :text, default: [], array: true + change_column_type_concurrently :test_text_limits, :test_id, :text, array: true + end + end + RUBY + end + end + # Make sure that the cop is properly checking for an `add_text_limit` # over the same {table, attribute} as the one that triggered the offence context 'when the limit is defined for a same name attribute but different table' do diff --git a/spec/rubocop/cop/migration/prevent_strings_spec.rb b/spec/rubocop/cop/migration/prevent_strings_spec.rb index 2702ce1c090..d0e97874aed 100644 --- a/spec/rubocop/cop/migration/prevent_strings_spec.rb +++ b/spec/rubocop/cop/migration/prevent_strings_spec.rb @@ -90,6 +90,27 @@ describe RuboCop::Cop::Migration::PreventStrings do end end + context 'when the string data type is used for arrays' do + it 'registers no offense' do + expect_no_offenses(<<~RUBY) + class TestStringArrays < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def up + create_table :test_string_arrays, id: false do |t| + t.integer :test_id, null: false + t.string :name, array: true, default: [], null: false + end + + add_column :test_string_arrays, :email, :string, array: true + add_column_with_default :test_string_arrays, :role, :string, default: [], array: true + change_column_type_concurrently :test_string_arrays, :test_id, :string, array: true + end + end + RUBY + end + end + context 'on down' do it 'registers no offense' do expect_no_offenses(<<~RUBY) |