Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-06-20 13:43:29 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-06-20 13:43:29 +0300
commit3b1af5cc7ed2666ff18b718ce5d30fa5a2756674 (patch)
tree3bc4a40e0ee51ec27eabf917c537033c0c5b14d4 /spec/controllers/profiles
parent9bba14be3f2c211bf79e15769cd9b77bc73a13bc (diff)
Add latest changes from gitlab-org/gitlab@16-1-stable-eev16.1.0-rc42
Diffstat (limited to 'spec/controllers/profiles')
-rw-r--r--spec/controllers/profiles/preferences_controller_spec.rb1
-rw-r--r--spec/controllers/profiles/slacks_controller_spec.rb63
-rw-r--r--spec/controllers/profiles/webauthn_registrations_controller_spec.rb24
3 files changed, 84 insertions, 4 deletions
diff --git a/spec/controllers/profiles/preferences_controller_spec.rb b/spec/controllers/profiles/preferences_controller_spec.rb
index e2ade5e3de9..f5c97f63293 100644
--- a/spec/controllers/profiles/preferences_controller_spec.rb
+++ b/spec/controllers/profiles/preferences_controller_spec.rb
@@ -53,6 +53,7 @@ RSpec.describe Profiles::PreferencesController do
first_day_of_week: '1',
preferred_language: 'jp',
tab_width: '5',
+ project_shortcut_buttons: 'true',
render_whitespace_in_code: 'true'
}.with_indifferent_access
diff --git a/spec/controllers/profiles/slacks_controller_spec.rb b/spec/controllers/profiles/slacks_controller_spec.rb
new file mode 100644
index 00000000000..3c47ad1285b
--- /dev/null
+++ b/spec/controllers/profiles/slacks_controller_spec.rb
@@ -0,0 +1,63 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Profiles::SlacksController, feature_category: :integrations do
+ let_it_be(:user) { create(:user) }
+
+ before do
+ sign_in(user)
+
+ allow(subject).to receive(:current_user).and_return(user)
+ end
+
+ describe 'GET edit' do
+ before do
+ get :edit
+ end
+
+ it 'renders' do
+ expect(response).to render_template :edit
+ end
+
+ it 'assigns projects' do
+ expect(assigns[:projects]).to eq []
+ end
+
+ it 'assigns disabled_projects' do
+ expect(assigns[:disabled_projects]).to eq []
+ end
+ end
+
+ describe 'GET slack_link' do
+ let_it_be(:project) { create(:project) }
+
+ context 'when user is not a maintainer of the project' do
+ before do
+ project.add_developer(user)
+ end
+
+ it 'renders 404' do
+ get :slack_link, params: { project_id: project.id }
+
+ expect(response).to have_gitlab_http_status(:not_found)
+ expect(response.body).to be_blank
+ end
+ end
+
+ context 'when user is a maintainer of the project' do
+ before do
+ project.add_maintainer(user)
+ end
+
+ it 'renders slack link' do
+ allow(controller).to receive(:add_to_slack_link).and_return('mock_redirect_link')
+
+ get :slack_link, params: { project_id: project.id }
+
+ expect(response).to have_gitlab_http_status(:ok)
+ expect(json_response).to eq({ 'add_to_slack_link' => 'mock_redirect_link' })
+ end
+ end
+ end
+end
diff --git a/spec/controllers/profiles/webauthn_registrations_controller_spec.rb b/spec/controllers/profiles/webauthn_registrations_controller_spec.rb
index 0c475039963..949de9d0b90 100644
--- a/spec/controllers/profiles/webauthn_registrations_controller_spec.rb
+++ b/spec/controllers/profiles/webauthn_registrations_controller_spec.rb
@@ -10,11 +10,27 @@ RSpec.describe Profiles::WebauthnRegistrationsController do
end
describe '#destroy' do
- it 'deletes the given webauthn registration' do
- registration_to_delete = user.webauthn_registrations.first
+ let(:webauthn_id) { user.webauthn_registrations.first.id }
- expect { delete :destroy, params: { id: registration_to_delete.id } }.to change { user.webauthn_registrations.count }.by(-1)
- expect(response).to be_redirect
+ subject { delete :destroy, params: { id: webauthn_id } }
+
+ it 'redirects to the profile two factor authentication page' do
+ subject
+
+ expect(response).to redirect_to profile_two_factor_auth_path
+ end
+
+ it 'destroys the webauthn registration' do
+ expect { subject }.to change { user.webauthn_registrations.count }.by(-1)
+ end
+
+ it 'calls the Webauthn::DestroyService' do
+ service = double
+
+ expect(Webauthn::DestroyService).to receive(:new).with(user, user, webauthn_id.to_s).and_return(service)
+ expect(service).to receive(:execute)
+
+ subject
end
end
end