debian-mirror-gitlab/spec/models/integrations/base_issue_tracker_spec.rb

35 lines
1,021 B
Ruby
Raw Normal View History

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
2017-08-17 22:00:37 +05:30
describe 'Validations' do
let(:project) { create :project }
describe 'only one issue tracker per project' do
2021-09-04 01:27:46 +05:30
let(:service) { Integrations::Redmine.new(project: project, active: true, issue_tracker_data: build(:issue_tracker_data)) }
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
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