diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-06 12:08:38 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-06 12:08:38 +0000 |
commit | 6ab9cdec264a9caf7e4eb5519fcae5ac65a18b15 (patch) | |
tree | 28afca02f01c1b9d22a5e4227521a575fae57bea /spec/services/projects | |
parent | 497d517e130ac88cbdee69c4c9e88938e164fc52 (diff) | |
download | gitlab-ce-6ab9cdec264a9caf7e4eb5519fcae5ac65a18b15.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services/projects')
-rw-r--r-- | spec/services/projects/operations/update_service_spec.rb | 92 |
1 files changed, 90 insertions, 2 deletions
diff --git a/spec/services/projects/operations/update_service_spec.rb b/spec/services/projects/operations/update_service_spec.rb index 8a538bc67ed..018bfa8ef61 100644 --- a/spec/services/projects/operations/update_service_spec.rb +++ b/spec/services/projects/operations/update_service_spec.rb @@ -3,8 +3,8 @@ require 'spec_helper' RSpec.describe Projects::Operations::UpdateService do + let_it_be_with_refind(:project) { create(:project) } let_it_be(:user) { create(:user) } - let_it_be(:project, refind: true) { create(:project) } let(:result) { subject.execute } @@ -12,7 +12,7 @@ RSpec.describe Projects::Operations::UpdateService do describe '#execute' do context 'alerting setting' do - before do + before_all do project.add_maintainer(user) end @@ -430,5 +430,93 @@ RSpec.describe Projects::Operations::UpdateService do end end end + + context 'tracing setting' do + context 'with valid params' do + let(:params) do + { + tracing_setting_attributes: { + external_url: 'http://some-url.com' + } + } + end + + context 'with an existing setting' do + before do + create(:project_tracing_setting, project: project) + end + + shared_examples 'setting deletion' do + let!(:original_params) { params.deep_dup } + + it 'deletes the setting' do + expect(result[:status]).to eq(:success) + expect(project.reload.tracing_setting).to be_nil + end + + it 'does not modify original params' do + subject.execute + + expect(params).to eq(original_params) + end + end + + it 'updates the setting' do + expect(project.tracing_setting).not_to be_nil + + expect(result[:status]).to eq(:success) + expect(project.reload.tracing_setting.external_url) + .to eq('http://some-url.com') + end + + context 'with missing external_url' do + before do + params[:tracing_setting_attributes].delete(:external_url) + end + + it_behaves_like 'setting deletion' + end + + context 'with empty external_url' do + before do + params[:tracing_setting_attributes][:external_url] = '' + end + + it_behaves_like 'setting deletion' + end + + context 'with blank external_url' do + before do + params[:tracing_setting_attributes][:external_url] = ' ' + end + + it_behaves_like 'setting deletion' + end + end + + context 'without an existing setting' do + it 'creates a setting' do + expect(project.tracing_setting).to be_nil + + expect(result[:status]).to eq(:success) + expect(project.reload.tracing_setting.external_url) + .to eq('http://some-url.com') + end + end + end + + context 'with empty params' do + let(:params) { {} } + + let!(:tracing_setting) do + create(:project_tracing_setting, project: project) + end + + it 'does nothing' do + expect(result[:status]).to eq(:success) + expect(project.reload.tracing_setting).to eq(tracing_setting) + end + end + end end end |