]> source.dussan.org Git - redmine.git/commitdiff
Revert part of r4064.
authorEric Davis <edavis@littlestreamsoftware.com>
Fri, 15 Oct 2010 23:11:00 +0000 (23:11 +0000)
committerEric Davis <edavis@littlestreamsoftware.com>
Fri, 15 Oct 2010 23:11:00 +0000 (23:11 +0000)
Having link_to_if_authorized support urls has too many edge cases and isn't
working with sub-uris.  #6195 #6513

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4257 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/application_helper.rb
test/unit/helpers/application_helper_test.rb

index 6ba40eb451150d6055554e2b61d2b5ca3ec17a9e..e2255da30946d3cf90a374f50161c76057fd8471 100644 (file)
@@ -34,25 +34,11 @@ module ApplicationHelper
   # Display a link if user is authorized
   #
   # @param [String] name Anchor text (passed to link_to)
-  # @param [Hash, String] options Hash params or url for the link target (passed to link_to).
-  #        This will checked by authorize_for to see if the user is authorized
+  # @param [Hash] options Hash params. This will checked by authorize_for to see if the user is authorized
   # @param [optional, Hash] html_options Options passed to link_to
   # @param [optional, Hash] parameters_for_method_reference Extra parameters for link_to
   def link_to_if_authorized(name, options = {}, html_options = nil, *parameters_for_method_reference)
-    if options.is_a?(String)
-      begin
-        route = ActionController::Routing::Routes.recognize_path(options.gsub(/\?.*/,''), :method => options[:method] || :get)
-        link_controller = route[:controller]
-        link_action = route[:action]
-      rescue ActionController::RoutingError # Parse failed, not a route
-        link_controller, link_action = nil, nil
-      end
-    else
-      link_controller = options[:controller] || params[:controller]
-      link_action = options[:action]
-    end
-
-    link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for(link_controller, link_action)
+    link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for(options[:controller] || params[:controller], options[:action])
   end
 
   # Display a link to remote if user is authorized
index 2906ec6e42d0941d6b1a3b5b39d3e1f46a848116..d44bc00455fda2955318b0373af73e336399507d 100644 (file)
@@ -49,15 +49,6 @@ class ApplicationHelperTest < ActionView::TestCase
       assert_match /href/, response
     end
     
-    should "allow using the url for the target link" do
-      User.current = User.find_by_login('admin')
-
-      @project = Issue.first.project # Used by helper
-      response = link_to_if_authorized("By url",
-                                       new_issue_move_path(:id => Issue.first.id))
-      assert_match /href/, response
-    end
-
   end
   
   def test_auto_links