2019-04-11 08:17:24 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-09-29 10:21:19 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-07-10 10:24:02 -04:00
|
|
|
describe CompareService do
|
2017-03-27 17:14:01 -04:00
|
|
|
let(:project) { create(:project, :repository) }
|
2016-09-29 10:21:19 -04:00
|
|
|
let(:user) { create(:user) }
|
2016-12-08 04:57:52 -05:00
|
|
|
let(:service) { described_class.new(project, 'feature') }
|
2016-09-29 10:21:19 -04:00
|
|
|
|
|
|
|
describe '#execute' do
|
|
|
|
context 'compare with base, like feature...fix' do
|
2016-12-08 04:57:52 -05:00
|
|
|
subject { service.execute(project, 'fix', straight: false) }
|
2016-09-29 10:21:19 -04:00
|
|
|
|
|
|
|
it { expect(subject.diffs.size).to eq(1) }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'straight compare, like feature..fix' do
|
2016-12-08 04:57:52 -05:00
|
|
|
subject { service.execute(project, 'fix', straight: true) }
|
2016-09-29 10:21:19 -04:00
|
|
|
|
|
|
|
it { expect(subject.diffs.size).to eq(3) }
|
|
|
|
end
|
2019-04-14 18:56:02 -04:00
|
|
|
|
|
|
|
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') }
|
2019-12-12 07:07:33 -05:00
|
|
|
|
2019-04-14 18:56:02 -04:00
|
|
|
subject { service.execute(project, 'non-existent-ref') }
|
|
|
|
|
|
|
|
it { expect(subject).to be_nil }
|
|
|
|
end
|
2016-09-29 10:21:19 -04:00
|
|
|
end
|
|
|
|
end
|