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