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>2022-12-20 17:22:11 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-12-20 17:22:11 +0300
commit0c872e02b2c822e3397515ec324051ff540f0cd5 (patch)
treece2fb6ce7030e4dad0f4118d21ab6453e5938cdd /spec/controllers/groups
parentf7e05a6853b12f02911494c4b3fe53d9540d74fc (diff)
Add latest changes from gitlab-org/gitlab@15-7-stable-eev15.7.0-rc42
Diffstat (limited to 'spec/controllers/groups')
-rw-r--r--spec/controllers/groups/application_controller_spec.rb45
-rw-r--r--spec/controllers/groups/dependency_proxy_for_containers_controller_spec.rb8
-rw-r--r--spec/controllers/groups/labels_controller_spec.rb2
-rw-r--r--spec/controllers/groups/registry/repositories_controller_spec.rb2
-rw-r--r--spec/controllers/groups/runners_controller_spec.rb2
-rw-r--r--spec/controllers/groups/settings/repository_controller_spec.rb2
6 files changed, 53 insertions, 8 deletions
diff --git a/spec/controllers/groups/application_controller_spec.rb b/spec/controllers/groups/application_controller_spec.rb
new file mode 100644
index 00000000000..46908fdb26a
--- /dev/null
+++ b/spec/controllers/groups/application_controller_spec.rb
@@ -0,0 +1,45 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Groups::ApplicationController do
+ let_it_be(:user) { create(:user) }
+ let_it_be(:group) { create(:group) }
+
+ describe '#respond_to_missing?' do
+ it 'returns true if the method matches the name structure' do
+ expect(controller.respond_to?(:authorize_read_usage_quotas!)).to eq(true)
+ end
+
+ it 'returns false if the method does not match the name structure' do
+ expect(controller.respond_to?(:does_not_exist)).to eq(false)
+ end
+ end
+
+ describe '#method_missing' do
+ controller do
+ before_action :authorize_read_usage_quotas!
+
+ def index
+ head :ok
+ end
+ end
+
+ it 'calls authorize_action! with the policy and renders not_found when user not authorized' do
+ group.add_maintainer(user)
+ sign_in(user)
+ get :index, params: { group_id: group.to_param }
+
+ expect(response).to have_gitlab_http_status(:not_found)
+ expect(response.headers['X-GitLab-Custom-Error']).to eq '1'
+ end
+
+ it 'calls authorize_action! with the policy and renders OK when user is authorized' do
+ group.add_owner(user)
+ sign_in(user)
+ get :index, params: { group_id: group.to_param }
+
+ expect(response).to have_gitlab_http_status(:ok)
+ end
+ end
+end
diff --git a/spec/controllers/groups/dependency_proxy_for_containers_controller_spec.rb b/spec/controllers/groups/dependency_proxy_for_containers_controller_spec.rb
index 5b4b00106cb..f1ca9e11a1a 100644
--- a/spec/controllers/groups/dependency_proxy_for_containers_controller_spec.rb
+++ b/spec/controllers/groups/dependency_proxy_for_containers_controller_spec.rb
@@ -233,7 +233,7 @@ RSpec.describe Groups::DependencyProxyForContainersController do
end
it_behaves_like 'a successful manifest pull'
- it_behaves_like 'a package tracking event', described_class.name, 'pull_manifest'
+ it_behaves_like 'a package tracking event', described_class.name, 'pull_manifest', false
context 'with workhorse response' do
let(:pull_response) { { status: :success, manifest: nil, from_cache: false } }
@@ -303,7 +303,7 @@ RSpec.describe Groups::DependencyProxyForContainersController do
end
it_behaves_like 'a successful blob pull'
- it_behaves_like 'a package tracking event', described_class.name, 'pull_blob_from_cache'
+ it_behaves_like 'a package tracking event', described_class.name, 'pull_blob_from_cache', false
context 'when cache entry does not exist' do
let(:blob_sha) { 'a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4' }
@@ -387,7 +387,7 @@ RSpec.describe Groups::DependencyProxyForContainersController do
group.add_guest(user)
end
- it_behaves_like 'a package tracking event', described_class.name, 'pull_blob'
+ it_behaves_like 'a package tracking event', described_class.name, 'pull_blob', false
it 'creates a blob' do
expect { subject }.to change { group.dependency_proxy_blobs.count }.by(1)
@@ -445,7 +445,7 @@ RSpec.describe Groups::DependencyProxyForContainersController do
group.add_guest(user)
end
- it_behaves_like 'a package tracking event', described_class.name, 'pull_manifest'
+ it_behaves_like 'a package tracking event', described_class.name, 'pull_manifest', false
it_behaves_like 'with invalid path'
context 'with no existing manifest' do
diff --git a/spec/controllers/groups/labels_controller_spec.rb b/spec/controllers/groups/labels_controller_spec.rb
index 37db26096d3..0521c5e02a8 100644
--- a/spec/controllers/groups/labels_controller_spec.rb
+++ b/spec/controllers/groups/labels_controller_spec.rb
@@ -54,7 +54,7 @@ RSpec.describe Groups::LabelsController do
get :index, params: { group_id: group.to_param }
end
- it 'avoids N+1 queries' do
+ it 'avoids N+1 queries', :use_clean_rails_redis_caching do
control = ActiveRecord::QueryRecorder.new(skip_cached: false) { get :index, params: { group_id: group.to_param } }
create_list(:group_label, 3, group: group)
diff --git a/spec/controllers/groups/registry/repositories_controller_spec.rb b/spec/controllers/groups/registry/repositories_controller_spec.rb
index 62c15201a95..efdafcd2657 100644
--- a/spec/controllers/groups/registry/repositories_controller_spec.rb
+++ b/spec/controllers/groups/registry/repositories_controller_spec.rb
@@ -114,7 +114,7 @@ RSpec.describe Groups::Registry::RepositoriesController do
it_behaves_like 'with name parameter'
- it_behaves_like 'a package tracking event', described_class.name, 'list_repositories'
+ it_behaves_like 'a package tracking event', described_class.name, 'list_repositories', false
context 'with project in subgroup' do
let_it_be(:test_group) { create(:group, parent: group) }
diff --git a/spec/controllers/groups/runners_controller_spec.rb b/spec/controllers/groups/runners_controller_spec.rb
index 2add3cd3b18..93c1571bb6c 100644
--- a/spec/controllers/groups/runners_controller_spec.rb
+++ b/spec/controllers/groups/runners_controller_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Groups::RunnersController do
+RSpec.describe Groups::RunnersController, feature_category: :runner_fleet do
let_it_be(:user) { create(:user) }
let_it_be(:group) { create(:group) }
let_it_be(:project) { create(:project, group: group) }
diff --git a/spec/controllers/groups/settings/repository_controller_spec.rb b/spec/controllers/groups/settings/repository_controller_spec.rb
index 73a205069f5..ab1bb134b03 100644
--- a/spec/controllers/groups/settings/repository_controller_spec.rb
+++ b/spec/controllers/groups/settings/repository_controller_spec.rb
@@ -16,7 +16,7 @@ RSpec.describe Groups::Settings::RepositoryController do
let(:good_deploy_token_params) do
{
name: 'name',
- expires_at: 1.day.from_now.to_s,
+ expires_at: 1.day.from_now.to_datetime.to_s,
username: 'deployer',
read_repository: '1',
deploy_token_type: DeployToken.deploy_token_types[:group_type]