- assert_template "revoke"
- b = UserBlock.find(active_block.id)
- assert_operator b.ends_at - Time.now.utc, :>, 100
-
- # Check that revoking a block works using POST
- post revoke_user_block_path(:id => active_block, :confirm => true)
- assert_redirected_to user_block_path(active_block)
- b = UserBlock.find(active_block.id)
- assert_in_delta Time.now.utc, b.ends_at, 1
-
- # We should get an error if the block doesn't exist
- get revoke_user_block_path(:id => 99999)
- assert_response :not_found
- assert_template "not_found"
- assert_select "p", "Sorry, the user block with ID 99999 could not be found."
- end
-
- ##
- # test the revoke all page
- def test_revoke_all_page
- blocked_user = create(:user)
- create(:user_block, :user => blocked_user)
-
- # Asking for the revoke all blocks page with a bogus user name should fail
- get user_blocks_on_path("non_existent_user")
- assert_response :not_found
-
- # Check that the revoke all blocks page requires us to login
- get revoke_all_user_blocks_path(blocked_user)
- assert_redirected_to login_path(:referer => revoke_all_user_blocks_path(blocked_user))
-
- # Login as a normal user
- session_for(create(:user))
-
- # Check that normal users can't load the revoke all blocks page
- get revoke_all_user_blocks_path(blocked_user)
- assert_redirected_to :controller => "errors", :action => "forbidden"
-
- # Login as a moderator
- session_for(create(:moderator_user))