From 4f05b6a8accae4877f81e617262a52cf0428cf8f Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Tue, 15 Oct 2013 18:24:51 +0100 Subject: [PATCH] Add tests for diary_entry#comments --- .../functional/diary_entry_controller_test.rb | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/functional/diary_entry_controller_test.rb b/test/functional/diary_entry_controller_test.rb index cc13cb675..be4dbe87a 100644 --- a/test/functional/diary_entry_controller_test.rb +++ b/test/functional/diary_entry_controller_test.rb @@ -476,4 +476,30 @@ class DiaryEntryControllerTest < ActionController::TestCase assert_redirected_to :action => :view, :display_name => users(:normal_user).display_name, :id => diary_entries(:normal_user_geo_entry).id assert_equal false, DiaryComment.find(diary_comments(:comment_for_geo_post).id).visible end + + def test_comments + # Test a user with no comments + get :comments, :display_name => users(:normal_user).display_name + assert_response :success + assert_template :comments + assert_select "table.messages" do + assert_select "tr", :count => 1 # header, no comments + end + + # Test a user with a comment + get :comments, :display_name => users(:public_user).display_name + assert_response :success + assert_template :comments + assert_select "table.messages" do + assert_select "tr", :count => 2 # header and one comment + end + + # Test a suspended user + get :comments, :display_name => users(:suspended_user).display_name + assert_response :not_found + + # Test a deleted user + get :comments, :display_name => users(:deleted_user).display_name + assert_response :not_found + end end -- 2.43.2