summaryrefslogtreecommitdiff
path: root/spec/services/suggestions/apply_service_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/services/suggestions/apply_service_spec.rb')
-rw-r--r--spec/services/suggestions/apply_service_spec.rb34
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