2016-10-08 16:51:44 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-07-10 14:24:02 +00:00
|
|
|
describe IssueTrackerService do
|
2016-10-08 16:51:44 +00:00
|
|
|
describe 'Validations' do
|
2017-08-02 19:55:11 +00:00
|
|
|
let(:project) { create :project }
|
2016-10-08 16:51:44 +00:00
|
|
|
|
|
|
|
describe 'only one issue tracker per project' do
|
|
|
|
let(:service) { RedmineService.new(project: project, active: true) }
|
|
|
|
|
|
|
|
before do
|
2017-04-25 15:48:12 +00:00
|
|
|
create(:custom_issue_tracker_service, project: project)
|
2016-10-08 16:51:44 +00: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
|