- def test_comments
- user = create(:user)
- other_user = create(:user)
- suspended_user = create(:user, :suspended)
- deleted_user = create(:user, :deleted)
-
- # Test a user with no comments
- get diary_comments_path(:display_name => user.display_name)
- assert_response :success
- assert_template :comments
- assert_select "h4", :html => "No diary comments"
-
- # Test a user with a comment
- create(:diary_comment, :user => other_user)
-
- get diary_comments_path(:display_name => other_user.display_name)
- assert_response :success
- assert_template :comments
- assert_select "table.table-striped" do
- assert_select "tr", :count => 2 # header and one comment
- end
-
- # Test a suspended user
- get diary_comments_path(:display_name => suspended_user.display_name)
- assert_response :not_found
-
- # Test a deleted user
- get diary_comments_path(:display_name => deleted_user.display_name)
- assert_response :not_found
- end
-