From: Anton Khorev Date: Mon, 23 Dec 2024 21:58:57 +0000 (+0300) Subject: Declare new block path on resources X-Git-Tag: live~11^2~4 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/3b0748831aa249b2beeb593641dfec06f980b6c8 Declare new block path on resources --- diff --git a/config/routes.rb b/config/routes.rb index 0e00da9e3..ccc32c773 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -332,8 +332,7 @@ OpenStreetMap::Application.routes.draw do # banning pages get "/user/:display_name/blocks" => "user_blocks#blocks_on", :as => "user_blocks_on" get "/user/:display_name/blocks_by" => "user_blocks#blocks_by", :as => "user_blocks_by" - get "/blocks/new/:display_name" => "user_blocks#new", :as => "new_user_block" - resources :user_blocks, :except => :new + resources :user_blocks, :path_names => { :new => "new/:display_name" } match "/user/:display_name/blocks/revoke_all" => "user_blocks#revoke_all", :via => [:get, :post], :as => "revoke_all_user_blocks" # issues and reports diff --git a/test/controllers/user_blocks_controller_test.rb b/test/controllers/user_blocks_controller_test.rb index fee8f4cb3..ff789e7aa 100644 --- a/test/controllers/user_blocks_controller_test.rb +++ b/test/controllers/user_blocks_controller_test.rb @@ -5,7 +5,7 @@ class UserBlocksControllerTest < ActionDispatch::IntegrationTest # test all routes which lead to this controller def test_routes assert_routing( - { :path => "/blocks/new/username", :method => :get }, + { :path => "/user_blocks/new/username", :method => :get }, { :controller => "user_blocks", :action => "new", :display_name => "username" } ) diff --git a/test/controllers/users_controller_test.rb b/test/controllers/users_controller_test.rb index 732745539..ba1af9509 100644 --- a/test/controllers/users_controller_test.rb +++ b/test/controllers/users_controller_test.rb @@ -305,7 +305,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/account']", 0 assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/blocks']", 0 assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/blocks_by']", 0 - assert_select "a[href='/blocks/new/#{ERB::Util.u(user.display_name)}']", 0 + assert_select "a[href='/user_blocks/new/#{ERB::Util.u(user.display_name)}']", 0 end # Test a user who has been blocked @@ -321,7 +321,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest assert_select "a[href='/user/#{ERB::Util.u(blocked_user.display_name)}/account']", 0 assert_select "a[href='/user/#{ERB::Util.u(blocked_user.display_name)}/blocks']", 1 assert_select "a[href='/user/#{ERB::Util.u(blocked_user.display_name)}/blocks_by']", 0 - assert_select "a[href='/blocks/new/#{ERB::Util.u(blocked_user.display_name)}']", 0 + assert_select "a[href='/user_blocks/new/#{ERB::Util.u(blocked_user.display_name)}']", 0 end # Test a moderator who has applied blocks @@ -337,7 +337,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest assert_select "a[href='/user/#{ERB::Util.u(moderator_user.display_name)}/account']", 0 assert_select "a[href='/user/#{ERB::Util.u(moderator_user.display_name)}/blocks']", 0 assert_select "a[href='/user/#{ERB::Util.u(moderator_user.display_name)}/blocks_by']", 1 - assert_select "a[href='/blocks/new/#{ERB::Util.u(moderator_user.display_name)}']", 0 + assert_select "a[href='/user_blocks/new/#{ERB::Util.u(moderator_user.display_name)}']", 0 end # Login as a normal user @@ -354,7 +354,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest assert_select "a[href='/account/edit']", 1 assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/blocks']", 0 assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/blocks_by']", 0 - assert_select "a[href='/blocks/new/#{ERB::Util.u(user.display_name)}']", 0 + assert_select "a[href='/user_blocks/new/#{ERB::Util.u(user.display_name)}']", 0 assert_select "a[href='/api/0.6/user/#{ERB::Util.u(user.id)}']", 0 end @@ -372,7 +372,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest assert_select "a[href='/account/edit']", 0 assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/blocks']", 0 assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/blocks_by']", 0 - assert_select "a[href='/blocks/new/#{ERB::Util.u(user.display_name)}']", 1 + assert_select "a[href='/user_blocks/new/#{ERB::Util.u(user.display_name)}']", 1 assert_select "a[href='/api/0.6/user/#{ERB::Util.u(user.id)}']", 1 end end