summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorTiago Botelho <tiagonbotelho@hotmail.com>2018-03-27 16:33:29 +0100
committerTiago Botelho <tiagonbotelho@hotmail.com>2018-03-28 16:28:55 +0100
commit7fd9e39d885c7d7520ba0a7e45e8c58847f1c11d (patch)
tree9de4174e5fb03ecb2f324ef2b2c8e622cc51656a /spec
parentbf4a3af06ac4cb7f321267bf395022420e0c14a2 (diff)
downloadgitlab-ce-7fd9e39d885c7d7520ba0a7e45e8c58847f1c11d.tar.gz
When a Service templates are invalid newly created projects will have them inactive
Diffstat (limited to 'spec')
-rw-r--r--spec/models/service_spec.rb15
-rw-r--r--spec/services/projects/create_service_spec.rb15
2 files changed, 23 insertions, 7 deletions
diff --git a/spec/models/service_spec.rb b/spec/models/service_spec.rb
index 79f25dc4360..83ed3b203e6 100644
--- a/spec/models/service_spec.rb
+++ b/spec/models/service_spec.rb
@@ -58,6 +58,21 @@ describe Service do
end
describe "Template" do
+ describe '.build_from_template' do
+ context 'when template is invalid' do
+ it 'sets service template to inactive when template is invalid' do
+ project = create(:project)
+ template = JiraService.new(template: true, active: true)
+ template.save(validate: false)
+
+ service = described_class.build_from_template(project.id, template)
+
+ expect(service).to be_valid
+ expect(service.active).to be false
+ end
+ end
+ end
+
describe "for pushover service" do
let!(:service_template) do
PushoverService.create(
diff --git a/spec/services/projects/create_service_spec.rb b/spec/services/projects/create_service_spec.rb
index fbaa4f7aebc..3a9e0ace517 100644
--- a/spec/services/projects/create_service_spec.rb
+++ b/spec/services/projects/create_service_spec.rb
@@ -71,14 +71,14 @@ describe Projects::CreateService, '#execute' do
expect(create_project(user, opts)).to eq(nil)
end
- it 'handles invalid service' do
+ it 'sets invalid service as inactive' do
create(:service, type: 'JiraService', project: nil, template: true, active: true)
project = create_project(user, opts)
+ service = project.services.first
- expect(project).not_to be_persisted
- expect(project.errors.full_messages_for(:base).first).to match(/Unable to save project. Error: Unable to save JiraService/)
- expect(project.services.count).to eq 0
+ expect(project).to be_persisted
+ expect(service.active).to be false
end
end
@@ -242,14 +242,15 @@ describe Projects::CreateService, '#execute' do
end
context 'when a bad service template is created' do
- it 'reports an error in the imported project' do
+ it 'sets service to be inactive' do
opts[:import_url] = 'http://www.gitlab.com/gitlab-org/gitlab-ce'
create(:service, type: 'DroneCiService', project: nil, template: true, active: true)
project = create_project(user, opts)
+ service = project.services.first
- expect(project.errors.full_messages_for(:base).first).to match(/Unable to save project. Error: Unable to save DroneCiService/)
- expect(project.services.count).to eq 0
+ expect(project).to be_persisted
+ expect(service.active).to be false
end
end