debian-mirror-gitlab/spec/services/compare_service_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

38 lines
1 KiB
Ruby
Raw Normal View History

2019-07-31 22:56:46 +05:30
# frozen_string_literal: true
2016-11-03 12:29:30 +05:30
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe CompareService do
2017-08-17 22:00:37 +05:30
let(:project) { create(:project, :repository) }
2016-11-03 12:29:30 +05:30
let(:user) { create(:user) }
2017-08-17 22:00:37 +05:30
let(:service) { described_class.new(project, 'feature') }
2016-11-03 12:29:30 +05:30
describe '#execute' do
context 'compare with base, like feature...fix' do
2017-08-17 22:00:37 +05:30
subject { service.execute(project, 'fix', straight: false) }
2016-11-03 12:29:30 +05:30
it { expect(subject.diffs.size).to eq(1) }
end
context 'straight compare, like feature..fix' do
2017-08-17 22:00:37 +05:30
subject { service.execute(project, 'fix', straight: true) }
2016-11-03 12:29:30 +05:30
it { expect(subject.diffs.size).to eq(3) }
end
2019-07-31 22:56:46 +05:30
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') }
2020-01-01 13:55:28 +05:30
2019-07-31 22:56:46 +05:30
subject { service.execute(project, 'non-existent-ref') }
it { expect(subject).to be_nil }
end
2016-11-03 12:29:30 +05:30
end
end