summaryrefslogtreecommitdiff
path: root/spec/services/suggestions
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-08-20 18:42:06 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-08-20 18:42:06 +0000
commit6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch)
tree78be5963ec075d80116a932011d695dd33910b4e /spec/services/suggestions
parent1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff)
downloadgitlab-ce-6e4e1050d9dba2b7b2523fdd1768823ab85feef4.tar.gz
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'spec/services/suggestions')
-rw-r--r--spec/services/suggestions/apply_service_spec.rb34
-rw-r--r--spec/services/suggestions/create_service_spec.rb1
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