X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/03408b6294e0aa56d46823c1f44d47aaf69e226b..3f2ba044e54c3529c3afc531ab1c18b16c432be8:/test/controllers/notes_controller_test.rb?ds=inline diff --git a/test/controllers/notes_controller_test.rb b/test/controllers/notes_controller_test.rb index dfeec0c52..1ebce60b5 100644 --- a/test/controllers/notes_controller_test.rb +++ b/test/controllers/notes_controller_test.rb @@ -3,7 +3,7 @@ require "test_helper" class NotesControllerTest < ActionController::TestCase def setup # Stub nominatim response for note locations - stub_request(:get, %r{^http://nominatim\.openstreetmap\.org/reverse\?}) + stub_request(:get, %r{^https://nominatim\.openstreetmap\.org/reverse\?}) .to_return(:status => 404) end @@ -303,7 +303,7 @@ class NotesControllerTest < ActionController::TestCase ActionMailer::Base.deliveries.clear - basic_authorization(third_user.email, "test") + basic_authorization third_user.email, "test" assert_difference "NoteComment.count", 1 do assert_difference "ActionMailer::Base.deliveries.size", 2 do @@ -397,7 +397,7 @@ class NotesControllerTest < ActionController::TestCase post :close, :params => { :id => open_note_with_comment.id, :text => "This is a close comment", :format => "json" } assert_response :unauthorized - basic_authorization(user.email, "test") + basic_authorization user.email, "test" post :close, :params => { :id => open_note_with_comment.id, :text => "This is a close comment", :format => "json" } assert_response :success @@ -428,7 +428,7 @@ class NotesControllerTest < ActionController::TestCase post :close assert_response :unauthorized - basic_authorization(create(:user).email, "test") + basic_authorization create(:user).email, "test" post :close assert_response :bad_request @@ -454,7 +454,7 @@ class NotesControllerTest < ActionController::TestCase post :reopen, :params => { :id => closed_note_with_comment.id, :text => "This is a reopen comment", :format => "json" } assert_response :unauthorized - basic_authorization(user.email, "test") + basic_authorization user.email, "test" post :reopen, :params => { :id => closed_note_with_comment.id, :text => "This is a reopen comment", :format => "json" } assert_response :success @@ -487,7 +487,7 @@ class NotesControllerTest < ActionController::TestCase post :reopen, :params => { :id => hidden_note_with_comment.id } assert_response :unauthorized - basic_authorization(create(:user).email, "test") + basic_authorization create(:user).email, "test" post :reopen, :params => { :id => 12345 } assert_response :not_found @@ -606,12 +606,12 @@ class NotesControllerTest < ActionController::TestCase delete :destroy, :params => { :id => open_note_with_comment.id, :text => "This is a hide comment", :format => "json" } assert_response :unauthorized - basic_authorization(user.email, "test") + basic_authorization user.email, "test" delete :destroy, :params => { :id => open_note_with_comment.id, :text => "This is a hide comment", :format => "json" } assert_response :forbidden - basic_authorization(moderator_user.email, "test") + basic_authorization moderator_user.email, "test" delete :destroy, :params => { :id => open_note_with_comment.id, :text => "This is a hide comment", :format => "json" } assert_response :success @@ -625,6 +625,10 @@ class NotesControllerTest < ActionController::TestCase assert_equal "This is a hide comment", js["properties"]["comments"].last["text"] assert_equal moderator_user.display_name, js["properties"]["comments"].last["user"] + get :show, :params => { :id => open_note_with_comment.id, :format => "json" } + assert_response :success + + basic_authorization user.email, "test" get :show, :params => { :id => open_note_with_comment.id, :format => "json" } assert_response :gone end @@ -636,12 +640,12 @@ class NotesControllerTest < ActionController::TestCase delete :destroy, :params => { :id => 12345, :format => "json" } assert_response :unauthorized - basic_authorization(user.email, "test") + basic_authorization user.email, "test" delete :destroy, :params => { :id => 12345, :format => "json" } assert_response :forbidden - basic_authorization(moderator_user.email, "test") + basic_authorization moderator_user.email, "test" delete :destroy, :params => { :id => 12345, :format => "json" } assert_response :not_found @@ -770,11 +774,11 @@ class NotesControllerTest < ActionController::TestCase get :index, :params => { :bbox => "-10,-10,12,12", :format => :json } assert_response :bad_request - assert_equal "text/plain", @response.content_type + assert_equal "application/json", @response.content_type get :index, :params => { :l => "-10", :b => "-10", :r => "12", :t => "12", :format => :json } assert_response :bad_request - assert_equal "text/plain", @response.content_type + assert_equal "application/json", @response.content_type end def test_index_closed @@ -999,4 +1003,20 @@ class NotesControllerTest < ActionController::TestCase get :mine, :params => { :display_name => "non-existent" } assert_response :not_found end + + def test_mine_paged + user = create(:user) + + create_list(:note, 50) do |note| + create(:note_comment, :note => note, :author => user) + end + + get :mine, :params => { :display_name => user.display_name } + assert_response :success + assert_select "table.note_list tr", :count => 11 + + get :mine, :params => { :display_name => user.display_name, :page => 2 } + assert_response :success + assert_select "table.note_list tr", :count => 11 + end end