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
This commit is contained in:
parent
84e455b583
commit
bc68c1c039
@ -36,23 +36,29 @@ class ApplicationHelperTest < ActionView::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
context "#link_to_if_authorized" do
|
context "#link_to_if_authorized" do
|
||||||
context "authorized user" do
|
context "for authorized user" do
|
||||||
should "be tested"
|
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
|
end
|
||||||
|
|
||||||
context "unauthorized user" do
|
context "for unauthorized user" do
|
||||||
should "be tested"
|
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
|
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
|
end
|
||||||
|
|
||||||
def test_auto_links
|
def test_auto_links
|
||||||
|
Loading…
x
Reference in New Issue
Block a user