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
|
2016-10-08 12:51:44 -04:00
|
|
|
describe 'Validations' do
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:project) { create :project }
|
2016-10-08 12:51:44 -04:00
|
|
|
|
|
|
|
describe 'only one issue tracker per project' do
|
2021-05-20 05:10:30 -04:00
|
|
|
let(:service) { Integrations::Redmine.new(project: project, active: true, issue_tracker_data: build(:issue_tracker_data)) }
|
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
|
|
|
|
|
|
|
|
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
|