expired_block = create(:user_block, :expired)
revoked_block = create(:user_block, :revoked)
expired_block = create(:user_block, :expired)
revoked_block = create(:user_block, :revoked)
assert_response :success
assert_select "table#block_list", :count => 1 do
assert_select "tr", :count => 21
end
assert_response :success
assert_select "table#block_list", :count => 1 do
assert_select "tr", :count => 21
end
assert_response :success
assert_select "table#block_list", :count => 1 do
assert_select "tr", :count => 21
assert_response :success
assert_select "table#block_list", :count => 1 do
assert_select "tr", :count => 21
expired_block = create(:user_block, :expired)
revoked_block = create(:user_block, :revoked)
expired_block = create(:user_block, :expired)
revoked_block = create(:user_block, :revoked)
assert_response :not_found
assert_template "not_found"
assert_select "p", "Sorry, the user block with ID 99999 could not be found."
# Viewing an expired block should work
assert_response :not_found
assert_template "not_found"
assert_select "p", "Sorry, the user block with ID 99999 could not be found."
# Viewing an expired block should work
assert_response :redirect
assert_redirected_to :controller => "errors", :action => "forbidden"
# Login as a moderator
assert_response :redirect
assert_redirected_to :controller => "errors", :action => "forbidden"
# Login as a moderator
assert_response :success
assert_select "form#new_user_block", :count => 1 do
assert_select "textarea#user_block_reason", :count => 1
assert_response :success
assert_select "form#new_user_block", :count => 1 do
assert_select "textarea#user_block_reason", :count => 1
- # We should get an error if no user is specified
- get :new
- assert_response :not_found
- assert_template "users/no_such_user"
- assert_select "h1", "The user does not exist"
-
assert_response :not_found
assert_template "users/no_such_user"
assert_select "h1", "The user non_existent_user does not exist"
assert_response :not_found
assert_template "users/no_such_user"
assert_select "h1", "The user non_existent_user does not exist"
assert_response :redirect
assert_redirected_to :controller => "errors", :action => "forbidden"
# Login as a moderator
assert_response :redirect
assert_redirected_to :controller => "errors", :action => "forbidden"
# Login as a moderator
assert_response :success
assert_select "form#edit_user_block_#{active_block.id}", :count => 1 do
assert_select "textarea#user_block_reason", :count => 1
assert_response :success
assert_select "form#edit_user_block_#{active_block.id}", :count => 1 do
assert_select "textarea#user_block_reason", :count => 1
assert_response :not_found
assert_template "not_found"
assert_select "p", "Sorry, the user block with ID 99999 could not be found."
assert_response :not_found
assert_template "not_found"
assert_select "p", "Sorry, the user block with ID 99999 could not be found."
moderator_user = create(:moderator_user)
# Not logged in yet, so creating a block should fail
moderator_user = create(:moderator_user)
# Not logged in yet, so creating a block should fail
assert_response :redirect
assert_redirected_to :controller => "errors", :action => "forbidden"
# Login as a moderator
assert_response :redirect
assert_redirected_to :controller => "errors", :action => "forbidden"
# Login as a moderator
- post :create,
- :params => { :display_name => target_user.display_name,
- :user_block_period => "99" }
+ post user_blocks_path(:display_name => target_user.display_name,
+ :user_block_period => "99")
end
assert_redirected_to new_user_block_path(:display_name => target_user.display_name)
assert_equal "The blocking period must be one of the values selectable in the drop-down list.", flash[:error]
# Check that creating a block works
assert_difference "UserBlock.count", 1 do
end
assert_redirected_to new_user_block_path(:display_name => target_user.display_name)
assert_equal "The blocking period must be one of the values selectable in the drop-down list.", flash[:error]
# Check that creating a block works
assert_difference "UserBlock.count", 1 do
- post :create,
- :params => { :display_name => target_user.display_name,
- :user_block_period => "12",
- :user_block => { :needs_view => false, :reason => "Vandalism" } }
+ post user_blocks_path(:display_name => target_user.display_name,
+ :user_block_period => "12",
+ :user_block => { :needs_view => false, :reason => "Vandalism" })
assert_equal moderator_user.id, b.creator_id
# We should get an error if no user is specified
assert_equal moderator_user.id, b.creator_id
# We should get an error if no user is specified
assert_response :not_found
assert_template "users/no_such_user"
assert_select "h1", "The user does not exist"
# We should get an error if the user doesn't exist
assert_response :not_found
assert_template "users/no_such_user"
assert_select "h1", "The user does not exist"
# We should get an error if the user doesn't exist
assert_response :not_found
assert_template "users/no_such_user"
assert_select "h1", "The user non_existent_user does not exist"
assert_response :not_found
assert_template "users/no_such_user"
assert_select "h1", "The user non_existent_user does not exist"
active_block = create(:user_block, :creator => moderator_user)
# Not logged in yet, so updating a block should fail
active_block = create(:user_block, :creator => moderator_user)
# Not logged in yet, so updating a block should fail
assert_response :redirect
assert_redirected_to :controller => "errors", :action => "forbidden"
# Login as the wrong moderator
assert_response :redirect
assert_redirected_to :controller => "errors", :action => "forbidden"
# Login as the wrong moderator
# Check that only the person who created a block can update it
assert_no_difference "UserBlock.count" do
# Check that only the person who created a block can update it
assert_no_difference "UserBlock.count" do
- put :update,
- :params => { :id => active_block.id,
- :user_block_period => "12",
- :user_block => { :needs_view => true, :reason => "Vandalism" } }
+ put user_block_path(:id => active_block,
+ :user_block_period => "12",
+ :user_block => { :needs_view => true, :reason => "Vandalism" })
end
assert_redirected_to edit_user_block_path(active_block)
assert_equal "Only the moderator who created this block can edit it.", flash[:error]
# Login as the correct moderator
end
assert_redirected_to edit_user_block_path(active_block)
assert_equal "Only the moderator who created this block can edit it.", flash[:error]
# Login as the correct moderator
end
assert_redirected_to edit_user_block_path(active_block)
assert_equal "The blocking period must be one of the values selectable in the drop-down list.", flash[:error]
# Check that updating a block works
assert_no_difference "UserBlock.count" do
end
assert_redirected_to edit_user_block_path(active_block)
assert_equal "The blocking period must be one of the values selectable in the drop-down list.", flash[:error]
# Check that updating a block works
assert_no_difference "UserBlock.count" do
- put :update,
- :params => { :id => active_block.id,
- :user_block_period => "12",
- :user_block => { :needs_view => true, :reason => "Vandalism" } }
+ put user_block_path(:id => active_block,
+ :user_block_period => "12",
+ :user_block => { :needs_view => true, :reason => "Vandalism" })
end
assert_redirected_to user_block_path(active_block)
assert_equal "Block updated.", flash[:notice]
end
assert_redirected_to user_block_path(active_block)
assert_equal "Block updated.", flash[:notice]
assert_response :not_found
assert_template "not_found"
assert_select "p", "Sorry, the user block with ID 99999 could not be found."
assert_response :not_found
assert_template "not_found"
assert_select "p", "Sorry, the user block with ID 99999 could not be found."
- get :revoke, :params => { :id => active_block.id }
- assert_redirected_to login_path(:referer => revoke_user_block_path(:id => active_block.id))
+ get revoke_user_block_path(:id => active_block)
+ assert_redirected_to login_path(:referer => revoke_user_block_path(:id => active_block))
assert_response :redirect
assert_redirected_to :controller => "errors", :action => "forbidden"
# Login as a moderator
assert_response :redirect
assert_redirected_to :controller => "errors", :action => "forbidden"
# Login as a moderator
assert_redirected_to user_block_path(active_block)
b = UserBlock.find(active_block.id)
assert_in_delta Time.now, b.ends_at, 1
assert_redirected_to user_block_path(active_block)
b = UserBlock.find(active_block.id)
assert_in_delta Time.now, b.ends_at, 1
assert_response :not_found
assert_template "not_found"
assert_select "p", "Sorry, the user block with ID 99999 could not be found."
assert_response :not_found
assert_template "not_found"
assert_select "p", "Sorry, the user block with ID 99999 could not be found."
revoked_block = create(:user_block, :revoked, :user => blocked_user)
expired_block = create(:user_block, :expired, :user => unblocked_user)
revoked_block = create(:user_block, :revoked, :user => blocked_user)
expired_block = create(:user_block, :expired, :user => unblocked_user)
assert_response :not_found
assert_template "users/no_such_user"
assert_select "h1", "The user non_existent_user does not exist"
# Check the list of blocks for a user that has never been blocked
assert_response :not_found
assert_template "users/no_such_user"
assert_select "h1", "The user non_existent_user does not exist"
# Check the list of blocks for a user that has never been blocked
assert_response :success
assert_select "table#block_list", false
assert_select "p", "#{normal_user.display_name} has not been blocked yet."
# Check the list of blocks for a user that is currently blocked
assert_response :success
assert_select "table#block_list", false
assert_select "p", "#{normal_user.display_name} has not been blocked yet."
# Check the list of blocks for a user that is currently blocked
assert_response :success
assert_select "table#block_list", :count => 1 do
assert_select "tr", :count => 21
end
assert_response :success
assert_select "table#block_list", :count => 1 do
assert_select "tr", :count => 21
end
assert_response :success
assert_select "table#block_list", :count => 1 do
assert_select "tr", :count => 21
assert_response :success
assert_select "table#block_list", :count => 1 do
assert_select "tr", :count => 21
expired_block = create(:user_block, :expired, :creator => second_moderator_user)
revoked_block = create(:user_block, :revoked, :creator => second_moderator_user)
expired_block = create(:user_block, :expired, :creator => second_moderator_user)
revoked_block = create(:user_block, :revoked, :creator => second_moderator_user)
assert_response :not_found
assert_template "users/no_such_user"
assert_select "h1", "The user non_existent_user does not exist"
# Check the list of blocks given by one moderator
assert_response :not_found
assert_template "users/no_such_user"
assert_select "h1", "The user non_existent_user does not exist"
# Check the list of blocks given by one moderator
assert_response :success
assert_select "table#block_list", false
assert_select "p", "#{normal_user.display_name} has not made any blocks yet."
assert_response :success
assert_select "table#block_list", false
assert_select "p", "#{normal_user.display_name} has not made any blocks yet."
user = create(:moderator_user)
create_list(:user_block, 50, :creator => user)
user = create(:moderator_user)
create_list(:user_block, 50, :creator => user)
assert_response :success
assert_select "table#block_list", :count => 1 do
assert_select "tr", :count => 21
end
assert_response :success
assert_select "table#block_list", :count => 1 do
assert_select "tr", :count => 21
end
assert_response :success
assert_select "table#block_list", :count => 1 do
assert_select "tr", :count => 21
assert_response :success
assert_select "table#block_list", :count => 1 do
assert_select "tr", :count => 21