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