##// END OF EJS Templates
add unit test of group blank name in French (#9795)...
Toshi MARUYAMA -
r8116:34087c417819
parent child
Show More
@@ -1,104 +1,113
1 1 # Redmine - project management software
2 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.
17 17
18 18 require File.expand_path('../../test_helper', __FILE__)
19 19
20 20 class GroupTest < ActiveSupport::TestCase
21 21 fixtures :projects, :trackers, :issue_statuses, :issues,
22 22 :enumerations, :users, :issue_categories,
23 23 :projects_trackers,
24 24 :roles,
25 25 :member_roles,
26 26 :members,
27 27 :enabled_modules,
28 28 :workflows,
29 29 :groups_users
30 30
31 31 include Redmine::I18n
32 32
33 33 def test_create
34 34 g = Group.new(:lastname => 'New group')
35 35 assert g.save
36 36 end
37 37
38 38 def test_blank_name_error_message
39 39 set_language_if_valid 'en'
40 40 g = Group.new
41 41 assert !g.save
42 42 assert_include "Name can't be blank", g.errors.full_messages
43 43 end
44 44
45 def test_blank_name_error_message_fr
46 set_language_if_valid 'fr'
47 str = "Nom doit \xc3\xaatre renseign\xc3\xa9(e)"
48 str.force_encoding('UTF-8') if str.respond_to?(:force_encoding)
49 g = Group.new
50 assert !g.save
51 assert_include str, g.errors.full_messages
52 end
53
45 54 def test_roles_given_to_new_user
46 55 group = Group.find(11)
47 56 user = User.find(9)
48 57 project = Project.first
49 58
50 59 Member.create!(:principal => group, :project => project, :role_ids => [1, 2])
51 60 group.users << user
52 61 assert user.member_of?(project)
53 62 end
54 63
55 64 def test_roles_given_to_existing_user
56 65 group = Group.find(11)
57 66 user = User.find(9)
58 67 project = Project.first
59 68
60 69 group.users << user
61 70 m = Member.create!(:principal => group, :project => project, :role_ids => [1, 2])
62 71 assert user.member_of?(project)
63 72 end
64 73
65 74 def test_roles_updated
66 75 group = Group.find(11)
67 76 user = User.find(9)
68 77 project = Project.first
69 78 group.users << user
70 79 m = Member.create!(:principal => group, :project => project, :role_ids => [1])
71 80 assert_equal [1], user.reload.roles_for_project(project).collect(&:id).sort
72 81
73 82 m.role_ids = [1, 2]
74 83 assert_equal [1, 2], user.reload.roles_for_project(project).collect(&:id).sort
75 84
76 85 m.role_ids = [2]
77 86 assert_equal [2], user.reload.roles_for_project(project).collect(&:id).sort
78 87
79 88 m.role_ids = [1]
80 89 assert_equal [1], user.reload.roles_for_project(project).collect(&:id).sort
81 90 end
82 91
83 92 def test_roles_removed_when_removing_group_membership
84 93 assert User.find(8).member_of?(Project.find(5))
85 94 Member.find_by_project_id_and_user_id(5, 10).destroy
86 95 assert !User.find(8).member_of?(Project.find(5))
87 96 end
88 97
89 98 def test_roles_removed_when_removing_user_from_group
90 99 assert User.find(8).member_of?(Project.find(5))
91 100 User.find(8).groups.clear
92 101 assert !User.find(8).member_of?(Project.find(5))
93 102 end
94 103
95 104 def test_destroy_should_unassign_issues
96 105 group = Group.first
97 106 Issue.update_all(["assigned_to_id = ?", group.id], 'id = 1')
98 107
99 108 assert group.destroy
100 109 assert group.destroyed?
101 110
102 111 assert_equal nil, Issue.find(1).assigned_to_id
103 112 end
104 113 end
General Comments 0
You need to be logged in to leave comments. Login now