diff options
Diffstat (limited to 'spec/services/suggestions')
-rw-r--r-- | spec/services/suggestions/apply_service_spec.rb | 34 | ||||
-rw-r--r-- | spec/services/suggestions/create_service_spec.rb | 1 |
2 files changed, 6 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 diff --git a/spec/services/suggestions/create_service_spec.rb b/spec/services/suggestions/create_service_spec.rb index 54e7c5cc127..80823364fe8 100644 --- a/spec/services/suggestions/create_service_spec.rb +++ b/spec/services/suggestions/create_service_spec.rb @@ -159,6 +159,7 @@ RSpec.describe Suggestions::CreateService do ``` MARKDOWN end + let(:position) { build_position(new_line: 13) } it 'creates an appliable suggestion' do |