2019-07-07 11:18:12 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
RSpec.describe Integrations::BaseIssueTracker do
|
2022-05-07 20:08:51 +05:30
|
|
|
let(:integration) { Integrations::Redmine.new(project: project, active: true, issue_tracker_data: build(:issue_tracker_data)) }
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2022-05-07 20:08:51 +05:30
|
|
|
let_it_be_with_refind(:project) { create :project }
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2022-05-07 20:08:51 +05:30
|
|
|
describe 'Validations' do
|
|
|
|
describe 'only one issue tracker per project' do
|
2017-08-17 22:00:37 +05:30
|
|
|
before do
|
2021-09-04 01:27:46 +05:30
|
|
|
create(:custom_issue_tracker_integration, project: project)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2021-09-30 23:02:18 +05:30
|
|
|
context 'when integration is changed manually by user' do
|
2017-08-17 22:00:37 +05:30
|
|
|
it 'executes the validation' do
|
2021-09-30 23:02:18 +05:30
|
|
|
valid = integration.valid?(:manual_change)
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
expect(valid).to be_falsey
|
2021-09-30 23:02:18 +05:30
|
|
|
expect(integration.errors[:base]).to include(
|
2017-08-17 22:00:37 +05:30
|
|
|
'Another issue tracker is already in use. Only one issue tracker service can be active at a time'
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-09-30 23:02:18 +05:30
|
|
|
context 'when integration is changed internally' do
|
2017-08-17 22:00:37 +05:30
|
|
|
it 'does not execute the validation' do
|
2021-09-30 23:02:18 +05:30
|
|
|
expect(integration.valid?).to be_truthy
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2022-05-07 20:08:51 +05:30
|
|
|
|
|
|
|
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
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|