diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
commit | 7e9c479f7de77702622631cff2628a9c8dcbc627 (patch) | |
tree | c8f718a08e110ad7e1894510980d2155a6549197 /spec/controllers/groups_controller_spec.rb | |
parent | e852b0ae16db4052c1c567d9efa4facc81146e88 (diff) |
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'spec/controllers/groups_controller_spec.rb')
-rw-r--r-- | spec/controllers/groups_controller_spec.rb | 86 |
1 files changed, 71 insertions, 15 deletions
diff --git a/spec/controllers/groups_controller_spec.rb b/spec/controllers/groups_controller_spec.rb index df7e018b35e..55833ee3aad 100644 --- a/spec/controllers/groups_controller_spec.rb +++ b/spec/controllers/groups_controller_spec.rb @@ -319,10 +319,10 @@ RSpec.describe GroupsController, factory_default: :keep do stub_experiment(onboarding_issues: false) end - it 'does not track anything' do - expect(Gitlab::Tracking).not_to receive(:event) - + it 'does not track anything', :snowplow do create_namespace + + expect_no_snowplow_event end end @@ -336,15 +336,15 @@ RSpec.describe GroupsController, factory_default: :keep 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', + it 'tracks the event with the "created_namespace" action with the "control_group" property', :snowplow do + create_namespace + + expect_snowplow_event( + category: 'Growth::Conversion::Experiment::OnboardingIssues', + action: 'created_namespace', label: anything, property: 'control_group' ) - - create_namespace end end @@ -353,15 +353,15 @@ RSpec.describe GroupsController, factory_default: :keep 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', + it 'tracks the event with the "created_namespace" action with the "experimental_group" property', :snowplow do + create_namespace + + expect_snowplow_event( + category: 'Growth::Conversion::Experiment::OnboardingIssues', + action: 'created_namespace', label: anything, property: 'experimental_group' ) - - create_namespace end end end @@ -1213,4 +1213,60 @@ RSpec.describe GroupsController, factory_default: :keep do it_behaves_like 'disabled when using an external authorization service' end end + + describe 'GET #unfoldered_environment_names' do + it 'shows the environment names of a public project to an anonymous user' do + public_project = create(:project, :public, namespace: group) + + create(:environment, project: public_project, name: 'foo') + + get( + :unfoldered_environment_names, + params: { id: group, format: :json } + ) + + expect(response).to have_gitlab_http_status(:ok) + expect(json_response).to eq(%w[foo]) + end + + it 'does not show environment names of private projects to anonymous users' do + create(:environment, project: project, name: 'foo') + + get( + :unfoldered_environment_names, + params: { id: group, format: :json } + ) + + expect(response).to have_gitlab_http_status(:ok) + expect(json_response).to be_empty + end + + it 'shows environment names of a private project to a group member' do + create(:environment, project: project, name: 'foo') + sign_in(developer) + + get( + :unfoldered_environment_names, + params: { id: group, format: :json } + ) + + expect(response).to have_gitlab_http_status(:ok) + expect(json_response).to eq(%w[foo]) + end + + it 'does not show environment names of private projects to a logged-in non-member' do + alice = create(:user) + + create(:environment, project: project, name: 'foo') + sign_in(alice) + + get( + :unfoldered_environment_names, + params: { id: group, format: :json } + ) + + expect(response).to have_gitlab_http_status(:ok) + expect(json_response).to be_empty + end + end end |