]> git.openstreetmap.org Git - rails.git/commitdiff
Declare new block path on resources
authorAnton Khorev <tony29@yandex.ru>
Mon, 23 Dec 2024 21:58:57 +0000 (00:58 +0300)
committerAnton Khorev <tony29@yandex.ru>
Tue, 24 Dec 2024 03:44:35 +0000 (06:44 +0300)
config/routes.rb
test/controllers/user_blocks_controller_test.rb
test/controllers/users_controller_test.rb

index 0e00da9e3b4f0555b28fd1c06b747b272bf0d5f9..ccc32c7733b904dbbff1f97f5267f2ae47043d32 100644 (file)
@@ -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
index fee8f4cb38a1f520279f9beefeb25231599fd393..ff789e7aacd4f4829cfb18e9c24904b54694efa4 100644 (file)
@@ -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" }
     )
 
index 732745539a6e3945a985332b766ae0b2c2cd9258..ba1af9509e0fbfaff740a279668f9aa4d247976c 100644 (file)
@@ -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