diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-20 16:37:47 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-20 16:37:47 +0300 |
commit | aee0a117a889461ce8ced6fcf73207fe017f1d99 (patch) | |
tree | 891d9ef189227a8445d83f35c1b0fc99573f4380 /spec/controllers/groups | |
parent | 8d46af3258650d305f53b819eabf7ab18d22f59e (diff) |
Add latest changes from gitlab-org/gitlab@14-6-stable-eev14.6.0-rc42
Diffstat (limited to 'spec/controllers/groups')
3 files changed, 23 insertions, 48 deletions
diff --git a/spec/controllers/groups/dependency_proxies_controller_spec.rb b/spec/controllers/groups/dependency_proxies_controller_spec.rb index 35bd7d47aed..67847936a80 100644 --- a/spec/controllers/groups/dependency_proxies_controller_spec.rb +++ b/spec/controllers/groups/dependency_proxies_controller_spec.rb @@ -3,8 +3,9 @@ require 'spec_helper' RSpec.describe Groups::DependencyProxiesController do - let(:group) { create(:group) } - let(:user) { create(:user) } + let_it_be(:group) { create(:group) } + let_it_be_with_reload(:dependency_proxy_group_setting) { create(:dependency_proxy_group_setting, group: group) } + let_it_be(:user) { create(:user) } before do group.add_owner(user) @@ -12,62 +13,37 @@ RSpec.describe Groups::DependencyProxiesController do end describe 'GET #show' do - context 'feature enabled' do - before do - enable_dependency_proxy - end - - it 'returns 200 and renders the view' do - get :show, params: { group_id: group.to_param } + subject { get :show, params: { group_id: group.to_param } } - expect(response).to have_gitlab_http_status(:ok) - expect(response).to render_template('groups/dependency_proxies/show') - end + before do + stub_config(dependency_proxy: { enabled: config_enabled }) end - it 'returns 404 when feature is disabled' do - disable_dependency_proxy + context 'with global config enabled' do + let(:config_enabled) { true } - get :show, params: { group_id: group.to_param } + context 'with the setting enabled' do + it 'returns 200 and renders the view' do + subject - expect(response).to have_gitlab_http_status(:not_found) - end - end - - describe 'PUT #update' do - context 'feature enabled' do - before do - enable_dependency_proxy + expect(response).to have_gitlab_http_status(:ok) + expect(response).to render_template('groups/dependency_proxies/show') + end end - it 'redirects back to show page' do - put :update, params: update_params + context 'with the setting disabled' do + before do + dependency_proxy_group_setting.update!(enabled: false) + end - expect(response).to have_gitlab_http_status(:found) + it_behaves_like 'returning response status', :not_found end end - it 'returns 404 when feature is disabled' do - put :update, params: update_params + context 'with global config disabled' do + let(:config_enabled) { false } - expect(response).to have_gitlab_http_status(:not_found) + it_behaves_like 'returning response status', :not_found end - - def update_params - { - group_id: group.to_param, - dependency_proxy_group_setting: { enabled: true } - } - end - end - - def enable_dependency_proxy - stub_config(dependency_proxy: { enabled: true }) - - group.create_dependency_proxy_setting!(enabled: true) - end - - def disable_dependency_proxy - group.create_dependency_proxy_setting!(enabled: false) 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 b22307578ab..0f262d93d4c 100644 --- a/spec/controllers/groups/dependency_proxy_for_containers_controller_spec.rb +++ b/spec/controllers/groups/dependency_proxy_for_containers_controller_spec.rb @@ -170,7 +170,7 @@ RSpec.describe Groups::DependencyProxyForContainersController do let(:pull_response) { { status: :success, manifest: manifest, from_cache: false } } before do - allow_next_instance_of(DependencyProxy::FindOrCreateManifestService) do |instance| + allow_next_instance_of(DependencyProxy::FindCachedManifestService) do |instance| allow(instance).to receive(:execute).and_return(pull_response) end end diff --git a/spec/controllers/groups/group_members_controller_spec.rb b/spec/controllers/groups/group_members_controller_spec.rb index 4b17326de09..04a9b9f5250 100644 --- a/spec/controllers/groups/group_members_controller_spec.rb +++ b/spec/controllers/groups/group_members_controller_spec.rb @@ -293,7 +293,6 @@ RSpec.describe Groups::GroupMembersController do context 'when `expires_at` is set' do it 'returns correct json response' do expect(json_response).to eq({ - "expires_in" => "about 1 month", "expires_soon" => false, "expires_at_formatted" => expiry_date.to_time.in_time_zone.to_s(:medium) }) |