summaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
authorJean-Baptiste Barth <jeanbaptiste.barth@gmail.com>2013-05-02 22:57:24 +0000
committerJean-Baptiste Barth <jeanbaptiste.barth@gmail.com>2013-05-02 22:57:24 +0000
commitbc68c1c039409847cb2476fb1f52da7aac510dc5 (patch)
tree3a603a2704d482f00780b9467572b8b5bfce70d0 /test/unit
parent84e455b58359ca247ee98ef109502c2ee343c69a (diff)
downloadredmine-bc68c1c039409847cb2476fb1f52da7aac510dc5.tar.gz
redmine-bc68c1c039409847cb2476fb1f52da7aac510dc5.zip
Add missing unit tests for ApplicationHelper#link_to_if_authorized.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11770 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/helpers/application_helper_test.rb34
1 files changed, 20 insertions, 14 deletions
diff --git a/test/unit/helpers/application_helper_test.rb b/test/unit/helpers/application_helper_test.rb
index a344669b4..067d14dcb 100644
--- a/test/unit/helpers/application_helper_test.rb
+++ b/test/unit/helpers/application_helper_test.rb
@@ -36,23 +36,29 @@ class ApplicationHelperTest < ActionView::TestCase
end
context "#link_to_if_authorized" do
- context "authorized user" do
- should "be tested"
+ context "for authorized user" do
+ 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/actionr',
+ {:controller => 'issues', :action => 'edit', :id => Issue.first.id})
+ assert_match /href/, response
+ end
end
- context "unauthorized user" do
- should "be tested"
+ context "for unauthorized user" do
+ should "display nothing if user isn't authorized" do
+ User.current = User.find_by_login('dlopper')
+ @project = Project.find('private-child')
+ issue = @project.issues.first
+ assert !issue.visible?
+
+ response = link_to_if_authorized('Never displayed',
+ {:controller => 'issues', :action => 'show', :id => issue})
+ assert_nil response
+ end
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
-
end
def test_auto_links