Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix #43] Remove change_column_null from BulkChangeTable #48

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## master (unreleased)

### Bug fixes

* [#43](https://github.com/rubocop-hq/rubocop-rails/issues/43): Remove `change_column_null` method from `BulkChangeTable` cop offenses. ([@anthony-robin][])

## 2.0.1 (2019-06-08)

### Changes
Expand All @@ -18,3 +22,4 @@
[@koic]: https://github.com/koic
[@andyw8]: https://github.com/andyw8
[@buehmann]: https://github.com/buehmann
[@anthony-robin]: https://github.com/anthony-robin
1 change: 0 additions & 1 deletion lib/rubocop/cop/rails/bulk_change_table.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ class BulkChangeTable < Cop

POSTGRESQL_COMBINABLE_ALTER_METHODS = %i[
change_column_default
change_column_null
].freeze

def on_def(node)
Expand Down
18 changes: 17 additions & 1 deletion spec/rubocop/cop/rails/bulk_change_table_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,18 @@ def change

it 'registers an offense when including combinable alter methods' do
expect_offense(<<~RUBY)
def change
change_column_default :users, :name, false
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ You can use `change_table :users, bulk: true` to combine alter queries.
change_column_default :users, :address, false
end
RUBY
end

it 'does not register an offense for `change_column_null`' do
expect_no_offenses(<<-RUBY.strip_indent)
def change
change_column_null :users, :name, false
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ You can use `change_table :users, bulk: true` to combine alter queries.
change_column_null :users, :address, false
end
RUBY
Expand All @@ -139,6 +148,13 @@ def change
it 'does not register an offense' \
'when including combinable alter methods' do
expect_no_offenses(<<~RUBY)
def change
change_column_default :users, :name, false
change_column_default :users, :address, false
end
RUBY

expect_no_offenses(<<-RUBY.strip_indent)
def change
change_column_null :users, :name, false
change_column_null :users, :address, false
Expand Down