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:
Diffstat (limited to 'spec/support/shared_examples/requests/clusters/integrations_controller_shared_examples.rb')
-rw-r--r--spec/support/shared_examples/requests/clusters/integrations_controller_shared_examples.rb46
1 files changed, 46 insertions, 0 deletions
diff --git a/spec/support/shared_examples/requests/clusters/integrations_controller_shared_examples.rb b/spec/support/shared_examples/requests/clusters/integrations_controller_shared_examples.rb
new file mode 100644
index 00000000000..490c7d12115
--- /dev/null
+++ b/spec/support/shared_examples/requests/clusters/integrations_controller_shared_examples.rb
@@ -0,0 +1,46 @@
+# frozen_string_literal: true
+
+RSpec.shared_examples '#create_or_update action' do
+ let(:params) do
+ { integration: { application_type: Clusters::Applications::Prometheus.application_name, enabled: true } }
+ end
+
+ let(:path) { raise NotImplementedError }
+ let(:redirect_path) { raise NotImplementedError }
+
+ describe 'authorization' do
+ subject do
+ post path, params: params
+ end
+
+ it_behaves_like 'a secure endpoint'
+ end
+
+ describe 'functionality' do
+ before do
+ sign_in(user)
+ end
+
+ it 'redirects on success' do
+ post path, params: params
+
+ expect(response).to have_gitlab_http_status(:redirect)
+ expect(response).to redirect_to(redirect_path)
+ expect(flash[:notice]).to be_present
+ end
+
+ it 'redirects on error' do
+ error = ServiceResponse.error(message: 'failed')
+
+ expect_next_instance_of(Clusters::Integrations::CreateService) do |service|
+ expect(service).to receive(:execute).and_return(error)
+ end
+
+ post path, params: params
+
+ expect(response).to have_gitlab_http_status(:redirect)
+ expect(response).to redirect_to(redirect_path)
+ expect(flash[:alert]).to eq(error.message)
+ end
+ end
+end