diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2017-03-10 15:25:24 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2017-03-10 15:25:24 +0000 |
commit | dc99f343afbb6e82e3639d3c33dbb103a844f083 (patch) | |
tree | 8442fc8eab8dcd1fbcbcca23f8db5177a9c87649 /spec | |
parent | 4d7ead9b210f866c8f223e3d7ef89347d9d305bb (diff) | |
parent | 6bc3edee11b91ce954f2dd3e9a6997f367f3003c (diff) | |
download | gitlab-ce-dc99f343afbb6e82e3639d3c33dbb103a844f083.tar.gz |
Merge branch 'adam-prevent-two-issue-trackers' into 'master'
Prevent more than one issue tracker to be active for the same project
Closes #22797
See merge request !9669
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/project_services/issue_tracker_service_spec.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/models/project_services/issue_tracker_service_spec.rb b/spec/models/project_services/issue_tracker_service_spec.rb new file mode 100644 index 00000000000..fbe6f344a98 --- /dev/null +++ b/spec/models/project_services/issue_tracker_service_spec.rb @@ -0,0 +1,32 @@ +require 'spec_helper' + +describe IssueTrackerService, models: true do + describe 'Validations' do + let(:project) { create :project } + + describe 'only one issue tracker per project' do + let(:service) { RedmineService.new(project: project, active: true) } + + before do + create(:service, project: project, active: true, category: 'issue_tracker') + 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 |