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>2020-03-25 12:08:11 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-25 12:08:11 +0300
commit5064bf8c5647d4c4430cbb4d097cf1592416de29 (patch)
treed051bf2abe2cc7061b3a7facb6669a56ccb9cf54 /spec/services/projects
parent9c83aadd2604e7e6cb1f84683f951e6b12872618 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services/projects')
-rw-r--r--spec/services/projects/operations/update_service_spec.rb81
1 files changed, 81 insertions, 0 deletions
diff --git a/spec/services/projects/operations/update_service_spec.rb b/spec/services/projects/operations/update_service_spec.rb
index de028ecb693..99a9fdd4184 100644
--- a/spec/services/projects/operations/update_service_spec.rb
+++ b/spec/services/projects/operations/update_service_spec.rb
@@ -11,6 +11,87 @@ describe Projects::Operations::UpdateService do
subject { described_class.new(project, user, params) }
describe '#execute' do
+ context 'alerting setting' do
+ before do
+ project.add_maintainer(user)
+ end
+
+ shared_examples 'no operation' do
+ it 'does nothing' do
+ expect(result[:status]).to eq(:success)
+ expect(project.reload.alerting_setting).to be_nil
+ end
+ end
+
+ context 'with valid params' do
+ let(:params) { { alerting_setting_attributes: alerting_params } }
+
+ shared_examples 'setting creation' do
+ it 'creates a setting' do
+ expect(project.alerting_setting).to be_nil
+
+ expect(result[:status]).to eq(:success)
+ expect(project.reload.alerting_setting).not_to be_nil
+ end
+ end
+
+ context 'when regenerate_token is not set' do
+ let(:alerting_params) { { token: 'some token' } }
+
+ context 'with an existing setting' do
+ let!(:alerting_setting) do
+ create(:project_alerting_setting, project: project)
+ end
+
+ it 'ignores provided token' do
+ expect(result[:status]).to eq(:success)
+ expect(project.reload.alerting_setting.token)
+ .to eq(alerting_setting.token)
+ end
+ end
+
+ context 'without an existing setting' do
+ it_behaves_like 'setting creation'
+ end
+ end
+
+ context 'when regenerate_token is set' do
+ let(:alerting_params) { { regenerate_token: true } }
+
+ context 'with an existing setting' do
+ let(:token) { 'some token' }
+
+ let!(:alerting_setting) do
+ create(:project_alerting_setting, project: project, token: token)
+ end
+
+ it 'regenerates token' do
+ expect(result[:status]).to eq(:success)
+ expect(project.reload.alerting_setting.token).not_to eq(token)
+ end
+ end
+
+ context 'without an existing setting' do
+ it_behaves_like 'setting creation'
+
+ context 'with insufficient permissions' do
+ before do
+ project.add_reporter(user)
+ end
+
+ it_behaves_like 'no operation'
+ end
+ end
+ end
+ end
+
+ context 'with empty params' do
+ let(:params) { {} }
+
+ it_behaves_like 'no operation'
+ end
+ end
+
context 'metrics dashboard setting' do
let(:params) do
{