@@ -5,12 +5,12 | |||||
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. | |
@@ -24,27 +24,27 class GroupTest < ActiveSupport::TestCase | |||||
24 | g = Group.new(:lastname => 'New group') |
|
24 | g = Group.new(:lastname => 'New group') | |
25 | assert g.save |
|
25 | assert g.save | |
26 | end |
|
26 | end | |
27 |
|
27 | |||
28 | def test_roles_given_to_new_user |
|
28 | def test_roles_given_to_new_user | |
29 | group = Group.find(11) |
|
29 | group = Group.find(11) | |
30 | user = User.find(9) |
|
30 | user = User.find(9) | |
31 | project = Project.first |
|
31 | project = Project.first | |
32 |
|
32 | |||
33 | Member.create!(:principal => group, :project => project, :role_ids => [1, 2]) |
|
33 | Member.create!(:principal => group, :project => project, :role_ids => [1, 2]) | |
34 | group.users << user |
|
34 | group.users << user | |
35 | assert user.member_of?(project) |
|
35 | assert user.member_of?(project) | |
36 | end |
|
36 | end | |
37 |
|
37 | |||
38 | def test_roles_given_to_existing_user |
|
38 | def test_roles_given_to_existing_user | |
39 | group = Group.find(11) |
|
39 | group = Group.find(11) | |
40 | user = User.find(9) |
|
40 | user = User.find(9) | |
41 | project = Project.first |
|
41 | project = Project.first | |
42 |
|
42 | |||
43 | group.users << user |
|
43 | group.users << user | |
44 | m = Member.create!(:principal => group, :project => project, :role_ids => [1, 2]) |
|
44 | m = Member.create!(:principal => group, :project => project, :role_ids => [1, 2]) | |
45 | assert user.member_of?(project) |
|
45 | assert user.member_of?(project) | |
46 | end |
|
46 | end | |
47 |
|
47 | |||
48 | def test_roles_updated |
|
48 | def test_roles_updated | |
49 | group = Group.find(11) |
|
49 | group = Group.find(11) | |
50 | user = User.find(9) |
|
50 | user = User.find(9) | |
@@ -52,13 +52,13 class GroupTest < ActiveSupport::TestCase | |||||
52 | group.users << user |
|
52 | group.users << user | |
53 | m = Member.create!(:principal => group, :project => project, :role_ids => [1]) |
|
53 | m = Member.create!(:principal => group, :project => project, :role_ids => [1]) | |
54 | assert_equal [1], user.reload.roles_for_project(project).collect(&:id).sort |
|
54 | assert_equal [1], user.reload.roles_for_project(project).collect(&:id).sort | |
55 |
|
55 | |||
56 | m.role_ids = [1, 2] |
|
56 | m.role_ids = [1, 2] | |
57 | assert_equal [1, 2], user.reload.roles_for_project(project).collect(&:id).sort |
|
57 | assert_equal [1, 2], user.reload.roles_for_project(project).collect(&:id).sort | |
58 |
|
58 | |||
59 | m.role_ids = [2] |
|
59 | m.role_ids = [2] | |
60 | assert_equal [2], user.reload.roles_for_project(project).collect(&:id).sort |
|
60 | assert_equal [2], user.reload.roles_for_project(project).collect(&:id).sort | |
61 |
|
61 | |||
62 | m.role_ids = [1] |
|
62 | m.role_ids = [1] | |
63 | assert_equal [1], user.reload.roles_for_project(project).collect(&:id).sort |
|
63 | assert_equal [1], user.reload.roles_for_project(project).collect(&:id).sort | |
64 | end |
|
64 | end | |
@@ -74,14 +74,14 class GroupTest < ActiveSupport::TestCase | |||||
74 | User.find(8).groups.clear |
|
74 | User.find(8).groups.clear | |
75 | assert !User.find(8).member_of?(Project.find(5)) |
|
75 | assert !User.find(8).member_of?(Project.find(5)) | |
76 | end |
|
76 | end | |
77 |
|
77 | |||
78 | def test_destroy_should_unassign_issues |
|
78 | def test_destroy_should_unassign_issues | |
79 | group = Group.first |
|
79 | group = Group.first | |
80 | Issue.update_all(["assigned_to_id = ?", group.id], 'id = 1') |
|
80 | Issue.update_all(["assigned_to_id = ?", group.id], 'id = 1') | |
81 |
|
81 | |||
82 | assert group.destroy |
|
82 | assert group.destroy | |
83 | assert group.destroyed? |
|
83 | assert group.destroyed? | |
84 |
|
84 | |||
85 | assert_equal nil, Issue.find(1).assigned_to_id |
|
85 | assert_equal nil, Issue.find(1).assigned_to_id | |
86 | end |
|
86 | end | |
87 | end |
|
87 | end |
General Comments 0
You need to be logged in to leave comments.
Login now