##// END OF EJS Templates
Include missing fixtures....
Jean-Philippe Lang -
r2875:e117dc8c9cb3
parent child
Show More
@@ -1,107 +1,107
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2009 Jean-Philippe Lang
2 # Copyright (C) 2006-2009 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.dirname(__FILE__) + '/../test_helper'
18 require File.dirname(__FILE__) + '/../test_helper'
19 require 'groups_controller'
19 require 'groups_controller'
20
20
21 # Re-raise errors caught by the controller.
21 # Re-raise errors caught by the controller.
22 class GroupsController; def rescue_action(e) raise e end; end
22 class GroupsController; def rescue_action(e) raise e end; end
23
23
24 class GroupsControllerTest < ActionController::TestCase
24 class GroupsControllerTest < ActionController::TestCase
25 fixtures :projects, :users, :members, :member_roles
25 fixtures :projects, :users, :members, :member_roles, :groups_users
26
26
27 def setup
27 def setup
28 @controller = GroupsController.new
28 @controller = GroupsController.new
29 @request = ActionController::TestRequest.new
29 @request = ActionController::TestRequest.new
30 @response = ActionController::TestResponse.new
30 @response = ActionController::TestResponse.new
31 User.current = nil
31 User.current = nil
32 @request.session[:user_id] = 1
32 @request.session[:user_id] = 1
33 end
33 end
34
34
35 def test_index
35 def test_index
36 get :index
36 get :index
37 assert_response :success
37 assert_response :success
38 assert_template 'index'
38 assert_template 'index'
39 end
39 end
40
40
41 def test_show
41 def test_show
42 get :show, :id => 10
42 get :show, :id => 10
43 assert_response :success
43 assert_response :success
44 assert_template 'show'
44 assert_template 'show'
45 end
45 end
46
46
47 def test_new
47 def test_new
48 get :new
48 get :new
49 assert_response :success
49 assert_response :success
50 assert_template 'new'
50 assert_template 'new'
51 end
51 end
52
52
53 def test_create
53 def test_create
54 assert_difference 'Group.count' do
54 assert_difference 'Group.count' do
55 post :create, :group => {:lastname => 'New group'}
55 post :create, :group => {:lastname => 'New group'}
56 end
56 end
57 assert_redirected_to 'groups'
57 assert_redirected_to 'groups'
58 end
58 end
59
59
60 def test_edit
60 def test_edit
61 get :edit, :id => 10
61 get :edit, :id => 10
62 assert_response :success
62 assert_response :success
63 assert_template 'edit'
63 assert_template 'edit'
64 end
64 end
65
65
66 def test_update
66 def test_update
67 post :update, :id => 10
67 post :update, :id => 10
68 assert_redirected_to 'groups'
68 assert_redirected_to 'groups'
69 end
69 end
70
70
71 def test_destroy
71 def test_destroy
72 assert_difference 'Group.count', -1 do
72 assert_difference 'Group.count', -1 do
73 post :destroy, :id => 10
73 post :destroy, :id => 10
74 end
74 end
75 assert_redirected_to 'groups'
75 assert_redirected_to 'groups'
76 end
76 end
77
77
78 def test_add_users
78 def test_add_users
79 assert_difference 'Group.find(10).users.count', 2 do
79 assert_difference 'Group.find(10).users.count', 2 do
80 post :add_users, :id => 10, :user_ids => ['2', '3']
80 post :add_users, :id => 10, :user_ids => ['2', '3']
81 end
81 end
82 end
82 end
83
83
84 def test_remove_user
84 def test_remove_user
85 assert_difference 'Group.find(10).users.count', -1 do
85 assert_difference 'Group.find(10).users.count', -1 do
86 post :remove_user, :id => 10, :user_id => '8'
86 post :remove_user, :id => 10, :user_id => '8'
87 end
87 end
88 end
88 end
89
89
90 def test_new_membership
90 def test_new_membership
91 assert_difference 'Group.find(10).members.count' do
91 assert_difference 'Group.find(10).members.count' do
92 post :edit_membership, :id => 10, :membership => { :project_id => 2, :role_ids => ['1', '2']}
92 post :edit_membership, :id => 10, :membership => { :project_id => 2, :role_ids => ['1', '2']}
93 end
93 end
94 end
94 end
95
95
96 def test_edit_membership
96 def test_edit_membership
97 assert_no_difference 'Group.find(10).members.count' do
97 assert_no_difference 'Group.find(10).members.count' do
98 post :edit_membership, :id => 10, :membership_id => 6, :membership => { :role_ids => ['1', '3']}
98 post :edit_membership, :id => 10, :membership_id => 6, :membership => { :role_ids => ['1', '3']}
99 end
99 end
100 end
100 end
101
101
102 def test_destroy_membership
102 def test_destroy_membership
103 assert_difference 'Group.find(10).members.count', -1 do
103 assert_difference 'Group.find(10).members.count', -1 do
104 post :destroy_membership, :id => 10, :membership_id => 6
104 post :destroy_membership, :id => 10, :membership_id => 6
105 end
105 end
106 end
106 end
107 end
107 end
General Comments 0
You need to be logged in to leave comments. Login now