summaryrefslogtreecommitdiff
path: root/spec/features/admin/admin_users_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/features/admin/admin_users_spec.rb')
-rw-r--r--spec/features/admin/admin_users_spec.rb68
1 files changed, 50 insertions, 18 deletions
diff --git a/spec/features/admin/admin_users_spec.rb b/spec/features/admin/admin_users_spec.rb
index e06e2d14f3c..97a30143a59 100644
--- a/spec/features/admin/admin_users_spec.rb
+++ b/spec/features/admin/admin_users_spec.rb
@@ -75,26 +75,12 @@ RSpec.describe "Admin::Users" do
end
context '`Pending approval` tab' do
- context 'feature is enabled' do
- before do
- stub_feature_flags(admin_approval_for_new_user_signups: true)
- visit admin_users_path
- end
-
- it 'shows the `Pending approval` tab' do
- expect(page).to have_link('Pending approval', href: admin_users_path(filter: 'blocked_pending_approval'))
- end
+ before do
+ visit admin_users_path
end
- context 'feature is disabled' do
- before do
- stub_feature_flags(admin_approval_for_new_user_signups: false)
- visit admin_users_path
- end
-
- it 'does not show the `Pending approval` tab' do
- expect(page).not_to have_link('Pending approval', href: admin_users_path(filter: 'blocked_pending_approval'))
- end
+ it 'shows the `Pending approval` tab' do
+ expect(page).to have_link('Pending approval', href: admin_users_path(filter: 'blocked_pending_approval'))
end
end
end
@@ -218,6 +204,32 @@ RSpec.describe "Admin::Users" do
expect(page).to have_content(user.email)
end
end
+
+ context 'when blocking a user' do
+ it 'shows confirmation and allows blocking', :js do
+ expect(page).to have_content(user.email)
+
+ find("[data-testid='user-action-button-#{user.id}']").click
+
+ within find("[data-testid='user-action-dropdown-#{user.id}']") do
+ find('li button', text: 'Block').click
+ end
+
+ wait_for_requests
+
+ 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')
+
+ find('.modal-footer button', text: 'Block').click
+
+ wait_for_requests
+
+ expect(page).to have_content('Successfully blocked')
+ expect(page).not_to have_content(user.email)
+ end
+ end
end
describe "GET /admin/users/new" do
@@ -376,6 +388,26 @@ RSpec.describe "Admin::Users" do
end
end
+ context 'when blocking the user' do
+ it 'shows confirmation and allows blocking', :js do
+ visit admin_user_path(user)
+
+ find('button', text: 'Block user').click
+
+ wait_for_requests
+
+ expect(page).to have_content('Block user')
+ expect(page).to have_content('You can always unblock their account, their data will remain intact.')
+
+ find('.modal-footer button', text: 'Block').click
+
+ wait_for_requests
+
+ expect(page).to have_content('Successfully blocked')
+ expect(page).to have_content('This user is blocked')
+ end
+ end
+
describe 'Impersonation' do
let(:another_user) { create(:user) }