diff options
author | Luis Del Giudice <luis.dg19@gmail.com> | 2016-10-08 19:51:44 +0300 |
---|---|---|
committer | Adam Niedzielski <adamsunday@gmail.com> | 2017-03-10 17:14:00 +0300 |
commit | 6bc3edee11b91ce954f2dd3e9a6997f367f3003c (patch) | |
tree | 6c1c172bb270e03c9a163485d17c5a4494c129a7 /spec | |
parent | 81ad61113112c49704cfe24b8e47479976422e60 (diff) |
Prevent more than one issue tracker to be active for the same project
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 |