From 1ac4b24dd3153acd1fa7a66f6261911ee74ce734 Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Sun, 14 Apr 2019 15:56:02 -0700 Subject: Add spec for CompareService The return result for the source or target branch being missing was ambiguous before. It should be an empty compare to indicate no comparison could be done. --- spec/services/compare_service_spec.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/spec/services/compare_service_spec.rb b/spec/services/compare_service_spec.rb index 0e4ef69ec19..fadd43635a6 100644 --- a/spec/services/compare_service_spec.rb +++ b/spec/services/compare_service_spec.rb @@ -19,5 +19,18 @@ describe CompareService do it { expect(subject.diffs.size).to eq(3) } end + + context 'compare with target branch that does not exist' do + subject { service.execute(project, 'non-existent-ref') } + + it { expect(subject).to be_nil } + end + + context 'compare with source branch that does not exist' do + let(:service) { described_class.new(project, 'non-existent-branch') } + subject { service.execute(project, 'non-existent-ref') } + + it { expect(subject).to be_nil } + end end end -- cgit v1.2.1