X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/3443533ce3836673b0533c8474717a41e7f107fe..353431363d84ff6386d06fd9216907cdc8307d26:/test/system/user_blocks_test.rb diff --git a/test/system/user_blocks_test.rb b/test/system/user_blocks_test.rb index 66a8befec..f710f74aa 100644 --- a/test/system/user_blocks_test.rb +++ b/test/system/user_blocks_test.rb @@ -27,16 +27,45 @@ class ReportNoteTest < ApplicationSystemTestCase assert_no_link "Revoke all blocks" end - test "revoke all link is present and working for moderators when viewed user has active blocks" do + test "revoke all page has no controls when viewed user has no active blocks" do + blocked_user = create(:user) + sign_in_as(create(:moderator_user)) + + visit revoke_all_user_blocks_path(blocked_user) + assert_title "Revoking all blocks on #{blocked_user.display_name}" + assert_text "Revoking all blocks on #{blocked_user.display_name}" + assert_no_button "Revoke!" + end + + test "revoke all link is present and working for moderators when viewed user has one active block" do + blocked_user = create(:user) + create(:user_block, :user => blocked_user) + sign_in_as(create(:moderator_user)) + + visit user_path(blocked_user) + assert_link "Revoke all blocks" + + click_on "Revoke all blocks" + assert_title "Revoking all blocks on #{blocked_user.display_name}" + assert_text "Revoking all blocks on #{blocked_user.display_name}" + assert_unchecked_field "Are you sure you wish to revoke 1 active block?" + assert_button "Revoke!" + end + + test "revoke all link is present and working for moderators when viewed user has multiple active blocks" do blocked_user = create(:user) create(:user_block, :user => blocked_user) + create(:user_block, :user => blocked_user) + create(:user_block, :expired, :user => blocked_user) sign_in_as(create(:moderator_user)) visit user_path(blocked_user) assert_link "Revoke all blocks" - click_link "Revoke all blocks" + click_on "Revoke all blocks" assert_title "Revoking all blocks on #{blocked_user.display_name}" assert_text "Revoking all blocks on #{blocked_user.display_name}" + assert_unchecked_field "Are you sure you wish to revoke 2 active blocks?" + assert_button "Revoke!" end end