]> source.dussan.org Git - redmine.git/commitdiff
Constraints *_all attachments routes to actually supported values of container_type...
authorGo MAEDA <maeda@farend.jp>
Thu, 20 Oct 2022 04:13:21 +0000 (04:13 +0000)
committerGo MAEDA <maeda@farend.jp>
Thu, 20 Oct 2022 04:13:21 +0000 (04:13 +0000)
Patch by  Jens Krämer.

git-svn-id: https://svn.redmine.org/redmine/trunk@21906 e93f8b46-1217-0410-a6f0-8f06a7374b81

config/routes.rb
test/functional/attachments_controller_test.rb

index fa65b4417dc9286fed5a9f6ff80741cf57ac4f40..2a8e24c0a0bd2526514168de14c282dbb622e708 100644 (file)
@@ -317,9 +317,11 @@ Rails.application.routes.draw do
   get 'attachments/download/:id', :to => 'attachments#download', :id => /\d+/
   get 'attachments/thumbnail/:id(/:size)', :to => 'attachments#thumbnail', :id => /\d+/, :size => /\d+/, :as => 'thumbnail'
   resources :attachments, :only => [:show, :update, :destroy]
-  get 'attachments/:object_type/:object_id/edit', :to => 'attachments#edit_all', :as => :object_attachments_edit
-  patch 'attachments/:object_type/:object_id', :to => 'attachments#update_all', :as => :object_attachments
-  get 'attachments/:object_type/:object_id/download', :to => 'attachments#download_all', :as => :object_attachments_download
+  constraints object_type: /(issues|versions|news|messages|wiki_pages|projects|documents|journals)/ do
+    get 'attachments/:object_type/:object_id/edit', :to => 'attachments#edit_all', :as => :object_attachments_edit
+    patch 'attachments/:object_type/:object_id', :to => 'attachments#update_all', :as => :object_attachments
+    get 'attachments/:object_type/:object_id/download', :to => 'attachments#download_all', :as => :object_attachments_download
+  end
 
   resources :groups do
     resources :memberships, :controller => 'principal_memberships'
index 71c54a774d51cb691a061144ff251f64deb47d12..4dbe3ce6e976decba7cc0dc29dc3292825fd3a1b 100644 (file)
@@ -491,17 +491,6 @@ class AttachmentsControllerTest < Redmine::ControllerTest
     assert_select 'h2 a', :text => "Feature request #2"
   end
 
-  def test_edit_all_with_invalid_container_class_should_return_404
-    get(
-      :edit_all,
-      :params => {
-        :object_type => 'nuggets',
-        :object_id => '3'
-      }
-    )
-    assert_response 404
-  end
-
   def test_edit_all_with_invalid_object_should_return_404
     get(
       :edit_all,