From: Tom Hughes Date: Tue, 15 Oct 2013 17:24:51 +0000 (+0100) Subject: Add tests for diary_entry#comments X-Git-Tag: live~4657 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/4f05b6a8accae4877f81e617262a52cf0428cf8f Add tests for diary_entry#comments --- 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