diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-08-18 08:17:02 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-08-18 08:17:02 +0000 |
commit | b39512ed755239198a9c294b6a45e65c05900235 (patch) | |
tree | d234a3efade1de67c46b9e5a38ce813627726aa7 /spec/controllers/admin | |
parent | d31474cf3b17ece37939d20082b07f6657cc79a9 (diff) | |
download | gitlab-ce-b39512ed755239198a9c294b6a45e65c05900235.tar.gz |
Add latest changes from gitlab-org/gitlab@15-3-stable-eev15.3.0-rc42
Diffstat (limited to 'spec/controllers/admin')
5 files changed, 91 insertions, 3 deletions
diff --git a/spec/controllers/admin/dev_ops_report_controller_spec.rb b/spec/controllers/admin/dev_ops_report_controller_spec.rb index 49e6c0f69bd..5d7a7e089aa 100644 --- a/spec/controllers/admin/dev_ops_report_controller_spec.rb +++ b/spec/controllers/admin/dev_ops_report_controller_spec.rb @@ -28,6 +28,17 @@ RSpec.describe Admin::DevOpsReportController do let(:request_params) { { tab: 'devops-score' } } end + + it_behaves_like 'Snowplow event tracking' do + subject { get :show, format: :html } + + let(:feature_flag_name) { :route_hll_to_snowplow_phase2 } + let(:category) { described_class.name } + let(:action) { 'perform_analytics_usage_action' } + let(:label) { 'redis_hll_counters.analytics.analytics_total_unique_counts_monthly' } + let(:property) { 'i_analytics_dev_ops_score' } + let(:namespace) { nil } + end end end diff --git a/spec/controllers/admin/identities_controller_spec.rb b/spec/controllers/admin/identities_controller_spec.rb index 6ac5ce13884..e32191e04e7 100644 --- a/spec/controllers/admin/identities_controller_spec.rb +++ b/spec/controllers/admin/identities_controller_spec.rb @@ -9,6 +9,30 @@ RSpec.describe Admin::IdentitiesController do sign_in(admin) end + describe 'GET #index' do + context 'when the user has no identities' do + it 'shows no identities' do + get :index, params: { user_id: admin.username } + + expect(assigns(:user)).to eq(admin) + expect(assigns(:identities)).to be_blank + expect(response).to have_gitlab_http_status(:ok) + end + end + + context 'when the user has identities' do + let(:ldap_user) { create(:omniauth_user, provider: 'ldapmain', extern_uid: 'ldap-uid') } + + it 'shows identities' do + get :index, params: { user_id: ldap_user.username } + + expect(assigns(:user)).to eq(ldap_user) + expect(assigns(:identities)).to eq(ldap_user.identities) + expect(response).to have_gitlab_http_status(:ok) + end + end + end + describe 'UPDATE identity' do let(:user) { create(:omniauth_user, provider: 'ldapmain', extern_uid: 'uid=myuser,ou=people,dc=example,dc=com') } diff --git a/spec/controllers/admin/topics_controller_spec.rb b/spec/controllers/admin/topics_controller_spec.rb index ee36d5f1def..87093e0263b 100644 --- a/spec/controllers/admin/topics_controller_spec.rb +++ b/spec/controllers/admin/topics_controller_spec.rb @@ -173,4 +173,44 @@ RSpec.describe Admin::TopicsController do end end end + + describe 'POST #merge' do + let_it_be(:source_topic) { create(:topic, name: 'source_topic') } + let_it_be(:project) { create(:project, topic_list: source_topic.name ) } + + it 'merges source topic into target topic' do + post :merge, params: { source_topic_id: source_topic.id, target_topic_id: topic.id } + + expect(response).to redirect_to(admin_topics_path) + expect(topic.projects).to contain_exactly(project) + expect { source_topic.reload }.to raise_error(ActiveRecord::RecordNotFound) + end + + it 'renders a 404 error for non-existing id' do + post :merge, params: { source_topic_id: non_existing_record_id, target_topic_id: topic.id } + + expect(response).to have_gitlab_http_status(:not_found) + expect { topic.reload }.not_to raise_error + end + + it 'renders a 400 error for identical topic ids' do + post :merge, params: { source_topic_id: topic, target_topic_id: topic.id } + + expect(response).to have_gitlab_http_status(:bad_request) + expect { topic.reload }.not_to raise_error + end + + context 'as a normal user' do + before do + sign_in(user) + end + + it 'renders a 404 error' do + post :merge, params: { source_topic_id: source_topic.id, target_topic_id: topic.id } + + expect(response).to have_gitlab_http_status(:not_found) + expect { source_topic.reload }.not_to raise_error + end + end + end end diff --git a/spec/controllers/admin/usage_trends_controller_spec.rb b/spec/controllers/admin/usage_trends_controller_spec.rb index 35fb005aacb..356f603bf57 100644 --- a/spec/controllers/admin/usage_trends_controller_spec.rb +++ b/spec/controllers/admin/usage_trends_controller_spec.rb @@ -13,5 +13,18 @@ RSpec.describe Admin::UsageTrendsController do it_behaves_like 'tracking unique visits', :index do let(:target_id) { 'i_analytics_instance_statistics' } end + + it_behaves_like 'Snowplow event tracking' do + subject { get :index } + + let(:feature_flag_name) { :route_hll_to_snowplow_phase2 } + let(:category) { described_class.name } + let(:action) { 'perform_analytics_usage_action' } + let(:label) { 'redis_hll_counters.analytics.analytics_total_unique_counts_monthly' } + let(:property) { 'i_analytics_instance_statistics' } + let(:namespace) { nil } + let(:project) { nil } + let(:user) { admin } + end end end diff --git a/spec/controllers/admin/users_controller_spec.rb b/spec/controllers/admin/users_controller_spec.rb index c46a12680a2..515ad9daf36 100644 --- a/spec/controllers/admin/users_controller_spec.rb +++ b/spec/controllers/admin/users_controller_spec.rb @@ -140,7 +140,7 @@ RSpec.describe Admin::UsersController do it 'displays the rejection message' do subject - expect(response).to redirect_to(admin_users_path) + expect(response).to redirect_to(admin_user_path(user)) expect(flash[:notice]).to eq("You've rejected #{user.name}") end @@ -612,8 +612,8 @@ RSpec.describe Admin::UsersController do end context 'when the new password does not match the password confirmation' do - let(:password) { 'some_password' } - let(:password_confirmation) { 'not_same_as_password' } + let(:password) { User.random_password } + let(:password_confirmation) { User.random_password } it 'shows the edit page again' do update_password(user, password, password_confirmation) |