X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/0e78061cdba5cfb3f299f57b7643d2b396ee235b..27e9965dd2d7476ea8242c8c646976b698cc9e8e:/test/controllers/diary_entries_controller_test.rb diff --git a/test/controllers/diary_entries_controller_test.rb b/test/controllers/diary_entries_controller_test.rb index 255b43997..1c0c623c8 100644 --- a/test/controllers/diary_entries_controller_test.rb +++ b/test/controllers/diary_entries_controller_test.rb @@ -273,7 +273,7 @@ class DiaryEntriesControllerTest < ActionDispatch::IntegrationTest get edit_diary_entry_path(:display_name => entry.user.display_name, :id => 9999) assert_response :not_found assert_select "div.content-heading", :count => 1 do - assert_select "h2", :text => "No entry with the id: 9999", :count => 1 + assert_select "h1", :text => "No entry with the id: 9999", :count => 1 end # Now pass the id, and check that you can edit it, when using the same @@ -314,18 +314,17 @@ class DiaryEntriesControllerTest < ActionDispatch::IntegrationTest get diary_entry_path(:display_name => entry.user.display_name, :id => entry) assert_response :success assert_template "show" - assert_select "title", :text => /Users' diaries | /, :count => 1 + assert_select "title", :text => /Users' Diaries | /, :count => 1 assert_select "div.content-heading", :count => 1 do - assert_select "h2", :text => /#{entry.user.display_name}'s diary/, :count => 1 + assert_select "h1", :text => /#{entry.user.display_name}'s Diary/, :count => 1 end assert_select "div#content", :count => 1 do - assert_select "div.post_heading", :text => /#{new_title}/, :count => 1 + assert_select "h2", :text => /#{new_title}/, :count => 1 # This next line won't work if the text has been run through the htmlize function # due to formatting that could be introduced assert_select "p", :text => /#{new_body}/, :count => 1 assert_select "abbr[class='geo'][title='#{number_with_precision(new_latitude, :precision => 4)}; #{number_with_precision(new_longitude, :precision => 4)}']", :count => 1 # As we're not logged in, check that you cannot edit - # print @response.body assert_select "a[href='/user/#{ERB::Util.u(entry.user.display_name)}/diary/#{entry.id}/edit']", :text => "Edit this entry", :count => 1 end @@ -334,12 +333,12 @@ class DiaryEntriesControllerTest < ActionDispatch::IntegrationTest get diary_entry_path(:display_name => entry.user.display_name, :id => entry) assert_response :success assert_template "show" - assert_select "title", :text => /Users' diaries | /, :count => 1 + assert_select "title", :text => /Users' Diaries | /, :count => 1 assert_select "div.content-heading", :count => 1 do - assert_select "h2", :text => /#{entry.user.display_name}'s diary/, :count => 1 + assert_select "h1", :text => /#{entry.user.display_name}'s Diary/, :count => 1 end assert_select "div#content", :count => 1 do - assert_select "div.post_heading", :text => /#{new_title}/, :count => 1 + assert_select "h2", :text => /#{new_title}/, :count => 1 # This next line won't work if the text has been run through the htmlize function # due to formatting that could be introduced assert_select "p", :text => /#{new_body}/, :count => 1 @@ -374,7 +373,7 @@ class DiaryEntriesControllerTest < ActionDispatch::IntegrationTest post comment_diary_entry_path(:display_name => entry.user.display_name, :id => 9999) assert_response :not_found assert_select "div.content-heading", :count => 1 do - assert_select "h2", :text => "No entry with the id: 9999", :count => 1 + assert_select "h1", :text => "No entry with the id: 9999", :count => 1 end # Now try an invalid comment with an empty body @@ -670,6 +669,11 @@ class DiaryEntriesControllerTest < ActionDispatch::IntegrationTest assert_response :success assert_template :show + # Try a non-integer ID + assert_raise ActionController::RoutingError do + get "/user/#{CGI.escapeURIComponent(user.display_name)}/diary/#{diary_entry.id})" + end + # Try a deleted entry diary_entry_deleted = create(:diary_entry, :user => user, :visible => false) get diary_entry_path(:display_name => user.display_name, :id => diary_entry_deleted)