summaryrefslogtreecommitdiff
path: root/spec/serializers/suggestion_entity_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/serializers/suggestion_entity_spec.rb')
-rw-r--r--spec/serializers/suggestion_entity_spec.rb82
1 files changed, 3 insertions, 79 deletions
diff --git a/spec/serializers/suggestion_entity_spec.rb b/spec/serializers/suggestion_entity_spec.rb
index b133c3fb82e..25301bb20cc 100644
--- a/spec/serializers/suggestion_entity_spec.rb
+++ b/spec/serializers/suggestion_entity_spec.rb
@@ -36,87 +36,11 @@ RSpec.describe SuggestionEntity do
let(:can_apply_suggestion) { true }
before do
- allow(suggestion).to receive(:appliable?).and_return(appliable)
+ allow(suggestion).to receive(:inapplicable_reason).and_return("Can't apply this suggestion.")
end
- context 'and suggestion is appliable' do
- let(:appliable) { true }
-
- it 'returns nil' do
- expect(inapplicable_reason).to be_nil
- end
- end
-
- context 'but suggestion is not applicable' do
- let(:appliable) { false }
-
- before do
- allow(suggestion).to receive(:inapplicable_reason).and_return(reason)
- end
-
- context 'and merge request was merged' do
- let(:reason) { :merge_request_merged }
-
- it 'returns appropriate message' do
- expect(inapplicable_reason).to eq("This merge request was merged. To apply this suggestion, edit this file directly.")
- end
- end
-
- context 'and source branch was deleted' do
- let(:reason) { :source_branch_deleted }
-
- it 'returns appropriate message' do
- expect(inapplicable_reason).to eq("Can't apply as the source branch was deleted.")
- end
- end
-
- context 'and merge request is closed' do
- let(:reason) { :merge_request_closed }
-
- it 'returns appropriate message' do
- expect(inapplicable_reason).to eq("This merge request is closed. To apply this suggestion, edit this file directly.")
- end
- end
-
- context 'and suggestion is outdated' do
- let(:reason) { :outdated }
-
- before do
- allow(suggestion).to receive(:single_line?).and_return(single_line)
- end
-
- context 'and suggestion is for a single line' do
- let(:single_line) { true }
-
- it 'returns appropriate message' do
- expect(inapplicable_reason).to eq("Can't apply as this line was changed in a more recent version.")
- end
- end
-
- context 'and suggestion is for multiple lines' do
- let(:single_line) { false }
-
- it 'returns appropriate message' do
- expect(inapplicable_reason).to eq("Can't apply as these lines were changed in a more recent version.")
- end
- end
- end
-
- context 'and suggestion has the same content' do
- let(:reason) { :same_content }
-
- it 'returns appropriate message' do
- expect(inapplicable_reason).to eq("This suggestion already matches its content.")
- end
- end
-
- context 'and suggestion is inapplicable for other reasons' do
- let(:reason) { :some_other_reason }
-
- it 'returns default message' do
- expect(inapplicable_reason).to eq("Can't apply this suggestion.")
- end
- end
+ it 'returns the inapplicable reason' do
+ expect(inapplicable_reason).to eq(suggestion.inapplicable_reason)
end
end