##// END OF EJS Templates
make WatchersHelperTest passes when config.threadsafe! is enabled (#12097)...
Toshi MARUYAMA -
r12153:637e450824cf
parent child
Show More
@@ -1,69 +1,70
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2013 Jean-Philippe Lang
2 # Copyright (C) 2006-2013 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
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
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.expand_path('../../../test_helper', __FILE__)
18 require File.expand_path('../../../test_helper', __FILE__)
19
19
20 class WatchersHelperTest < ActionView::TestCase
20 class WatchersHelperTest < ActionView::TestCase
21 include WatchersHelper
21 include WatchersHelper
22 include Redmine::I18n
22 include Redmine::I18n
23 include Rails.application.routes.url_helpers
23
24
24 fixtures :users, :issues
25 fixtures :users, :issues
25
26
26 def setup
27 def setup
27 super
28 super
28 set_language_if_valid('en')
29 set_language_if_valid('en')
29 User.current = nil
30 User.current = nil
30 end
31 end
31
32
32 test '#watcher_link with a non-watched object' do
33 test '#watcher_link with a non-watched object' do
33 expected = link_to(
34 expected = link_to(
34 "Watch",
35 "Watch",
35 "/watchers/watch?object_id=1&object_type=issue",
36 "/watchers/watch?object_id=1&object_type=issue",
36 :remote => true, :method => 'post', :class => "issue-1-watcher icon icon-fav-off"
37 :remote => true, :method => 'post', :class => "issue-1-watcher icon icon-fav-off"
37 )
38 )
38 assert_equal expected, watcher_link(Issue.find(1), User.find(1))
39 assert_equal expected, watcher_link(Issue.find(1), User.find(1))
39 end
40 end
40
41
41 test '#watcher_link with a single objet array' do
42 test '#watcher_link with a single objet array' do
42 expected = link_to(
43 expected = link_to(
43 "Watch",
44 "Watch",
44 "/watchers/watch?object_id=1&object_type=issue",
45 "/watchers/watch?object_id=1&object_type=issue",
45 :remote => true, :method => 'post', :class => "issue-1-watcher icon icon-fav-off"
46 :remote => true, :method => 'post', :class => "issue-1-watcher icon icon-fav-off"
46 )
47 )
47 assert_equal expected, watcher_link([Issue.find(1)], User.find(1))
48 assert_equal expected, watcher_link([Issue.find(1)], User.find(1))
48 end
49 end
49
50
50 test '#watcher_link with a multiple objets array' do
51 test '#watcher_link with a multiple objets array' do
51 expected = link_to(
52 expected = link_to(
52 "Watch",
53 "Watch",
53 "/watchers/watch?object_id%5B%5D=1&object_id%5B%5D=3&object_type=issue",
54 "/watchers/watch?object_id%5B%5D=1&object_id%5B%5D=3&object_type=issue",
54 :remote => true, :method => 'post', :class => "issue-bulk-watcher icon icon-fav-off"
55 :remote => true, :method => 'post', :class => "issue-bulk-watcher icon icon-fav-off"
55 )
56 )
56 assert_equal expected, watcher_link([Issue.find(1), Issue.find(3)], User.find(1))
57 assert_equal expected, watcher_link([Issue.find(1), Issue.find(3)], User.find(1))
57 end
58 end
58
59
59 test '#watcher_link with a watched object' do
60 test '#watcher_link with a watched object' do
60 Watcher.create!(:watchable => Issue.find(1), :user => User.find(1))
61 Watcher.create!(:watchable => Issue.find(1), :user => User.find(1))
61
62
62 expected = link_to(
63 expected = link_to(
63 "Unwatch",
64 "Unwatch",
64 "/watchers/watch?object_id=1&object_type=issue",
65 "/watchers/watch?object_id=1&object_type=issue",
65 :remote => true, :method => 'delete', :class => "issue-1-watcher icon icon-fav"
66 :remote => true, :method => 'delete', :class => "issue-1-watcher icon icon-fav"
66 )
67 )
67 assert_equal expected, watcher_link(Issue.find(1), User.find(1))
68 assert_equal expected, watcher_link(Issue.find(1), User.find(1))
68 end
69 end
69 end
70 end
General Comments 0
You need to be logged in to leave comments. Login now