diff options
author | Eric Davis <edavis@littlestreamsoftware.com> | 2010-09-06 00:26:08 +0000 |
---|---|---|
committer | Eric Davis <edavis@littlestreamsoftware.com> | 2010-09-06 00:26:08 +0000 |
commit | d771fa92892a8835168856b8a148d05b550440dc (patch) | |
tree | 062f20ace1e13cf3ac7b8377a75d7f07b7898faf /test/unit/helpers | |
parent | 563c879e44237eff4846ef44ae93ec43c27ba47f (diff) | |
download | redmine-d771fa92892a8835168856b8a148d05b550440dc.tar.gz redmine-d771fa92892a8835168856b8a148d05b550440dc.zip |
Change link_to_if_authorized to allow url paths. (Fixes #6195)
Both url paths (/issues/1234) and params hashes (:controller => 'issues')
are now supported by link_to_if_authorized. The authorize_for method
requires a controller/action pair so urls need to be parsed against the
routes to find their controller/action.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4064 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/helpers')
-rw-r--r-- | test/unit/helpers/application_helper_test.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/unit/helpers/application_helper_test.rb b/test/unit/helpers/application_helper_test.rb index 533311b1a..1936a981b 100644 --- a/test/unit/helpers/application_helper_test.rb +++ b/test/unit/helpers/application_helper_test.rb @@ -30,6 +30,35 @@ class ApplicationHelperTest < ActionView::TestCase def setup super end + + context "#link_to_if_authorized" do + context "authorized user" do + should "be tested" + end + + context "unauthorized user" do + should "be tested" + end + + should "allow using the :controller and :action 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 controller/action", + {:controller => 'issues', :action => 'edit', :id => Issue.first.id}) + 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 to_test = { |