2019-03-30 03:23:56 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-10-08 12:51:44 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2021-06-03 23:10:08 -04:00
|
|
|
RSpec.describe Integrations::BaseIssueTracker do
|
2022-03-07 04:13:09 -05:00
|
|
|
let(:integration) { Integrations::Redmine.new(project: project, active: true, issue_tracker_data: build(:issue_tracker_data)) }
|
2016-10-08 12:51:44 -04:00
|
|
|
|
2022-03-07 04:13:09 -05:00
|
|
|
let_it_be_with_refind(:project) { create :project }
|
2016-10-08 12:51:44 -04:00
|
|
|
|
2022-03-07 04:13:09 -05:00
|
|
|
describe 'Validations' do
|
|
|
|
describe 'only one issue tracker per project' do
|
2016-10-08 12:51:44 -04:00
|
|
|
before do
|
2021-06-09 14:11:25 -04:00
|
|
|
create(:custom_issue_tracker_integration, project: project)
|
2016-10-08 12:51:44 -04:00
|
|
|
end
|
|
|
|
|
2021-06-30 20:08:17 -04:00
|
|
|
context 'when integration is changed manually by user' do
|
2016-10-08 12:51:44 -04:00
|
|
|
it 'executes the validation' do
|
2021-06-30 20:08:17 -04:00
|
|
|
valid = integration.valid?(:manual_change)
|
2016-10-08 12:51:44 -04:00
|
|
|
|
|
|
|
expect(valid).to be_falsey
|
2021-06-30 20:08:17 -04:00
|
|
|
expect(integration.errors[:base]).to include(
|
2016-10-08 12:51:44 -04:00
|
|
|
'Another issue tracker is already in use. Only one issue tracker service can be active at a time'
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-06-30 20:08:17 -04:00
|
|
|
context 'when integration is changed internally' do
|
2016-10-08 12:51:44 -04:00
|
|
|
it 'does not execute the validation' do
|
2021-06-30 20:08:17 -04:00
|
|
|
expect(integration.valid?).to be_truthy
|
2016-10-08 12:51:44 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2022-03-07 04:13:09 -05:00
|
|
|
|
|
|
|
describe '#activate_disabled_reason' do
|
|
|
|
subject { integration.activate_disabled_reason }
|
|
|
|
|
|
|
|
context 'when there is an existing issue tracker integration' do
|
|
|
|
let_it_be(:custom_tracker) { create(:custom_issue_tracker_integration, project: project) }
|
|
|
|
|
|
|
|
it { is_expected.to eq(trackers: [custom_tracker]) }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when there is no existing issue tracker integration' do
|
|
|
|
it { is_expected.to be(nil) }
|
|
|
|
end
|
|
|
|
end
|
2016-10-08 12:51:44 -04:00
|
|
|
end
|