diff test/unit/helpers/application_helper_test.rb @ 22:40f7cfd4df19

* Update to SVN trunk rev 4173
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Fri, 24 Sep 2010 14:06:04 +0100
parents 1d32c0a0efbf
children 94944d00e43c
line wrap: on
line diff
--- a/test/unit/helpers/application_helper_test.rb	Wed Aug 25 16:30:24 2010 +0100
+++ b/test/unit/helpers/application_helper_test.rb	Fri Sep 24 14:06:04 2010 +0100
@@ -17,10 +17,7 @@
 
 require File.dirname(__FILE__) + '/../../test_helper'
 
-class ApplicationHelperTest < HelperTestCase
-  include ApplicationHelper
-  include ActionView::Helpers::TextHelper
-  include ActionView::Helpers::DateHelper
+class ApplicationHelperTest < ActionView::TestCase
   
   fixtures :projects, :roles, :enabled_modules, :users,
                       :repositories, :changesets, 
@@ -33,6 +30,35 @@
   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 = {
@@ -575,7 +601,7 @@
     
     # turn off avatars
     Setting.gravatar_enabled = '0'
-    assert_nil avatar(User.find_by_mail('jsmith@somenet.foo'))
+    assert_equal '', avatar(User.find_by_mail('jsmith@somenet.foo'))
   end
   
   def test_link_to_user