Welcome to mirror list, hosted at ThFree Co, Russian Federation.

compare_service_spec.rb « services « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6757fbdf5d44c4c3e1d050d28ad2b2b9465bcd14 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe CompareService, feature_category: :source_code_management do
  let(:project) { create(:project, :repository) }
  let(:user) { create(:user) }
  let(:service) { described_class.new(project, 'feature') }

  describe '#execute' do
    context 'compare with base, like feature...fix' do
      subject { service.execute(project, 'fix', straight: false) }

      it { expect(subject.diffs.size).to eq(1) }
    end

    context 'straight compare, like feature..fix' do
      subject { service.execute(project, 'fix', straight: true) }

      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