diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 18:42:06 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 18:42:06 +0000 |
commit | 6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch) | |
tree | 78be5963ec075d80116a932011d695dd33910b4e /spec/services/suggestions/apply_service_spec.rb | |
parent | 1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff) | |
download | gitlab-ce-6e4e1050d9dba2b7b2523fdd1768823ab85feef4.tar.gz |
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'spec/services/suggestions/apply_service_spec.rb')
-rw-r--r-- | spec/services/suggestions/apply_service_spec.rb | 34 |
1 files changed, 5 insertions, 29 deletions
diff --git a/spec/services/suggestions/apply_service_spec.rb b/spec/services/suggestions/apply_service_spec.rb index aa9caf35987..d8ade0fbbda 100644 --- a/spec/services/suggestions/apply_service_spec.rb +++ b/spec/services/suggestions/apply_service_spec.rb @@ -609,40 +609,16 @@ RSpec.describe Suggestions::ApplyService do end end - context 'suggestion is eligible to be outdated' do - it 'returns error message' do - expect(suggestion).to receive(:outdated?) { true } - - result = apply_service.new(user, suggestion).execute - - expect(result).to eq(message: 'A suggestion is not applicable.', - status: :error) - end - end - - context 'note is outdated' do - before do - allow(diff_note).to receive(:active?) { false } - end + context 'suggestion is not appliable' do + let(:inapplicable_reason) { "Can't apply this suggestion." } it 'returns error message' do - result = apply_service.new(user, suggestion).execute - - expect(result).to eq(message: 'A suggestion is not applicable.', - status: :error) - end - end + expect(suggestion).to receive(:appliable?).and_return(false) + expect(suggestion).to receive(:inapplicable_reason).and_return(inapplicable_reason) - context 'suggestion was already applied' do - before do - suggestion.update!(applied: true, commit_id: 'sha') - end - - it 'returns error message' do result = apply_service.new(user, suggestion).execute - expect(result).to eq(message: 'A suggestion is not applicable.', - status: :error) + expect(result).to eq(message: inapplicable_reason, status: :error) end end |