diff options
Diffstat (limited to 'spec/requests/groups')
6 files changed, 95 insertions, 13 deletions
diff --git a/spec/requests/groups/achievements_controller_spec.rb b/spec/requests/groups/achievements_controller_spec.rb new file mode 100644 index 00000000000..26ca0039984 --- /dev/null +++ b/spec/requests/groups/achievements_controller_spec.rb @@ -0,0 +1,78 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Groups::AchievementsController, feature_category: :user_profile do + let_it_be(:user) { create(:user) } + + shared_examples 'response with 404 status' do + it 'returns 404' do + subject + + expect(response).to have_gitlab_http_status(:not_found) + end + end + + shared_examples 'ok response with index template' do + it 'renders the index template' do + subject + + expect(response).to have_gitlab_http_status(:ok) + expect(response).to render_template(:index) + end + end + + shared_examples 'ok response with index template if authorized' do + context 'with a private group' do + let(:group) { create(:group, :private) } + + context 'with authorized user' do + before do + group.add_guest(user) + sign_in(user) + end + + it_behaves_like 'ok response with index template' + + context 'when achievements ff is disabled' do + before do + stub_feature_flags(achievements: false) + end + + it_behaves_like 'response with 404 status' + end + end + + context 'with unauthorized user' do + before do + sign_in(user) + end + + it_behaves_like 'response with 404 status' + end + + context 'with anonymous user' do + it 'redirects to sign_in page' do + subject + + expect(response).to have_gitlab_http_status(:found) + expect(response).to redirect_to(new_user_session_path) + end + end + end + + context 'with a public group' do + let(:group) { create(:group, :public) } + + context 'with anonymous user' do + it_behaves_like 'ok response with index template' + end + end + end + + describe 'GET #index' do + subject { get group_achievements_path(group) } + + it_behaves_like 'ok response with index template if authorized' + end +end diff --git a/spec/requests/groups/email_campaigns_controller_spec.rb b/spec/requests/groups/email_campaigns_controller_spec.rb index 7db5c084793..b6e765eba37 100644 --- a/spec/requests/groups/email_campaigns_controller_spec.rb +++ b/spec/requests/groups/email_campaigns_controller_spec.rb @@ -38,11 +38,7 @@ RSpec.describe Groups::EmailCampaignsController, feature_category: :navigation d expect(subject).to have_gitlab_http_status(:redirect) end - context 'on .com' do - before do - allow(Gitlab).to receive(:com?).and_return(true) - end - + context 'on SaaS', :saas do it 'emits a snowplow event', :snowplow do subject diff --git a/spec/requests/groups/observability_controller_spec.rb b/spec/requests/groups/observability_controller_spec.rb index 471cad40c90..b82cf2b0bad 100644 --- a/spec/requests/groups/observability_controller_spec.rb +++ b/spec/requests/groups/observability_controller_spec.rb @@ -26,7 +26,7 @@ RSpec.describe Groups::ObservabilityController, feature_category: :tracing do end end - context 'when user is not a developer' do + context 'when user is a guest' do before do sign_in(user) end @@ -36,10 +36,10 @@ RSpec.describe Groups::ObservabilityController, feature_category: :tracing do end end - context 'when user is authenticated and a developer' do + context 'when user has the correct permissions' do before do sign_in(user) - group.add_developer(user) + set_permissions end context 'when observability url is missing' do @@ -75,13 +75,21 @@ RSpec.describe Groups::ObservabilityController, feature_category: :tracing do let(:path) { group_observability_explore_path(group) } let(:expected_observability_path) { "#{observability_url}/-/#{group.id}/explore" } - it_behaves_like 'observability route request' + it_behaves_like 'observability route request' do + let(:set_permissions) do + group.add_developer(user) + end + end end describe 'GET #datasources' do let(:path) { group_observability_datasources_path(group) } let(:expected_observability_path) { "#{observability_url}/-/#{group.id}/datasources" } - it_behaves_like 'observability route request' + it_behaves_like 'observability route request' do + let(:set_permissions) do + group.add_maintainer(user) + end + end end end diff --git a/spec/requests/groups/settings/access_tokens_controller_spec.rb b/spec/requests/groups/settings/access_tokens_controller_spec.rb index f26b69f8d30..0204af8ea8e 100644 --- a/spec/requests/groups/settings/access_tokens_controller_spec.rb +++ b/spec/requests/groups/settings/access_tokens_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Groups::Settings::AccessTokensController, feature_category: :authentication_and_authorization do +RSpec.describe Groups::Settings::AccessTokensController, feature_category: :system_access do let_it_be(:user) { create(:user) } let_it_be(:resource) { create(:group) } let_it_be(:access_token_user) { create(:user, :project_bot) } diff --git a/spec/requests/groups/settings/applications_controller_spec.rb b/spec/requests/groups/settings/applications_controller_spec.rb index fb91cd8bdab..2fcf80658b2 100644 --- a/spec/requests/groups/settings/applications_controller_spec.rb +++ b/spec/requests/groups/settings/applications_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Groups::Settings::ApplicationsController, feature_category: :authentication_and_authorization do +RSpec.describe Groups::Settings::ApplicationsController, feature_category: :system_access do let_it_be(:user) { create(:user) } let_it_be(:group) { create(:group) } let_it_be(:application) { create(:oauth_application, owner_id: group.id, owner_type: 'Namespace') } diff --git a/spec/requests/groups/usage_quotas_controller_spec.rb b/spec/requests/groups/usage_quotas_controller_spec.rb index a329398aab3..67aef23704a 100644 --- a/spec/requests/groups/usage_quotas_controller_spec.rb +++ b/spec/requests/groups/usage_quotas_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Groups::UsageQuotasController, :with_license, feature_category: :subscription_cost_management do +RSpec.describe Groups::UsageQuotasController, :with_license, feature_category: :consumables_cost_management do let_it_be(:group) { create(:group) } let_it_be(:subgroup) { create(:group, parent: group) } let_it_be(:user) { create(:user) } |