X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/44312c221bf79db6d0108803ba32f396befffca6..5add2d7e1d1d365e80d1d4ef417ff249ca7f35c0:/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 94b706975..d13a50163 100644 --- a/test/controllers/diary_entries_controller_test.rb +++ b/test/controllers/diary_entries_controller_test.rb @@ -53,10 +53,6 @@ class DiaryEntriesControllerTest < ActionDispatch::IntegrationTest { :path => "/user/username/diary/comments", :method => :get }, { :controller => "diary_entries", :action => "comments", :display_name => "username" } ) - assert_routing( - { :path => "/user/username/diary/comments/1", :method => :get }, - { :controller => "diary_entries", :action => "comments", :display_name => "username", :page => "1" } - ) assert_routing( { :path => "/diary/new", :method => :get }, @@ -114,6 +110,9 @@ class DiaryEntriesControllerTest < ActionDispatch::IntegrationTest { :path => "/user/username/diary/1/unsubscribe", :method => :post }, { :controller => "diary_entries", :action => "unsubscribe", :display_name => "username", :id => "1" } ) + + get "/user/username/diary/comments/1" + assert_redirected_to "/user/username/diary/comments" end def test_new_no_login @@ -591,6 +590,17 @@ class DiaryEntriesControllerTest < ActionDispatch::IntegrationTest assert_select "li.page-item.disabled span.page-link", :text => "Newer Entries", :count => 1 end + def test_index_invalid_paged + # Try some invalid paged accesses + %w[-1 0 fred].each do |id| + get diary_entries_path(:before => id) + assert_redirected_to :controller => :errors, :action => :bad_request + + get diary_entries_path(:after => id) + assert_redirected_to :controller => :errors, :action => :bad_request + end + end + def test_rss create(:language, :code => "de") create(:diary_entry, :language_code => "en") @@ -900,6 +910,18 @@ class DiaryEntriesControllerTest < ActionDispatch::IntegrationTest assert_response :not_found end + def test_comments_invalid_paged + user = create(:user) + + %w[-1 0 fred].each do |id| + get diary_comments_path(:display_name => user.display_name, :before => id) + assert_redirected_to :controller => :errors, :action => :bad_request + + get diary_comments_path(:display_name => user.display_name, :after => id) + assert_redirected_to :controller => :errors, :action => :bad_request + end + end + def test_subscribe_page user = create(:user) other_user = create(:user)