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

base_issue_tracker_spec.rb « integrations « models « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0f1bc39929ad37c6470629c9aab91bc54cfa480f (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Integrations::BaseIssueTracker do
  describe 'Validations' do
    let(:project) { create :project }

    describe 'only one issue tracker per project' do
      let(:service) { Integrations::Redmine.new(project: project, active: true, issue_tracker_data: build(:issue_tracker_data)) }

      before do
        create(:custom_issue_tracker_integration, project: project)
      end

      context 'when service is changed manually by user' do
        it 'executes the validation' do
          valid = service.valid?(:manual_change)

          expect(valid).to be_falsey
          expect(service.errors[:base]).to include(
            'Another issue tracker is already in use. Only one issue tracker service can be active at a time'
          )
        end
      end

      context 'when service is changed internally' do
        it 'does not execute the validation' do
          expect(service.valid?).to be_truthy
        end
      end
    end
  end
end