Mercurial > hg > soundsoftware-site
comparison .svn/pristine/6e/6efefaf092d1bb6808bf2a3bfd1a462458bc170c.svn-base @ 1517:dffacf8a6908 redmine-2.5
Update to Redmine SVN revision 13367 on 2.5-stable branch
author | Chris Cannam |
---|---|
date | Tue, 09 Sep 2014 09:29:00 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1516:b450a9d58aed | 1517:dffacf8a6908 |
---|---|
1 # Redmine - project management software | |
2 # Copyright (C) 2006-2014 Jean-Philippe Lang | |
3 # | |
4 # This program is free software; you can redistribute it and/or | |
5 # modify it under the terms of the GNU General Public License | |
6 # as published by the Free Software Foundation; either version 2 | |
7 # of the License, or (at your option) any later version. | |
8 # | |
9 # This program is distributed in the hope that it will be useful, | |
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 # GNU General Public License for more details. | |
13 # | |
14 # You should have received a copy of the GNU General Public License | |
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. | |
17 | |
18 require File.expand_path('../../../test_helper', __FILE__) | |
19 | |
20 class WatchersHelperTest < ActionView::TestCase | |
21 include WatchersHelper | |
22 include Redmine::I18n | |
23 include Rails.application.routes.url_helpers | |
24 | |
25 fixtures :users, :issues | |
26 | |
27 def setup | |
28 super | |
29 set_language_if_valid('en') | |
30 User.current = nil | |
31 end | |
32 | |
33 test '#watcher_link with a non-watched object' do | |
34 expected = link_to( | |
35 "Watch", | |
36 "/watchers/watch?object_id=1&object_type=issue", | |
37 :remote => true, :method => 'post', :class => "issue-1-watcher icon icon-fav-off" | |
38 ) | |
39 assert_equal expected, watcher_link(Issue.find(1), User.find(1)) | |
40 end | |
41 | |
42 test '#watcher_link with a single objet array' do | |
43 expected = link_to( | |
44 "Watch", | |
45 "/watchers/watch?object_id=1&object_type=issue", | |
46 :remote => true, :method => 'post', :class => "issue-1-watcher icon icon-fav-off" | |
47 ) | |
48 assert_equal expected, watcher_link([Issue.find(1)], User.find(1)) | |
49 end | |
50 | |
51 test '#watcher_link with a multiple objets array' do | |
52 expected = link_to( | |
53 "Watch", | |
54 "/watchers/watch?object_id%5B%5D=1&object_id%5B%5D=3&object_type=issue", | |
55 :remote => true, :method => 'post', :class => "issue-bulk-watcher icon icon-fav-off" | |
56 ) | |
57 assert_equal expected, watcher_link([Issue.find(1), Issue.find(3)], User.find(1)) | |
58 end | |
59 | |
60 def test_watcher_link_with_nil_should_return_empty_string | |
61 assert_equal '', watcher_link(nil, User.find(1)) | |
62 end | |
63 | |
64 test '#watcher_link with a watched object' do | |
65 Watcher.create!(:watchable => Issue.find(1), :user => User.find(1)) | |
66 | |
67 expected = link_to( | |
68 "Unwatch", | |
69 "/watchers/watch?object_id=1&object_type=issue", | |
70 :remote => true, :method => 'delete', :class => "issue-1-watcher icon icon-fav" | |
71 ) | |
72 assert_equal expected, watcher_link(Issue.find(1), User.find(1)) | |
73 end | |
74 end |