diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 14:18:50 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 14:18:50 +0300 |
commit | 8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch) | |
tree | a77e7fe7a93de11213032ed4ab1f33a3db51b738 /spec/controllers/groups_controller_spec.rb | |
parent | 00b35af3db1abfe813a778f643dad221aad51fca (diff) |
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'spec/controllers/groups_controller_spec.rb')
-rw-r--r-- | spec/controllers/groups_controller_spec.rb | 98 |
1 files changed, 90 insertions, 8 deletions
diff --git a/spec/controllers/groups_controller_spec.rb b/spec/controllers/groups_controller_spec.rb index 354c9e047c8..dce7105c073 100644 --- a/spec/controllers/groups_controller_spec.rb +++ b/spec/controllers/groups_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GroupsController do +RSpec.describe GroupsController do include ExternalAuthorizationServiceHelpers let(:user) { create(:user) } @@ -37,6 +37,8 @@ describe GroupsController do end shared_examples 'details view' do + let(:namespace) { group } + it { is_expected.to render_template('groups/show') } context 'as atom' do @@ -50,6 +52,8 @@ describe GroupsController do expect(assigns(:events).map(&:id)).to contain_exactly(event.id) end end + + it_behaves_like 'namespace storage limit alert' end describe 'GET #show' do @@ -62,7 +66,19 @@ describe GroupsController do subject { get :show, params: { id: group.to_param }, format: format } - it_behaves_like 'details view' + context 'when the group is not importing' do + it_behaves_like 'details view' + end + + context 'when the group is importing' do + before do + create(:group_import_state, group: group) + end + + it 'redirects to the import status page' do + expect(subject).to redirect_to group_import_path(group) + end + end end describe 'GET #details' do @@ -301,6 +317,66 @@ describe GroupsController do end end end + + describe 'tracking group creation for onboarding issues experiment' do + before do + sign_in(user) + end + + subject(:create_namespace) { post :create, params: { group: { name: 'new_group', path: 'new_group' } } } + + context 'experiment disabled' do + before do + stub_experiment(onboarding_issues: false) + end + + it 'does not track anything' do + expect(Gitlab::Tracking).not_to receive(:event) + + create_namespace + end + end + + context 'experiment enabled' do + before do + stub_experiment(onboarding_issues: true) + end + + context 'and the user is part of the control group' do + before do + stub_experiment_for_user(onboarding_issues: false) + end + + it 'tracks the event with the "created_namespace" action with the "control_group" property' do + expect(Gitlab::Tracking).to receive(:event).with( + 'Growth::Conversion::Experiment::OnboardingIssues', + 'created_namespace', + label: anything, + property: 'control_group' + ) + + create_namespace + end + end + + context 'and the user is part of the experimental group' do + before do + stub_experiment_for_user(onboarding_issues: true) + end + + it 'tracks the event with the "created_namespace" action with the "experimental_group" property' do + expect(Gitlab::Tracking).to receive(:event).with( + 'Growth::Conversion::Experiment::OnboardingIssues', + 'created_namespace', + label: anything, + property: 'experimental_group' + ) + + create_namespace + end + end + end + end end describe 'GET #index' do @@ -862,14 +938,17 @@ describe GroupsController do context 'when the endpoint receives requests above the rate limit' do before do sign_in(admin) - allow(Gitlab::ApplicationRateLimiter).to receive(:throttled?).and_return(true) + + allow(Gitlab::ApplicationRateLimiter) + .to receive(:increment) + .and_return(Gitlab::ApplicationRateLimiter.rate_limits[:group_export][:threshold] + 1) end it 'throttles the endpoint' do post :export, params: { id: group.to_param } - expect(flash[:alert]).to eq('This endpoint has been requested too many times. Try again later.') - expect(response).to have_gitlab_http_status(:found) + expect(response.body).to eq('This endpoint has been requested too many times. Try again later.') + expect(response).to have_gitlab_http_status :too_many_requests end end end @@ -933,14 +1012,17 @@ describe GroupsController do context 'when the endpoint receives requests above the rate limit' do before do sign_in(admin) - allow(Gitlab::ApplicationRateLimiter).to receive(:throttled?).and_return(true) + + allow(Gitlab::ApplicationRateLimiter) + .to receive(:increment) + .and_return(Gitlab::ApplicationRateLimiter.rate_limits[:group_download_export][:threshold] + 1) end it 'throttles the endpoint' do get :download_export, params: { id: group.to_param } - expect(flash[:alert]).to eq('This endpoint has been requested too many times. Try again later.') - expect(response).to have_gitlab_http_status(:found) + expect(response.body).to eq('This endpoint has been requested too many times. Try again later.') + expect(response).to have_gitlab_http_status :too_many_requests end end end |