diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-13 15:09:21 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-13 15:09:21 +0000 |
commit | c36152ff8c41fad2f413f253eb7ac5c927e47c56 (patch) | |
tree | bbf300da207de3e8bbf272d44111ceedb18f5833 /spec/rubocop | |
parent | 286fe61013674fe2d245ffc8d2233baf09923e70 (diff) | |
download | gitlab-ce-c36152ff8c41fad2f413f253eb7ac5c927e47c56.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/rubocop')
-rw-r--r-- | spec/rubocop/cop/migration/with_lock_retries_with_change_spec.rb | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/spec/rubocop/cop/migration/with_lock_retries_with_change_spec.rb b/spec/rubocop/cop/migration/with_lock_retries_with_change_spec.rb new file mode 100644 index 00000000000..75a1f939a9f --- /dev/null +++ b/spec/rubocop/cop/migration/with_lock_retries_with_change_spec.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +require 'spec_helper' + +require 'rubocop' +require 'rubocop/rspec/support' + +require_relative '../../../../rubocop/cop/migration/with_lock_retries_with_change' + +describe RuboCop::Cop::Migration::WithLockRetriesWithChange do + include CopHelper + + subject(:cop) { described_class.new } + + context 'in migration' do + before do + allow(cop).to receive(:in_migration?).and_return(true) + end + + it 'registers an offense when `with_lock_retries` is used inside a `change` method' do + inspect_source('def change; with_lock_retries {}; end') + + aggregate_failures do + expect(cop.offenses.size).to eq(1) + expect(cop.offenses.map(&:line)).to eq([1]) + end + end + + it 'registers no offense when `with_lock_retries` is used inside an `up` method' do + inspect_source('def up; with_lock_retries {}; end') + + expect(cop.offenses.size).to eq(0) + end + end + + context 'outside of migration' do + it 'registers no offense' do + inspect_source('def change; with_lock_retries {}; end') + + expect(cop.offenses.size).to eq(0) + end + end +end |