Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-10-01 15:05:59 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-10-01 15:05:59 +0300
commit9e27f0d920cc3891fa7644c5cc0bc280c519fb20 (patch)
tree9784dd99270f2009159b19077412bf83d13123a4 /spec/models/service_spec.rb
parent1bab0ba591263cd739af2d2c7c3f1b03678a59b6 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/service_spec.rb')
-rw-r--r--spec/models/service_spec.rb62
1 files changed, 60 insertions, 2 deletions
diff --git a/spec/models/service_spec.rb b/spec/models/service_spec.rb
index d96e1398677..4049ddcff7f 100644
--- a/spec/models/service_spec.rb
+++ b/spec/models/service_spec.rb
@@ -78,10 +78,11 @@ describe Service do
end
describe "Template" do
+ let(:project) { create(:project) }
+
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 = build(:prometheus_service, template: true, active: true, properties: {})
template.save(validate: false)
@@ -91,6 +92,64 @@ describe Service do
expect(service.active).to be false
end
end
+
+ describe 'build issue tracker from a template' do
+ let(:title) { 'custom title' }
+ let(:description) { 'custom description' }
+ let(:url) { 'http://jira.example.com' }
+ let(:api_url) { 'http://api-jira.example.com' }
+ let(:username) { 'jira-username' }
+ let(:password) { 'jira-password' }
+ let(:data_params) do
+ {
+ url: url, api_url: api_url,
+ username: username, password: password
+ }
+ end
+
+ shared_examples 'service creation from a template' do
+ it 'creates a correct service' do
+ service = described_class.build_from_template(project.id, template)
+
+ expect(service).to be_active
+ expect(service.title).to eq(title)
+ expect(service.description).to eq(description)
+ expect(service.url).to eq(url)
+ expect(service.api_url).to eq(api_url)
+ expect(service.username).to eq(username)
+ expect(service.password).to eq(password)
+ end
+ end
+
+ # this will be removed as part of https://gitlab.com/gitlab-org/gitlab-foss/issues/63084
+ context 'when data are stored in properties' do
+ let(:properties) { data_params.merge(title: title, description: description) }
+ let!(:template) do
+ create(:jira_service, :without_properties_callback, template: true, properties: properties.merge(additional: 'something'))
+ end
+
+ it_behaves_like 'service creation from a template'
+ end
+
+ context 'when data are stored in separated fields' do
+ let(:template) do
+ create(:jira_service, data_params.merge(properties: {}, title: title, description: description, template: true))
+ end
+
+ it_behaves_like 'service creation from a template'
+ end
+
+ context 'when data are stored in both properties and separated fields' do
+ let(:properties) { data_params.merge(title: title, description: description) }
+ let(:template) do
+ create(:jira_service, :without_properties_callback, active: true, template: true, properties: properties).tap do |service|
+ create(:jira_tracker_data, data_params.merge(service: service))
+ end
+ end
+
+ it_behaves_like 'service creation from a template'
+ end
+ end
end
describe "for pushover service" do
@@ -104,7 +163,6 @@ describe Service do
api_key: '123456789'
})
end
- let(:project) { create(:project) }
describe 'is prefilled for projects pushover service' do
it "has all fields prefilled" do