X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/735a5cf9e25b81d03db80ca4393aa34ea74d612a..899795a82b584d802ea67f8cb01fc0130bf92804:/test/controllers/diary_comments_controller_test.rb diff --git a/test/controllers/diary_comments_controller_test.rb b/test/controllers/diary_comments_controller_test.rb index a06565aa1..3ee9959db 100644 --- a/test/controllers/diary_comments_controller_test.rb +++ b/test/controllers/diary_comments_controller_test.rb @@ -17,12 +17,12 @@ class DiaryCommentsControllerTest < ActionDispatch::IntegrationTest { :controller => "diary_comments", :action => "create", :display_name => "username", :id => "1" } ) assert_routing( - { :path => "/user/username/diary/1/comments/2/hide", :method => :post }, - { :controller => "diary_comments", :action => "hide", :display_name => "username", :id => "1", :comment => "2" } + { :path => "/diary_comments/2/hide", :method => :post }, + { :controller => "diary_comments", :action => "hide", :comment => "2" } ) assert_routing( - { :path => "/user/username/diary/1/comments/2/unhide", :method => :post }, - { :controller => "diary_comments", :action => "unhide", :display_name => "username", :id => "1", :comment => "2" } + { :path => "/diary_comments/2/unhide", :method => :post }, + { :controller => "diary_comments", :action => "unhide", :comment => "2" } ) get "/user/username/diary/comments/1" @@ -36,7 +36,7 @@ class DiaryCommentsControllerTest < ActionDispatch::IntegrationTest deleted_user = create(:user, :deleted) # Test a user with no comments - get diary_comments_path(:display_name => user.display_name) + get user_diary_comments_path(user) assert_response :success assert_template :index assert_select "h4", :html => "No diary comments" @@ -44,7 +44,7 @@ class DiaryCommentsControllerTest < ActionDispatch::IntegrationTest # Test a user with a comment create(:diary_comment, :user => other_user) - get diary_comments_path(:display_name => other_user.display_name) + get user_diary_comments_path(other_user) assert_response :success assert_template :index assert_dom "a[href='#{user_path(other_user)}']", :text => other_user.display_name @@ -53,11 +53,11 @@ class DiaryCommentsControllerTest < ActionDispatch::IntegrationTest end # Test a suspended user - get diary_comments_path(:display_name => suspended_user.display_name) + get user_diary_comments_path(suspended_user) assert_response :not_found # Test a deleted user - get diary_comments_path(:display_name => deleted_user.display_name) + get user_diary_comments_path(deleted_user) assert_response :not_found end @@ -65,10 +65,10 @@ class DiaryCommentsControllerTest < ActionDispatch::IntegrationTest user = create(:user) %w[-1 0 fred].each do |id| - get diary_comments_path(:display_name => user.display_name, :before => id) + get user_diary_comments_path(user, :before => id) assert_redirected_to :controller => :errors, :action => :bad_request - get diary_comments_path(:display_name => user.display_name, :after => id) + get user_diary_comments_path(user, :after => id) assert_redirected_to :controller => :errors, :action => :bad_request end end @@ -104,6 +104,7 @@ class DiaryCommentsControllerTest < ActionDispatch::IntegrationTest end assert_response :success assert_template :new + assert_match(/img-src \* data:;/, @response.headers["Content-Security-Policy-Report-Only"]) # Now try again with the right id assert_difference "ActionMailer::Base.deliveries.size", entry.subscribers.count do @@ -186,19 +187,19 @@ class DiaryCommentsControllerTest < ActionDispatch::IntegrationTest diary_comment = create(:diary_comment, :diary_entry => diary_entry) # Try without logging in - post hide_diary_comment_path(user, diary_entry, diary_comment) + post hide_diary_comment_path(diary_comment) assert_response :forbidden assert DiaryComment.find(diary_comment.id).visible # Now try as a normal user session_for(user) - post hide_diary_comment_path(user, diary_entry, diary_comment) + post hide_diary_comment_path(diary_comment) assert_redirected_to :controller => :errors, :action => :forbidden assert DiaryComment.find(diary_comment.id).visible # Try as a moderator session_for(create(:moderator_user)) - post hide_diary_comment_path(user, diary_entry, diary_comment) + post hide_diary_comment_path(diary_comment) assert_redirected_to diary_entry_path(user, diary_entry) assert_not DiaryComment.find(diary_comment.id).visible @@ -207,7 +208,7 @@ class DiaryCommentsControllerTest < ActionDispatch::IntegrationTest # Finally try as an administrator session_for(create(:administrator_user)) - post hide_diary_comment_path(user, diary_entry, diary_comment) + post hide_diary_comment_path(diary_comment) assert_redirected_to diary_entry_path(user, diary_entry) assert_not DiaryComment.find(diary_comment.id).visible end @@ -218,19 +219,19 @@ class DiaryCommentsControllerTest < ActionDispatch::IntegrationTest diary_comment = create(:diary_comment, :diary_entry => diary_entry, :visible => false) # Try without logging in - post unhide_diary_comment_path(user, diary_entry, diary_comment) + post unhide_diary_comment_path(diary_comment) assert_response :forbidden assert_not DiaryComment.find(diary_comment.id).visible # Now try as a normal user session_for(user) - post unhide_diary_comment_path(user, diary_entry, diary_comment) + post unhide_diary_comment_path(diary_comment) assert_redirected_to :controller => :errors, :action => :forbidden assert_not DiaryComment.find(diary_comment.id).visible # Now try as a moderator session_for(create(:moderator_user)) - post unhide_diary_comment_path(user, diary_entry, diary_comment) + post unhide_diary_comment_path(diary_comment) assert_redirected_to diary_entry_path(user, diary_entry) assert DiaryComment.find(diary_comment.id).visible @@ -239,7 +240,7 @@ class DiaryCommentsControllerTest < ActionDispatch::IntegrationTest # Finally try as an administrator session_for(create(:administrator_user)) - post unhide_diary_comment_path(user, diary_entry, diary_comment) + post unhide_diary_comment_path(diary_comment) assert_redirected_to diary_entry_path(user, diary_entry) assert DiaryComment.find(diary_comment.id).visible end