X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/94b59f440321846760d430fee378f05a6a2803ee..9f280be82b251522bc8e6a28b24d2e44988bf680:/test/controllers/notes_controller_test.rb diff --git a/test/controllers/notes_controller_test.rb b/test/controllers/notes_controller_test.rb index 82821de6c..1450aced8 100644 --- a/test/controllers/notes_controller_test.rb +++ b/test/controllers/notes_controller_test.rb @@ -1,7 +1,8 @@ require "test_helper" -class NotesControllerTest < ActionController::TestCase +class NotesControllerTest < ActionDispatch::IntegrationTest def setup + super # Stub nominatim response for note locations stub_request(:get, %r{^https://nominatim\.openstreetmap\.org/reverse\?}) .to_return(:status => 404) @@ -12,11 +13,11 @@ class NotesControllerTest < ActionController::TestCase def test_routes assert_routing( { :path => "/user/username/notes", :method => :get }, - { :controller => "notes", :action => "mine", :display_name => "username" } + { :controller => "notes", :action => "index", :display_name => "username" } ) end - def test_mine_success + def test_index_success first_user = create(:user) second_user = create(:user) moderator_user = create(:moderator_user) @@ -32,43 +33,43 @@ class NotesControllerTest < ActionController::TestCase end # Note that the table rows include a header row - get :mine, :params => { :display_name => first_user.display_name } + get user_notes_path(:display_name => first_user.display_name) assert_response :success assert_select "table.note_list tr", :count => 2 - get :mine, :params => { :display_name => second_user.display_name } + get user_notes_path(:display_name => second_user.display_name) assert_response :success assert_select "table.note_list tr", :count => 2 - get :mine, :params => { :display_name => "non-existent" } + get user_notes_path(:display_name => "non-existent") assert_response :not_found - session[:user] = moderator_user.id + session_for(moderator_user) - get :mine, :params => { :display_name => first_user.display_name } + get user_notes_path(:display_name => first_user.display_name) assert_response :success assert_select "table.note_list tr", :count => 2 - get :mine, :params => { :display_name => second_user.display_name } + get user_notes_path(:display_name => second_user.display_name) assert_response :success assert_select "table.note_list tr", :count => 3 - get :mine, :params => { :display_name => "non-existent" } + get user_notes_path(:display_name => "non-existent") assert_response :not_found end - def test_mine_paged + def test_index_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 } + get user_notes_path(: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 } + get user_notes_path(:display_name => user.display_name, :page => 2) assert_response :success assert_select "table.note_list tr", :count => 11 end