comparison 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
comparison
equal deleted inserted replaced
14:1d32c0a0efbf 22:40f7cfd4df19
15 # along with this program; if not, write to the Free Software 15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 require File.dirname(__FILE__) + '/../../test_helper' 18 require File.dirname(__FILE__) + '/../../test_helper'
19 19
20 class ApplicationHelperTest < HelperTestCase 20 class ApplicationHelperTest < ActionView::TestCase
21 include ApplicationHelper
22 include ActionView::Helpers::TextHelper
23 include ActionView::Helpers::DateHelper
24 21
25 fixtures :projects, :roles, :enabled_modules, :users, 22 fixtures :projects, :roles, :enabled_modules, :users,
26 :repositories, :changesets, 23 :repositories, :changesets,
27 :trackers, :issue_statuses, :issues, :versions, :documents, 24 :trackers, :issue_statuses, :issues, :versions, :documents,
28 :wikis, :wiki_pages, :wiki_contents, 25 :wikis, :wiki_pages, :wiki_contents,
30 :attachments, 27 :attachments,
31 :enumerations 28 :enumerations
32 29
33 def setup 30 def setup
34 super 31 super
32 end
33
34 context "#link_to_if_authorized" do
35 context "authorized user" do
36 should "be tested"
37 end
38
39 context "unauthorized user" do
40 should "be tested"
41 end
42
43 should "allow using the :controller and :action for the target link" do
44 User.current = User.find_by_login('admin')
45
46 @project = Issue.first.project # Used by helper
47 response = link_to_if_authorized("By controller/action",
48 {:controller => 'issues', :action => 'edit', :id => Issue.first.id})
49 assert_match /href/, response
50 end
51
52 should "allow using the url for the target link" do
53 User.current = User.find_by_login('admin')
54
55 @project = Issue.first.project # Used by helper
56 response = link_to_if_authorized("By url",
57 new_issue_move_path(:id => Issue.first.id))
58 assert_match /href/, response
59 end
60
35 end 61 end
36 62
37 def test_auto_links 63 def test_auto_links
38 to_test = { 64 to_test = {
39 'http://foo.bar' => '<a class="external" href="http://foo.bar">http://foo.bar</a>', 65 'http://foo.bar' => '<a class="external" href="http://foo.bar">http://foo.bar</a>',
573 assert_nil avatar('jsmith') 599 assert_nil avatar('jsmith')
574 assert_nil avatar(nil) 600 assert_nil avatar(nil)
575 601
576 # turn off avatars 602 # turn off avatars
577 Setting.gravatar_enabled = '0' 603 Setting.gravatar_enabled = '0'
578 assert_nil avatar(User.find_by_mail('jsmith@somenet.foo')) 604 assert_equal '', avatar(User.find_by_mail('jsmith@somenet.foo'))
579 end 605 end
580 606
581 def test_link_to_user 607 def test_link_to_user
582 user = User.find(2) 608 user = User.find(2)
583 t = link_to_user(user) 609 t = link_to_user(user)