debian-mirror-gitlab/spec/features/admin/users/users_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

616 lines
18 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2014-09-02 18:07:02 +05:30
require 'spec_helper'
2023-03-04 22:38:38 +05:30
RSpec.describe 'Admin::Users', feature_category: :user_management do
2021-09-30 23:02:18 +05:30
include Spec::Support::Helpers::Features::AdminUsersHelpers
2022-04-04 11:22:00 +05:30
include Spec::Support::Helpers::ModalHelpers
2021-09-30 23:02:18 +05:30
2021-02-22 17:27:13 +05:30
let_it_be(:user, reload: true) { create(:omniauth_user, provider: 'twitter', extern_uid: '123456') }
2021-06-08 01:23:25 +05:30
let_it_be(:current_user) { create(:admin) }
2017-09-10 17:25:29 +05:30
before do
sign_in(current_user)
2021-02-22 17:27:13 +05:30
gitlab_enable_admin_mode_sign_in(current_user)
2017-09-10 17:25:29 +05:30
end
2014-09-02 18:07:02 +05:30
2021-09-04 01:27:46 +05:30
describe 'GET /admin/users', :js do
before do
visit admin_users_path
end
2014-09-02 18:07:02 +05:30
2021-09-04 01:27:46 +05:30
it "is ok" do
2022-05-07 20:08:51 +05:30
expect(page).to have_current_path(admin_users_path, ignore_query: true)
2021-09-04 01:27:46 +05:30
end
2014-09-02 18:07:02 +05:30
2021-09-04 01:27:46 +05:30
it "has users list" do
current_user.reload
2015-09-11 14:41:01 +05:30
2021-09-04 01:27:46 +05:30
expect(page).to have_content(current_user.email)
expect(page).to have_content(current_user.name)
2023-03-17 16:20:25 +05:30
expect(page).to have_content(current_user.created_at.strftime('%b %d, %Y'))
2021-09-04 01:27:46 +05:30
expect(page).to have_content(user.email)
expect(page).to have_content(user.name)
expect(page).to have_content('Projects')
2019-03-02 22:35:43 +05:30
2021-09-04 01:27:46 +05:30
click_user_dropdown_toggle(user.id)
2019-03-02 22:35:43 +05:30
2021-09-04 01:27:46 +05:30
expect(page).to have_button('Block')
expect(page).to have_button('Deactivate')
expect(page).to have_button('Delete user')
expect(page).to have_button('Delete user and contributions')
end
2019-03-02 22:35:43 +05:30
2021-09-04 01:27:46 +05:30
it 'clicking edit user takes us to edit page', :aggregate_failures do
page.within("[data-testid='user-actions-#{user.id}']") do
click_link 'Edit'
end
2021-01-03 14:25:43 +05:30
2021-09-04 01:27:46 +05:30
expect(page).to have_content('Name')
expect(page).to have_content('Password')
end
2021-01-03 14:25:43 +05:30
2021-09-04 01:27:46 +05:30
describe 'view extra user information' do
it 'shows the user popover on hover', :js, quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/11290' do
expect(page).not_to have_selector('#__BV_popover_1__')
2021-01-03 14:25:43 +05:30
2021-09-04 01:27:46 +05:30
first_user_link = page.first('.js-user-link')
first_user_link.hover
2021-01-03 14:25:43 +05:30
2021-09-04 01:27:46 +05:30
expect(page).to have_selector('#__BV_popover_1__')
end
end
2021-01-03 14:25:43 +05:30
2021-09-04 01:27:46 +05:30
context 'user project count' do
before do
project = create(:project)
project.add_maintainer(current_user)
end
2021-01-03 14:25:43 +05:30
2021-09-04 01:27:46 +05:30
it 'displays count of users projects' do
visit admin_users_path
2019-02-15 15:39:39 +05:30
2021-09-04 01:27:46 +05:30
expect(page.find("[data-testid='user-project-count-#{current_user.id}']").text).to eq("1")
end
end
describe 'tabs' do
it 'has multiple tabs to filter users' do
expect(page).to have_link('Active', href: admin_users_path)
expect(page).to have_link('Admins', href: admin_users_path(filter: 'admins'))
expect(page).to have_link('2FA Enabled', href: admin_users_path(filter: 'two_factor_enabled'))
expect(page).to have_link('2FA Disabled', href: admin_users_path(filter: 'two_factor_disabled'))
expect(page).to have_link('External', href: admin_users_path(filter: 'external'))
expect(page).to have_link('Blocked', href: admin_users_path(filter: 'blocked'))
expect(page).to have_link('Deactivated', href: admin_users_path(filter: 'deactivated'))
expect(page).to have_link('Without projects', href: admin_users_path(filter: 'wop'))
end
2019-02-15 15:39:39 +05:30
2021-09-04 01:27:46 +05:30
context '`Pending approval` tab' do
before do
visit admin_users_path
2021-06-08 01:23:25 +05:30
end
2019-02-15 15:39:39 +05:30
2021-09-04 01:27:46 +05:30
it 'shows the `Pending approval` tab' do
expect(page).to have_link('Pending approval', href: admin_users_path(filter: 'blocked_pending_approval'))
2021-06-08 01:23:25 +05:30
end
2021-09-04 01:27:46 +05:30
end
end
2019-02-15 15:39:39 +05:30
2021-09-04 01:27:46 +05:30
describe 'search and sort' do
before_all do
create(:user, name: 'Foo Bar', last_activity_on: 3.days.ago)
create(:user, name: 'Foo Baz', last_activity_on: 2.days.ago)
create(:user, name: 'Dmitriy')
end
2019-02-15 15:39:39 +05:30
2021-09-04 01:27:46 +05:30
it 'searches users by name' do
visit admin_users_path(search_query: 'Foo')
2019-02-15 15:39:39 +05:30
2021-09-04 01:27:46 +05:30
expect(page).to have_content('Foo Bar')
expect(page).to have_content('Foo Baz')
expect(page).not_to have_content('Dmitriy')
end
2019-02-15 15:39:39 +05:30
2021-09-04 01:27:46 +05:30
it 'sorts users by name' do
visit admin_users_path
2019-02-15 15:39:39 +05:30
2021-09-04 01:27:46 +05:30
sort_by('Name')
2019-02-15 15:39:39 +05:30
2021-09-04 01:27:46 +05:30
expect(first_row.text).to include('Dmitriy')
expect(second_row.text).to include('Foo Bar')
end
2019-02-15 15:39:39 +05:30
2021-09-04 01:27:46 +05:30
it 'sorts search results only' do
visit admin_users_path(search_query: 'Foo')
2019-02-15 15:39:39 +05:30
2021-09-04 01:27:46 +05:30
sort_by('Name')
expect(page).not_to have_content('Dmitriy')
expect(first_row.text).to include('Foo Bar')
expect(second_row.text).to include('Foo Baz')
end
2019-03-02 22:35:43 +05:30
2021-09-04 01:27:46 +05:30
it 'searches with respect of sorting' do
2022-05-07 20:08:51 +05:30
visit admin_users_path(sort: 'name_asc')
2019-03-02 22:35:43 +05:30
2021-09-04 01:27:46 +05:30
fill_in :search_query, with: 'Foo'
click_button('Search users')
2019-03-02 22:35:43 +05:30
2021-09-04 01:27:46 +05:30
expect(first_row.text).to include('Foo Bar')
expect(second_row.text).to include('Foo Baz')
end
2019-03-02 22:35:43 +05:30
2021-09-04 01:27:46 +05:30
it 'sorts users by recent last activity' do
visit admin_users_path(search_query: 'Foo')
2019-03-02 22:35:43 +05:30
2021-09-04 01:27:46 +05:30
sort_by('Recent last activity')
2019-03-02 22:35:43 +05:30
2021-09-04 01:27:46 +05:30
expect(first_row.text).to include('Foo Baz')
expect(second_row.text).to include('Foo Bar')
end
2019-02-15 15:39:39 +05:30
2021-09-04 01:27:46 +05:30
it 'sorts users by oldest last activity' do
visit admin_users_path(search_query: 'Foo')
2015-09-11 14:41:01 +05:30
2021-09-04 01:27:46 +05:30
sort_by('Oldest last activity')
2015-09-11 14:41:01 +05:30
2021-09-04 01:27:46 +05:30
expect(first_row.text).to include('Foo Bar')
expect(second_row.text).to include('Foo Baz')
end
end
describe 'Two-factor Authentication filters' do
it 'counts users who have enabled 2FA' do
create(:user, :two_factor)
visit admin_users_path
2021-12-11 22:18:48 +05:30
page.within('.filter-two-factor-enabled .gl-tab-counter-badge') do
2021-09-04 01:27:46 +05:30
expect(page).to have_content('1')
2015-09-11 14:41:01 +05:30
end
2021-09-04 01:27:46 +05:30
end
2015-09-11 14:41:01 +05:30
2021-09-04 01:27:46 +05:30
it 'filters by users who have enabled 2FA' do
user = create(:user, :two_factor)
2015-09-11 14:41:01 +05:30
2021-09-04 01:27:46 +05:30
visit admin_users_path
click_link '2FA Enabled'
2015-09-11 14:41:01 +05:30
2021-09-04 01:27:46 +05:30
expect(page).to have_content(user.email)
end
2015-09-11 14:41:01 +05:30
2021-09-04 01:27:46 +05:30
it 'counts users who have not enabled 2FA' do
visit admin_users_path
2015-09-11 14:41:01 +05:30
2021-12-11 22:18:48 +05:30
page.within('.filter-two-factor-disabled .gl-tab-counter-badge') do
2021-09-04 01:27:46 +05:30
expect(page).to have_content('2') # Including admin
end
end
2015-09-11 14:41:01 +05:30
2021-09-04 01:27:46 +05:30
it 'filters by users who have not enabled 2FA' do
visit admin_users_path
click_link '2FA Disabled'
2015-09-11 14:41:01 +05:30
2021-09-04 01:27:46 +05:30
expect(page).to have_content(user.email)
end
end
2021-01-03 14:25:43 +05:30
2021-09-04 01:27:46 +05:30
describe 'Pending approval filter' do
it 'counts users who are pending approval' do
create_list(:user, 2, :blocked_pending_approval)
2021-01-03 14:25:43 +05:30
2021-09-04 01:27:46 +05:30
visit admin_users_path
2021-01-03 14:25:43 +05:30
2021-12-11 22:18:48 +05:30
page.within('.filter-blocked-pending-approval .gl-tab-counter-badge') do
2021-09-04 01:27:46 +05:30
expect(page).to have_content('2')
2021-01-03 14:25:43 +05:30
end
2021-09-04 01:27:46 +05:30
end
2021-01-03 14:25:43 +05:30
2021-09-04 01:27:46 +05:30
it 'filters by users who are pending approval' do
user = create(:user, :blocked_pending_approval)
2021-01-03 14:25:43 +05:30
2021-09-04 01:27:46 +05:30
visit admin_users_path
click_link 'Pending approval'
2021-01-03 14:25:43 +05:30
2021-09-04 01:27:46 +05:30
expect(page).to have_content(user.email)
end
end
2021-01-29 00:20:46 +05:30
2021-09-04 01:27:46 +05:30
context 'when blocking/unblocking a user' do
it 'shows confirmation and allows blocking and unblocking', :js do
expect(page).to have_content(user.email)
2021-01-29 00:20:46 +05:30
2021-09-04 01:27:46 +05:30
click_action_in_user_dropdown(user.id, 'Block')
2021-01-29 00:20:46 +05:30
2021-09-04 01:27:46 +05:30
wait_for_requests
2021-01-29 00:20:46 +05:30
2021-09-04 01:27:46 +05:30
expect(page).to have_content('Block user')
expect(page).to have_content('Blocking user has the following effects')
expect(page).to have_content('User will not be able to login')
expect(page).to have_content('Owned groups will be left')
2021-01-29 00:20:46 +05:30
2021-09-04 01:27:46 +05:30
find('.modal-footer button', text: 'Block').click
2021-01-29 00:20:46 +05:30
2021-09-04 01:27:46 +05:30
wait_for_requests
2021-01-29 00:20:46 +05:30
2021-09-04 01:27:46 +05:30
expect(page).to have_content('Successfully blocked')
expect(page).not_to have_content(user.email)
2021-02-22 17:27:13 +05:30
2021-09-04 01:27:46 +05:30
click_link 'Blocked'
2021-02-22 17:27:13 +05:30
2021-09-04 01:27:46 +05:30
wait_for_requests
2021-02-22 17:27:13 +05:30
2021-09-04 01:27:46 +05:30
expect(page).to have_content(user.email)
2021-02-22 17:27:13 +05:30
2021-09-04 01:27:46 +05:30
click_action_in_user_dropdown(user.id, 'Unblock')
2021-02-22 17:27:13 +05:30
2021-09-04 01:27:46 +05:30
expect(page).to have_content('Unblock user')
expect(page).to have_content('You can always block their account again if needed.')
2021-02-22 17:27:13 +05:30
2021-09-04 01:27:46 +05:30
find('.modal-footer button', text: 'Unblock').click
2021-02-22 17:27:13 +05:30
2021-09-04 01:27:46 +05:30
wait_for_requests
2021-02-22 17:27:13 +05:30
2021-09-04 01:27:46 +05:30
expect(page).to have_content('Successfully unblocked')
expect(page).not_to have_content(user.email)
end
end
2021-02-22 17:27:13 +05:30
2021-09-04 01:27:46 +05:30
context 'when deactivating/re-activating a user' do
it 'shows confirmation and allows deactivating and re-activating', :js do
expect(page).to have_content(user.email)
2021-02-22 17:27:13 +05:30
2021-09-04 01:27:46 +05:30
click_action_in_user_dropdown(user.id, 'Deactivate')
2021-02-22 17:27:13 +05:30
2021-09-04 01:27:46 +05:30
expect(page).to have_content('Deactivate user')
expect(page).to have_content('Deactivating a user has the following effects')
expect(page).to have_content('The user will be logged out')
expect(page).to have_content('Personal projects, group and user history will be left intact')
2021-02-22 17:27:13 +05:30
2021-09-04 01:27:46 +05:30
find('.modal-footer button', text: 'Deactivate').click
2021-02-22 17:27:13 +05:30
2021-09-04 01:27:46 +05:30
wait_for_requests
2021-02-22 17:27:13 +05:30
2021-09-04 01:27:46 +05:30
expect(page).to have_content('Successfully deactivated')
expect(page).not_to have_content(user.email)
2021-02-22 17:27:13 +05:30
2021-09-04 01:27:46 +05:30
click_link 'Deactivated'
2021-02-22 17:27:13 +05:30
2021-09-04 01:27:46 +05:30
wait_for_requests
2021-02-22 17:27:13 +05:30
2021-09-04 01:27:46 +05:30
expect(page).to have_content(user.email)
2021-02-22 17:27:13 +05:30
2021-09-04 01:27:46 +05:30
click_action_in_user_dropdown(user.id, 'Activate')
2021-02-22 17:27:13 +05:30
2021-09-04 01:27:46 +05:30
expect(page).to have_content('Activate user')
expect(page).to have_content('You can always deactivate their account again if needed.')
2021-02-22 17:27:13 +05:30
2021-09-04 01:27:46 +05:30
find('.modal-footer button', text: 'Activate').click
2021-02-22 17:27:13 +05:30
2021-09-04 01:27:46 +05:30
wait_for_requests
2021-02-22 17:27:13 +05:30
2021-09-04 01:27:46 +05:30
expect(page).to have_content('Successfully activated')
expect(page).not_to have_content(user.email)
end
end
2021-02-22 17:27:13 +05:30
2022-04-04 11:22:00 +05:30
context 'when a user is locked', time_travel_to: '2020-02-25 10:30:45 -0700' do
let_it_be(:locked_user) { create(:user, locked_at: DateTime.parse('2020-02-25 10:30:00 -0700')) }
it "displays `Locked` badge next to user" do
expect(page).to have_content("#{locked_user.name} Locked")
end
it 'allows a user to be unlocked from the `User administration dropdown', :js do
accept_gl_confirm("Unlock user #{locked_user.name}?", button_text: 'Unlock') do
click_action_in_user_dropdown(locked_user.id, 'Unlock')
end
expect(page).not_to have_content("#{locked_user.name} (Locked)")
end
end
2021-09-04 01:27:46 +05:30
describe 'internal users' do
context 'when showing a `Ghost User`' do
let_it_be(:ghost_user) { create(:user, :ghost) }
2021-02-22 17:27:13 +05:30
2021-09-04 01:27:46 +05:30
it 'does not render actions dropdown' do
expect(page).not_to have_css("[data-testid='user-actions-#{ghost_user.id}'] [data-testid='dropdown-toggle']")
end
end
context 'when showing a `Bot User`' do
let_it_be(:bot_user) { create(:user, user_type: :alert_bot) }
2021-02-22 17:27:13 +05:30
2021-09-04 01:27:46 +05:30
it 'does not render actions dropdown' do
expect(page).not_to have_css("[data-testid='user-actions-#{bot_user.id}'] [data-testid='dropdown-toggle']")
2021-06-08 01:23:25 +05:30
end
end
2021-02-22 17:27:13 +05:30
end
2021-09-04 01:27:46 +05:30
context 'user group count', :js do
before do
group = create(:group)
group.add_developer(current_user)
project = create(:project, group: create(:group))
project.add_reporter(current_user)
end
it 'displays count of the users authorized groups' do
2022-05-07 20:08:51 +05:30
visit admin_users_path
2021-09-04 01:27:46 +05:30
wait_for_requests
expect(page.find("[data-testid='user-group-count-#{current_user.id}']").text).to eq("2")
end
end
2014-09-02 18:07:02 +05:30
end
2021-02-22 17:27:13 +05:30
describe 'GET /admin/users/new' do
2021-06-08 01:23:25 +05:30
let_it_be(:user_username) { 'bang' }
2018-11-20 20:47:30 +05:30
2014-09-02 18:07:02 +05:30
before do
visit new_admin_user_path
2021-02-22 17:27:13 +05:30
fill_in 'user_name', with: 'Big Bang'
fill_in 'user_username', with: user_username
fill_in 'user_email', with: 'bigbang@mail.com'
2014-09-02 18:07:02 +05:30
end
2021-02-22 17:27:13 +05:30
it 'creates new user' do
2022-08-27 11:52:29 +05:30
expect { click_button 'Create user' }.to change { User.count }.by(1)
2014-09-02 18:07:02 +05:30
end
2021-02-22 17:27:13 +05:30
it 'applies defaults to user' do
click_button 'Create user'
2015-04-26 12:48:37 +05:30
user = User.find_by(username: 'bang')
2017-09-10 17:25:29 +05:30
expect(user.projects_limit)
.to eq(Gitlab.config.gitlab.default_projects_limit)
expect(user.can_create_group)
2022-11-25 23:54:43 +05:30
.to eq(Gitlab::CurrentSettings.can_create_group)
2023-03-17 16:20:25 +05:30
expect(user.private_profile)
.to eq(Gitlab::CurrentSettings.user_defaults_to_private_profile)
2014-09-02 18:07:02 +05:30
end
2021-02-22 17:27:13 +05:30
it 'creates user with valid data' do
click_button 'Create user'
2015-04-26 12:48:37 +05:30
user = User.find_by(username: 'bang')
expect(user.name).to eq('Big Bang')
expect(user.email).to eq('bigbang@mail.com')
2014-09-02 18:07:02 +05:30
end
2021-02-22 17:27:13 +05:30
it 'calls send mail' do
2019-12-26 22:10:19 +05:30
expect_next_instance_of(NotificationService) do |instance|
expect(instance).to receive(:new_user)
end
2014-09-02 18:07:02 +05:30
2021-02-22 17:27:13 +05:30
click_button 'Create user'
2014-09-02 18:07:02 +05:30
end
2021-02-22 17:27:13 +05:30
it 'sends valid email to user with email & password' do
2015-12-23 02:04:40 +05:30
perform_enqueued_jobs do
2021-02-22 17:27:13 +05:30
click_button 'Create user'
2015-12-23 02:04:40 +05:30
end
2015-04-26 12:48:37 +05:30
user = User.find_by(username: 'bang')
2014-09-02 18:07:02 +05:30
email = ActionMailer::Base.deliveries.last
2015-04-26 12:48:37 +05:30
expect(email.subject).to have_content('Account was created')
expect(email.text_part.body).to have_content(user.email)
expect(email.text_part.body).to have_content('password')
2014-09-02 18:07:02 +05:30
end
2018-11-20 20:47:30 +05:30
context 'username contains spaces' do
2021-06-08 01:23:25 +05:30
let_it_be(:user_username) { 'Bing bang' }
2018-11-20 20:47:30 +05:30
it "doesn't create the user and shows an error message" do
2022-08-27 11:52:29 +05:30
expect { click_button 'Create user' }.to change { User.count }.by(0)
2018-11-20 20:47:30 +05:30
expect(page).to have_content('The form contains the following error')
expect(page).to have_content('Username can contain only letters, digits')
end
end
context 'with new users set to external enabled' do
context 'with regex to match internal user email address set', :js do
before do
stub_application_setting(user_default_external: true)
2019-02-15 15:39:39 +05:30
stub_application_setting(user_default_internal_regex: '\.internal@')
2018-11-20 20:47:30 +05:30
visit new_admin_user_path
end
it 'automatically unchecks external for matching email' do
expects_external_to_be_checked
expects_warning_to_be_hidden
fill_in 'user_email', with: 'test.internal@domain.ch'
expects_external_to_be_unchecked
expects_warning_to_be_shown
fill_in 'user_email', with: 'test@domain.ch'
expects_external_to_be_checked
expects_warning_to_be_hidden
uncheck 'user_external'
expects_warning_to_be_hidden
end
2019-02-15 15:39:39 +05:30
it 'creates an internal user' do
user_name = 'tester1'
fill_in 'user_email', with: 'test.internal@domain.ch'
fill_in 'user_name', with: 'tester1 name'
fill_in 'user_username', with: user_name
expects_external_to_be_unchecked
expects_warning_to_be_shown
click_button 'Create user'
new_user = User.find_by(username: user_name)
expect(new_user.external).to be_falsy
end
2014-09-02 18:07:02 +05:30
2021-06-08 01:23:25 +05:30
def expects_external_to_be_checked
expect(find('#user_external')).to be_checked
end
2017-08-17 22:00:37 +05:30
2021-06-08 01:23:25 +05:30
def expects_external_to_be_unchecked
expect(find('#user_external')).not_to be_checked
end
2017-08-17 22:00:37 +05:30
2021-06-08 01:23:25 +05:30
def expects_warning_to_be_hidden
expect(find('#warning_external_automatically_set', visible: :all)[:class]).to include 'hidden'
2017-08-17 22:00:37 +05:30
end
2021-06-08 01:23:25 +05:30
def expects_warning_to_be_shown
expect(find('#warning_external_automatically_set')[:class]).not_to include 'hidden'
end
2017-08-17 22:00:37 +05:30
end
end
end
2021-02-22 17:27:13 +05:30
describe 'GET /admin/users/:id/projects' do
let_it_be(:group) { create(:group) }
let_it_be(:project) { create(:project, group: group) }
2017-08-17 22:00:37 +05:30
before do
group.add_developer(user)
visit projects_admin_user_path(user)
end
2022-03-02 08:16:31 +05:30
it 'lists groups' do
2022-11-25 23:54:43 +05:30
within(:css, '.gl-mb-3 + .gl-card') do
2022-03-02 08:16:31 +05:30
expect(page).to have_content 'Groups'
2018-10-15 14:42:47 +05:30
expect(page).to have_link group.name, href: admin_group_path(group)
2014-09-02 18:07:02 +05:30
end
end
2017-08-17 22:00:37 +05:30
it 'allows navigation to the group details' do
2022-11-25 23:54:43 +05:30
within(:css, '.gl-mb-3 + .gl-card') do
2017-08-17 22:00:37 +05:30
click_link group.name
end
2022-07-23 23:45:48 +05:30
expect(page).to have_content "Group: #{group.name}"
2017-08-17 22:00:37 +05:30
expect(page).to have_content project.name
end
it 'shows the group access level' do
2022-11-25 23:54:43 +05:30
within(:css, '.gl-mb-3 + .gl-card') do
2017-08-17 22:00:37 +05:30
expect(page).to have_content 'Developer'
end
end
2018-03-17 18:26:18 +05:30
it 'allows group membership to be revoked', :js do
2017-08-17 22:00:37 +05:30
page.within(first('.group_member')) do
2022-07-23 23:45:48 +05:30
find('.btn[data-testid="remove-user"]').click
2017-08-17 22:00:37 +05:30
end
2022-07-23 23:45:48 +05:30
accept_gl_confirm(button_text: 'Remove')
2017-09-10 17:25:29 +05:30
wait_for_requests
2017-08-17 22:00:37 +05:30
expect(page).not_to have_selector('.group_member')
end
end
2018-11-18 11:00:15 +05:30
describe 'show breadcrumbs' do
it do
visit admin_user_path(user)
check_breadcrumb(user.name)
visit projects_admin_user_path(user)
check_breadcrumb(user.name)
visit keys_admin_user_path(user)
check_breadcrumb(user.name)
visit admin_user_impersonation_tokens_path(user)
check_breadcrumb(user.name)
visit admin_user_identities_path(user)
check_breadcrumb(user.name)
visit new_admin_user_identity_path(user)
2021-02-22 17:27:13 +05:30
check_breadcrumb('New Identity')
2018-11-18 11:00:15 +05:30
visit admin_user_identities_path(user)
find('.table').find(:link, 'Edit').click
2021-02-22 17:27:13 +05:30
check_breadcrumb('Edit Identity')
2017-08-17 22:00:37 +05:30
end
2021-06-08 01:23:25 +05:30
def check_breadcrumb(content)
2022-07-16 23:28:13 +05:30
expect(find('[data-testid="breadcrumb-current-link"]')).to have_content(content)
2021-06-08 01:23:25 +05:30
end
2014-09-02 18:07:02 +05:30
end
2018-11-18 11:00:15 +05:30
2021-06-08 01:23:25 +05:30
describe 'GET /admin/users/:id/edit' do
before do
visit edit_admin_user_path(user)
end
describe 'Update user' do
before do
fill_in 'user_name', with: 'Big Bang'
fill_in 'user_email', with: 'bigbang@mail.com'
fill_in 'user_password', with: 'AValidPassword1'
fill_in 'user_password_confirmation', with: 'AValidPassword1'
choose 'user_access_level_admin'
2023-03-17 16:20:25 +05:30
check 'Private profile'
2021-06-08 01:23:25 +05:30
click_button 'Save changes'
end
it 'shows page with new data' do
expect(page).to have_content('bigbang@mail.com')
expect(page).to have_content('Big Bang')
end
it 'changes user entry' do
user.reload
expect(user.name).to eq('Big Bang')
expect(user.admin?).to be_truthy
2022-05-07 20:08:51 +05:30
expect(user.password_expires_at).to be <= Time.zone.now
2023-03-17 16:20:25 +05:30
expect(user.private_profile).to eq(true)
2021-06-08 01:23:25 +05:30
end
end
describe 'update username to non ascii char' do
it do
fill_in 'user_username', with: '\u3042\u3044'
click_button('Save')
page.within '#error_explanation' do
expect(page).to have_content('Username')
end
expect(page).to have_selector(%(form[action="/admin/users/#{user.username}"]))
end
end
end
def first_row
page.all('[role="row"]')[1]
end
def second_row
page.all('[role="row"]')[2]
end
def sort_by(option)
page.within('.filtered-search-block') do
2023-03-04 22:38:38 +05:30
find('.gl-dropdown').click
find('.gl-dropdown-item', text: option).click
2021-06-08 01:23:25 +05:30
end
end
2014-09-02 18:07:02 +05:30
end