diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-20 02:18:09 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-20 02:18:09 +0300 |
commit | 6ed4ec3e0b1340f96b7c043ef51d1b33bbe85fde (patch) | |
tree | dc4d20fe6064752c0bd323187252c77e0a89144b /spec/support/shared_examples/controllers | |
parent | 9868dae7fc0655bd7ce4a6887d4e6d487690eeed (diff) |
Add latest changes from gitlab-org/gitlab@15-4-stable-eev15.4.0-rc42
Diffstat (limited to 'spec/support/shared_examples/controllers')
5 files changed, 63 insertions, 17 deletions
diff --git a/spec/support/shared_examples/controllers/concerns/web_hooks/integrations_hook_log_actions_shared_examples.rb b/spec/support/shared_examples/controllers/concerns/web_hooks/integrations_hook_log_actions_shared_examples.rb new file mode 100644 index 00000000000..62c9c3508a8 --- /dev/null +++ b/spec/support/shared_examples/controllers/concerns/web_hooks/integrations_hook_log_actions_shared_examples.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +RSpec.shared_examples WebHooks::HookLogActions do + let!(:show_path) { web_hook_log.present.details_path } + let!(:retry_path) { web_hook_log.present.retry_path } + + before do + sign_in(user) + end + + describe 'GET #show' do + it 'renders a 200 if the hook exists' do + get show_path + + expect(response).to have_gitlab_http_status(:ok) + expect(response).to render_template('hook_logs/show') + end + + it 'renders a 404 if the hook does not exist' do + web_hook.destroy! + get show_path + + expect(response).to have_gitlab_http_status(:not_found) + end + end + + describe 'POST #retry' do + it 'executes the hook and redirects to the service form' do + stub_request(:post, web_hook.url) + + expect_next_found_instance_of(web_hook.class) do |hook| + expect(hook).to receive(:execute).and_call_original + end + + post retry_path + + expect(response).to redirect_to(edit_hook_path) + end + + it 'renders a 404 if the hook does not exist' do + web_hook.destroy! + post retry_path + + expect(response).to have_gitlab_http_status(:not_found) + end + end +end diff --git a/spec/support/shared_examples/controllers/error_tracking_shared_examples.rb b/spec/support/shared_examples/controllers/error_tracking_shared_examples.rb index 08e5efcf63c..1bf2f158504 100644 --- a/spec/support/shared_examples/controllers/error_tracking_shared_examples.rb +++ b/spec/support/shared_examples/controllers/error_tracking_shared_examples.rb @@ -3,5 +3,5 @@ RSpec.shared_examples 'sets the polling header' do subject { response.headers[Gitlab::PollingInterval::HEADER_NAME] } - it { is_expected.to eq '1000'} + it { is_expected.to eq '1000' } end diff --git a/spec/support/shared_examples/controllers/githubish_import_controller_shared_examples.rb b/spec/support/shared_examples/controllers/githubish_import_controller_shared_examples.rb index 5faf462c23c..bbbe93a644f 100644 --- a/spec/support/shared_examples/controllers/githubish_import_controller_shared_examples.rb +++ b/spec/support/shared_examples/controllers/githubish_import_controller_shared_examples.rb @@ -241,12 +241,11 @@ RSpec.shared_examples 'a GitHub-ish import controller: POST create' do let(:provider_user) { double('user', login: provider_username) } let(:project) { create(:project, import_type: provider, import_status: :finished, import_source: "#{provider_username}/vim") } let(:provider_repo) do - double( - 'provider', + { name: 'vim', full_name: "#{provider_username}/vim", owner: double('owner', login: provider_username) - ) + } end before do @@ -256,7 +255,7 @@ RSpec.shared_examples 'a GitHub-ish import controller: POST create' do it 'returns 200 response when the project is imported successfully' do allow(Gitlab::LegacyGithubImport::ProjectCreator) - .to receive(:new).with(provider_repo, provider_repo.name, user.namespace, user, type: provider, **access_params) + .to receive(:new).with(provider_repo, provider_repo[:name], user.namespace, user, type: provider, **access_params) .and_return(double(execute: project)) post :create, format: :json @@ -270,7 +269,7 @@ RSpec.shared_examples 'a GitHub-ish import controller: POST create' do project.errors.add(:path, 'is old') allow(Gitlab::LegacyGithubImport::ProjectCreator) - .to receive(:new).with(provider_repo, provider_repo.name, user.namespace, user, type: provider, **access_params) + .to receive(:new).with(provider_repo, provider_repo[:name], user.namespace, user, type: provider, **access_params) .and_return(double(execute: project)) post :create, format: :json @@ -281,7 +280,7 @@ RSpec.shared_examples 'a GitHub-ish import controller: POST create' do it "touches the etag cache store" do allow(Gitlab::LegacyGithubImport::ProjectCreator) - .to receive(:new).with(provider_repo, provider_repo.name, user.namespace, user, type: provider, **access_params) + .to receive(:new).with(provider_repo, provider_repo[:name], user.namespace, user, type: provider, **access_params) .and_return(double(execute: project)) expect_next_instance_of(Gitlab::EtagCaching::Store) do |store| expect(store).to receive(:touch) { "realtime_changes_import_#{provider}_path" } @@ -294,7 +293,7 @@ RSpec.shared_examples 'a GitHub-ish import controller: POST create' do context "when the provider user and GitLab user's usernames match" do it "takes the current user's namespace" do expect(Gitlab::LegacyGithubImport::ProjectCreator) - .to receive(:new).with(provider_repo, provider_repo.name, user.namespace, user, type: provider, **access_params) + .to receive(:new).with(provider_repo, provider_repo[:name], user.namespace, user, type: provider, **access_params) .and_return(double(execute: project)) post :create, format: :json @@ -306,7 +305,7 @@ RSpec.shared_examples 'a GitHub-ish import controller: POST create' do it "takes the current user's namespace" do expect(Gitlab::LegacyGithubImport::ProjectCreator) - .to receive(:new).with(provider_repo, provider_repo.name, user.namespace, user, type: provider, **access_params) + .to receive(:new).with(provider_repo, provider_repo[:name], user.namespace, user, type: provider, **access_params) .and_return(double(execute: project)) post :create, format: :json @@ -331,7 +330,7 @@ RSpec.shared_examples 'a GitHub-ish import controller: POST create' do it "takes the existing namespace" do expect(Gitlab::LegacyGithubImport::ProjectCreator) - .to receive(:new).with(provider_repo, provider_repo.name, existing_namespace, user, type: provider, **access_params) + .to receive(:new).with(provider_repo, provider_repo[:name], existing_namespace, user, type: provider, **access_params) .and_return(double(execute: project)) post :create, format: :json @@ -343,7 +342,7 @@ RSpec.shared_examples 'a GitHub-ish import controller: POST create' do create(:user, username: provider_username) expect(Gitlab::LegacyGithubImport::ProjectCreator) - .to receive(:new).with(provider_repo, provider_repo.name, user.namespace, user, type: provider, **access_params) + .to receive(:new).with(provider_repo, provider_repo[:name], user.namespace, user, type: provider, **access_params) .and_return(double(execute: project)) post :create, format: :json @@ -357,15 +356,15 @@ RSpec.shared_examples 'a GitHub-ish import controller: POST create' do expect(Gitlab::LegacyGithubImport::ProjectCreator) .to receive(:new).and_return(double(execute: project)) - expect { post :create, params: { target_namespace: provider_repo.name }, format: :json }.to change(Namespace, :count).by(1) + expect { post :create, params: { target_namespace: provider_repo[:name] }, format: :json }.to change(Namespace, :count).by(1) end it "takes the new namespace" do expect(Gitlab::LegacyGithubImport::ProjectCreator) - .to receive(:new).with(provider_repo, provider_repo.name, an_instance_of(Group), user, type: provider, **access_params) + .to receive(:new).with(provider_repo, provider_repo[:name], an_instance_of(Group), user, type: provider, **access_params) .and_return(double(execute: project)) - post :create, params: { target_namespace: provider_repo.name }, format: :json + post :create, params: { target_namespace: provider_repo[:name] }, format: :json end end @@ -383,7 +382,7 @@ RSpec.shared_examples 'a GitHub-ish import controller: POST create' do it "takes the current user's namespace" do expect(Gitlab::LegacyGithubImport::ProjectCreator) - .to receive(:new).with(provider_repo, provider_repo.name, user.namespace, user, type: provider, **access_params) + .to receive(:new).with(provider_repo, provider_repo[:name], user.namespace, user, type: provider, **access_params) .and_return(double(execute: project)) post :create, format: :json diff --git a/spec/support/shared_examples/controllers/snippets_sort_order_shared_examples.rb b/spec/support/shared_examples/controllers/snippets_sort_order_shared_examples.rb index aa4d78b23f4..112b9cbb204 100644 --- a/spec/support/shared_examples/controllers/snippets_sort_order_shared_examples.rb +++ b/spec/support/shared_examples/controllers/snippets_sort_order_shared_examples.rb @@ -3,7 +3,7 @@ RSpec.shared_examples 'snippets sort order' do let(:params) { {} } let(:sort_argument) { {} } - let(:sort_params) { params.merge(sort_argument)} + let(:sort_params) { params.merge(sort_argument) } before do sign_in(user) diff --git a/spec/support/shared_examples/controllers/snowplow_event_tracking_examples.rb b/spec/support/shared_examples/controllers/snowplow_event_tracking_examples.rb index 2e691d1b36f..4af3c0cc6cc 100644 --- a/spec/support/shared_examples/controllers/snowplow_event_tracking_examples.rb +++ b/spec/support/shared_examples/controllers/snowplow_event_tracking_examples.rb @@ -13,7 +13,7 @@ # - label # - **extra -shared_examples 'Snowplow event tracking' do |overrides: {}| +RSpec.shared_examples 'Snowplow event tracking' do |overrides: {}| let(:extra) { {} } it 'is not emitted if FF is disabled' do |