summaryrefslogtreecommitdiff
path: root/spec/services/projects/operations/update_service_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/services/projects/operations/update_service_spec.rb')
-rw-r--r--spec/services/projects/operations/update_service_spec.rb56
1 files changed, 56 insertions, 0 deletions
diff --git a/spec/services/projects/operations/update_service_spec.rb b/spec/services/projects/operations/update_service_spec.rb
index 7e765659b9d..b2f9fd6df79 100644
--- a/spec/services/projects/operations/update_service_spec.rb
+++ b/spec/services/projects/operations/update_service_spec.rb
@@ -170,5 +170,61 @@ describe Projects::Operations::UpdateService do
expect(project.reload.name).to eq(original_name)
end
end
+
+ context 'grafana integration' do
+ let(:params) do
+ {
+ grafana_integration_attributes: {
+ grafana_url: 'http://new.grafana.com',
+ token: 'VerySecureToken='
+ }
+ }
+ end
+
+ context 'without existing grafana integration' do
+ it 'creates an integration' do
+ expect(result[:status]).to eq(:success)
+
+ expected_attrs = params[:grafana_integration_attributes]
+ integration = project.reload.grafana_integration
+
+ expect(integration.grafana_url).to eq(expected_attrs[:grafana_url])
+ expect(integration.token).to eq(expected_attrs[:token])
+ end
+ end
+
+ context 'with an existing grafana integration' do
+ before do
+ create(:grafana_integration, project: project)
+ end
+
+ it 'updates the settings' do
+ expect(result[:status]).to eq(:success)
+
+ expected_attrs = params[:grafana_integration_attributes]
+ integration = project.reload.grafana_integration
+
+ expect(integration.grafana_url).to eq(expected_attrs[:grafana_url])
+ expect(integration.token).to eq(expected_attrs[:token])
+ end
+
+ context 'with all grafana attributes blank in params' do
+ let(:params) do
+ {
+ grafana_integration_attributes: {
+ grafana_url: '',
+ token: ''
+ }
+ }
+ end
+
+ it 'destroys the metrics_setting entry in DB' do
+ expect(result[:status]).to eq(:success)
+
+ expect(project.reload.grafana_integration).to be_nil
+ end
+ end
+ end
+ end
end
end