##// END OF EJS Templates
remove trailing white-spaces from test/unit/member_test.rb....
Toshi MARUYAMA -
r6633:53cc7af96da6
parent child
Show More
@@ -1,16 +1,16
1 # redMine - project management software
2 # Copyright (C) 2006 Jean-Philippe Lang
1 # Redmine - project management software
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.
@@ -23,21 +23,21 class MemberTest < ActiveSupport::TestCase
23 23 def setup
24 24 @jsmith = Member.find(1)
25 25 end
26
26
27 27 def test_create
28 28 member = Member.new(:project_id => 1, :user_id => 4, :role_ids => [1, 2])
29 29 assert member.save
30 30 member.reload
31
31
32 32 assert_equal 2, member.roles.size
33 33 assert_equal Role.find(1), member.roles.sort.first
34 34 end
35 35
36 def test_update
36 def test_update
37 37 assert_equal "eCookbook", @jsmith.project.name
38 38 assert_equal "Manager", @jsmith.roles.first.name
39 39 assert_equal "jsmith", @jsmith.user.login
40
40
41 41 @jsmith.mail_notification = !@jsmith.mail_notification
42 42 assert @jsmith.save
43 43 end
@@ -48,27 +48,27 class MemberTest < ActiveSupport::TestCase
48 48 assert @jsmith.save
49 49 assert_equal 2, @jsmith.reload.roles.size
50 50 end
51
51
52 52 def test_validate
53 53 member = Member.new(:project_id => 1, :user_id => 2, :role_ids => [2])
54 54 # same use can't have more than one membership for a project
55 55 assert !member.save
56
56
57 57 member = Member.new(:project_id => 1, :user_id => 2, :role_ids => [])
58 58 # must have one role at least
59 59 assert !member.save
60 60 end
61
61
62 62 def test_destroy
63 63 assert_difference 'Member.count', -1 do
64 64 assert_difference 'MemberRole.count', -1 do
65 65 @jsmith.destroy
66 66 end
67 67 end
68
68
69 69 assert_raise(ActiveRecord::RecordNotFound) { Member.find(@jsmith.id) }
70 70 end
71
71
72 72 context "removing permissions" do
73 73 setup do
74 74 Watcher.delete_all("user_id = 9")
@@ -81,12 +81,12 class MemberTest < ActiveSupport::TestCase
81 81 Watcher.create!(:watchable => Wiki.find(2), :user => user)
82 82 Watcher.create!(:watchable => WikiPage.find(3), :user => user)
83 83 end
84
84
85 85 context "of user" do
86 86 setup do
87 87 @member = Member.create!(:project => Project.find(2), :principal => User.find(9), :role_ids => [1, 2])
88 88 end
89
89
90 90 context "by deleting membership" do
91 91 should "prune watchers" do
92 92 assert_difference 'Watcher.count', -4 do
@@ -94,7 +94,7 class MemberTest < ActiveSupport::TestCase
94 94 end
95 95 end
96 96 end
97
97
98 98 context "by updating roles" do
99 99 should "prune watchers" do
100 100 Role.find(2).remove_permission! :view_wiki_pages
@@ -107,7 +107,7 class MemberTest < ActiveSupport::TestCase
107 107 end
108 108 end
109 109 end
110
110
111 111 context "of group" do
112 112 setup do
113 113 group = Group.find(10)
@@ -121,7 +121,7 class MemberTest < ActiveSupport::TestCase
121 121 @member.destroy
122 122 end
123 123 end
124 end
124 end
125 125
126 126 context "by updating roles" do
127 127 should "prune watchers" do
General Comments 0
You need to be logged in to leave comments. Login now