##// END OF EJS Templates
remove trailing white-spaces from test/unit/role_test.rb....
Toshi MARUYAMA -
r6649:3e7a2b7ae8df
parent child
Show More
@@ -1,111 +1,111
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2011 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.
17
17
18 require File.expand_path('../../test_helper', __FILE__)
18 require File.expand_path('../../test_helper', __FILE__)
19
19
20 class RoleTest < ActiveSupport::TestCase
20 class RoleTest < ActiveSupport::TestCase
21 fixtures :roles, :workflows
21 fixtures :roles, :workflows
22
22
23 def test_copy_workflows
23 def test_copy_workflows
24 source = Role.find(1)
24 source = Role.find(1)
25 assert_equal 90, source.workflows.size
25 assert_equal 90, source.workflows.size
26
26
27 target = Role.new(:name => 'Target')
27 target = Role.new(:name => 'Target')
28 assert target.save
28 assert target.save
29 target.workflows.copy(source)
29 target.workflows.copy(source)
30 target.reload
30 target.reload
31 assert_equal 90, target.workflows.size
31 assert_equal 90, target.workflows.size
32 end
32 end
33
33
34 def test_add_permission
34 def test_add_permission
35 role = Role.find(1)
35 role = Role.find(1)
36 size = role.permissions.size
36 size = role.permissions.size
37 role.add_permission!("apermission", "anotherpermission")
37 role.add_permission!("apermission", "anotherpermission")
38 role.reload
38 role.reload
39 assert role.permissions.include?(:anotherpermission)
39 assert role.permissions.include?(:anotherpermission)
40 assert_equal size + 2, role.permissions.size
40 assert_equal size + 2, role.permissions.size
41 end
41 end
42
42
43 def test_remove_permission
43 def test_remove_permission
44 role = Role.find(1)
44 role = Role.find(1)
45 size = role.permissions.size
45 size = role.permissions.size
46 perm = role.permissions[0..1]
46 perm = role.permissions[0..1]
47 role.remove_permission!(*perm)
47 role.remove_permission!(*perm)
48 role.reload
48 role.reload
49 assert ! role.permissions.include?(perm[0])
49 assert ! role.permissions.include?(perm[0])
50 assert_equal size - 2, role.permissions.size
50 assert_equal size - 2, role.permissions.size
51 end
51 end
52
52
53 def test_name
53 def test_name
54 I18n.locale = 'fr'
54 I18n.locale = 'fr'
55 assert_equal 'Manager', Role.find(1).name
55 assert_equal 'Manager', Role.find(1).name
56 assert_equal 'Anonyme', Role.anonymous.name
56 assert_equal 'Anonyme', Role.anonymous.name
57 assert_equal 'Non membre', Role.non_member.name
57 assert_equal 'Non membre', Role.non_member.name
58 end
58 end
59
59
60 context "#anonymous" do
60 context "#anonymous" do
61 should "return the anonymous role" do
61 should "return the anonymous role" do
62 role = Role.anonymous
62 role = Role.anonymous
63 assert role.builtin?
63 assert role.builtin?
64 assert_equal Role::BUILTIN_ANONYMOUS, role.builtin
64 assert_equal Role::BUILTIN_ANONYMOUS, role.builtin
65 end
65 end
66
66
67 context "with a missing anonymous role" do
67 context "with a missing anonymous role" do
68 setup do
68 setup do
69 Role.delete_all("builtin = #{Role::BUILTIN_ANONYMOUS}")
69 Role.delete_all("builtin = #{Role::BUILTIN_ANONYMOUS}")
70 end
70 end
71
71
72 should "create a new anonymous role" do
72 should "create a new anonymous role" do
73 assert_difference('Role.count') do
73 assert_difference('Role.count') do
74 Role.anonymous
74 Role.anonymous
75 end
75 end
76 end
76 end
77
77
78 should "return the anonymous role" do
78 should "return the anonymous role" do
79 role = Role.anonymous
79 role = Role.anonymous
80 assert role.builtin?
80 assert role.builtin?
81 assert_equal Role::BUILTIN_ANONYMOUS, role.builtin
81 assert_equal Role::BUILTIN_ANONYMOUS, role.builtin
82 end
82 end
83 end
83 end
84 end
84 end
85
85
86 context "#non_member" do
86 context "#non_member" do
87 should "return the non-member role" do
87 should "return the non-member role" do
88 role = Role.non_member
88 role = Role.non_member
89 assert role.builtin?
89 assert role.builtin?
90 assert_equal Role::BUILTIN_NON_MEMBER, role.builtin
90 assert_equal Role::BUILTIN_NON_MEMBER, role.builtin
91 end
91 end
92
92
93 context "with a missing non-member role" do
93 context "with a missing non-member role" do
94 setup do
94 setup do
95 Role.delete_all("builtin = #{Role::BUILTIN_NON_MEMBER}")
95 Role.delete_all("builtin = #{Role::BUILTIN_NON_MEMBER}")
96 end
96 end
97
97
98 should "create a new non-member role" do
98 should "create a new non-member role" do
99 assert_difference('Role.count') do
99 assert_difference('Role.count') do
100 Role.non_member
100 Role.non_member
101 end
101 end
102 end
102 end
103
103
104 should "return the non-member role" do
104 should "return the non-member role" do
105 role = Role.non_member
105 role = Role.non_member
106 assert role.builtin?
106 assert role.builtin?
107 assert_equal Role::BUILTIN_NON_MEMBER, role.builtin
107 assert_equal Role::BUILTIN_NON_MEMBER, role.builtin
108 end
108 end
109 end
109 end
110 end
110 end
111 end
111 end
General Comments 0
You need to be logged in to leave comments. Login now