-
-
Notifications
You must be signed in to change notification settings - Fork 14
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
Migration helper module #45
Conversation
context 'when a change block is used outside of a Sequel migration' do | ||
let(:source) do | ||
<<~SOURCE | ||
it { expect { subject }.to change { document_count(user_id) }.by(-1) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test case taken directly from the reported issue:
#44
@@ -5,6 +5,8 @@ module Cop | |||
module Sequel | |||
# IrreversibleMigration looks for methods inside a `change` block that cannot be reversed. | |||
class IrreversibleMigration < Base | |||
include RuboCop::Cop::Sequel::Helpers::Migration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may want to apply this to other migration related cops?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! I've updated the PR description with these additional changes, and also created a spec helper module to wrap test code in a Sequel.migration
block.
Resolves this issue: #44
Bug was introduced in this PR: #43
Primary Change
IrreversibleMigration
will now check if achange
block is inside aSequel.migration
block before checking for offensesNew patterns
lib
lib/rubocop/cop/sequel/helpers/
module Migration
(Can be included viainclude Helpers::Migration
)Sequel.migration
block before checking for offenses.spec
spec/rubocop/cop/sequel/helpers
module Migration
(Can be included viainclude Spec::Helpers::Migration
)#inspect_source_within_migration
#inspect_source
. Will wrap thesource
argument within aSequel.migration
block