##// END OF EJS Templates
remove trailing white-spaces from test/unit/watcher_test.rb....
Toshi MARUYAMA -
r6634:9b8e0b90af02
parent child
Show More
@@ -1,16 +1,16
1 1 # Redmine - project management software
2 # Copyright (C) 2006-2009 Jean-Philippe Lang
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 #
8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 #
13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@@ -28,67 +28,67 class WatcherTest < ActiveSupport::TestCase
28 28 @user = User.find(1)
29 29 @issue = Issue.find(1)
30 30 end
31
31
32 32 def test_watch
33 33 assert @issue.add_watcher(@user)
34 34 @issue.reload
35 35 assert @issue.watchers.detect { |w| w.user == @user }
36 36 end
37
37
38 38 def test_cant_watch_twice
39 39 assert @issue.add_watcher(@user)
40 40 assert !@issue.add_watcher(@user)
41 41 end
42
42
43 43 def test_watched_by
44 44 assert @issue.add_watcher(@user)
45 45 @issue.reload
46 46 assert @issue.watched_by?(@user)
47 47 assert Issue.watched_by(@user).include?(@issue)
48 48 end
49
49
50 50 def test_watcher_users
51 51 watcher_users = Issue.find(2).watcher_users
52 52 assert_kind_of Array, watcher_users
53 53 assert_kind_of User, watcher_users.first
54 54 end
55
55
56 56 def test_watcher_users_should_not_validate_user
57 57 User.update_all("firstname = ''", "id=1")
58 58 @user.reload
59 59 assert !@user.valid?
60
60
61 61 issue = Issue.new(:project => Project.find(1), :tracker_id => 1, :subject => "test", :author => User.find(2))
62 62 issue.watcher_users << @user
63 63 issue.save!
64 64 assert issue.watched_by?(@user)
65 65 end
66
66
67 67 def test_watcher_user_ids
68 68 assert_equal [1, 3], Issue.find(2).watcher_user_ids.sort
69 69 end
70
70
71 71 def test_watcher_user_ids=
72 72 issue = Issue.new
73 73 issue.watcher_user_ids = ['1', '3']
74 74 assert issue.watched_by?(User.find(1))
75 75 end
76
76
77 77 def test_addable_watcher_users
78 78 addable_watcher_users = @issue.addable_watcher_users
79 79 assert_kind_of Array, addable_watcher_users
80 80 assert_kind_of User, addable_watcher_users.first
81 81 end
82
82
83 83 def test_addable_watcher_users_should_not_include_user_that_cannot_view_the_object
84 84 issue = Issue.new(:project => Project.find(1), :is_private => true)
85 85 assert_nil issue.addable_watcher_users.detect {|user| !issue.visible?(user)}
86 86 end
87
87
88 88 def test_recipients
89 89 @issue.watchers.delete_all
90 90 @issue.reload
91
91
92 92 assert @issue.watcher_recipients.empty?
93 93 assert @issue.add_watcher(@user)
94 94
@@ -102,41 +102,41 class WatcherTest < ActiveSupport::TestCase
102 102 @issue.reload
103 103 assert !@issue.watcher_recipients.include?(@user.mail)
104 104 end
105
105
106 106 def test_unwatch
107 107 assert @issue.add_watcher(@user)
108 108 @issue.reload
109 assert_equal 1, @issue.remove_watcher(@user)
109 assert_equal 1, @issue.remove_watcher(@user)
110 110 end
111
111
112 112 def test_prune
113 113 Watcher.delete_all("user_id = 9")
114 114 user = User.find(9)
115
115
116 116 # public
117 117 Watcher.create!(:watchable => Issue.find(1), :user => user)
118 118 Watcher.create!(:watchable => Issue.find(2), :user => user)
119 119 Watcher.create!(:watchable => Message.find(1), :user => user)
120 120 Watcher.create!(:watchable => Wiki.find(1), :user => user)
121 121 Watcher.create!(:watchable => WikiPage.find(2), :user => user)
122
122
123 123 # private project (id: 2)
124 124 Member.create!(:project => Project.find(2), :principal => user, :role_ids => [1])
125 125 Watcher.create!(:watchable => Issue.find(4), :user => user)
126 126 Watcher.create!(:watchable => Message.find(7), :user => user)
127 127 Watcher.create!(:watchable => Wiki.find(2), :user => user)
128 128 Watcher.create!(:watchable => WikiPage.find(3), :user => user)
129
129
130 130 assert_no_difference 'Watcher.count' do
131 131 Watcher.prune(:user => User.find(9))
132 132 end
133
133
134 134 Member.delete_all
135
135
136 136 assert_difference 'Watcher.count', -4 do
137 137 Watcher.prune(:user => User.find(9))
138 138 end
139
139
140 140 assert Issue.find(1).watched_by?(user)
141 141 assert !Issue.find(4).watched_by?(user)
142 142 end
General Comments 0
You need to be logged in to leave comments. Login now