@@ -1,130 +1,140 | |||||
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 BoardsControllerTest < ActionController::TestCase |
|
20 | class BoardsControllerTest < ActionController::TestCase | |
21 | fixtures :projects, :users, :members, :member_roles, :roles, :boards, :messages, :enabled_modules |
|
21 | fixtures :projects, :users, :members, :member_roles, :roles, :boards, :messages, :enabled_modules | |
22 |
|
22 | |||
23 | def setup |
|
23 | def setup | |
24 | User.current = nil |
|
24 | User.current = nil | |
25 | end |
|
25 | end | |
26 |
|
26 | |||
27 | def test_index |
|
27 | def test_index | |
28 | get :index, :project_id => 1 |
|
28 | get :index, :project_id => 1 | |
29 | assert_response :success |
|
29 | assert_response :success | |
30 | assert_template 'index' |
|
30 | assert_template 'index' | |
31 | assert_not_nil assigns(:boards) |
|
31 | assert_not_nil assigns(:boards) | |
32 | assert_not_nil assigns(:project) |
|
32 | assert_not_nil assigns(:project) | |
33 | end |
|
33 | end | |
34 |
|
34 | |||
35 | def test_index_not_found |
|
35 | def test_index_not_found | |
36 | get :index, :project_id => 97 |
|
36 | get :index, :project_id => 97 | |
37 | assert_response 404 |
|
37 | assert_response 404 | |
38 | end |
|
38 | end | |
39 |
|
39 | |||
40 | def test_index_should_show_messages_if_only_one_board |
|
40 | def test_index_should_show_messages_if_only_one_board | |
41 | Project.find(1).boards.slice(1..-1).each(&:destroy) |
|
41 | Project.find(1).boards.slice(1..-1).each(&:destroy) | |
42 |
|
42 | |||
43 | get :index, :project_id => 1 |
|
43 | get :index, :project_id => 1 | |
44 | assert_response :success |
|
44 | assert_response :success | |
45 | assert_template 'show' |
|
45 | assert_template 'show' | |
46 | assert_not_nil assigns(:topics) |
|
46 | assert_not_nil assigns(:topics) | |
47 | end |
|
47 | end | |
48 |
|
48 | |||
49 | def test_show |
|
49 | def test_show | |
50 | get :show, :project_id => 1, :id => 1 |
|
50 | get :show, :project_id => 1, :id => 1 | |
51 | assert_response :success |
|
51 | assert_response :success | |
52 | assert_template 'show' |
|
52 | assert_template 'show' | |
53 | assert_not_nil assigns(:board) |
|
53 | assert_not_nil assigns(:board) | |
54 | assert_not_nil assigns(:project) |
|
54 | assert_not_nil assigns(:project) | |
55 | assert_not_nil assigns(:topics) |
|
55 | assert_not_nil assigns(:topics) | |
56 | end |
|
56 | end | |
57 |
|
57 | |||
|
58 | def test_show_with_permission_should_display_the_new_message_form | |||
|
59 | @request.session[:user_id] = 2 | |||
|
60 | get :show, :project_id => 1, :id => 1 | |||
|
61 | assert_response :success | |||
|
62 | assert_template 'show' | |||
|
63 | ||||
|
64 | assert_tag 'form', :attributes => {:id => 'message-form'} | |||
|
65 | assert_tag 'input', :attributes => {:name => 'message[subject]'} | |||
|
66 | end | |||
|
67 | ||||
58 | def test_show_atom |
|
68 | def test_show_atom | |
59 | get :show, :project_id => 1, :id => 1, :format => 'atom' |
|
69 | get :show, :project_id => 1, :id => 1, :format => 'atom' | |
60 | assert_response :success |
|
70 | assert_response :success | |
61 | assert_template 'common/feed.atom' |
|
71 | assert_template 'common/feed.atom' | |
62 | assert_not_nil assigns(:board) |
|
72 | assert_not_nil assigns(:board) | |
63 | assert_not_nil assigns(:project) |
|
73 | assert_not_nil assigns(:project) | |
64 | assert_not_nil assigns(:messages) |
|
74 | assert_not_nil assigns(:messages) | |
65 | end |
|
75 | end | |
66 |
|
76 | |||
67 | def test_show_not_found |
|
77 | def test_show_not_found | |
68 | get :index, :project_id => 1, :id => 97 |
|
78 | get :index, :project_id => 1, :id => 97 | |
69 | assert_response 404 |
|
79 | assert_response 404 | |
70 | end |
|
80 | end | |
71 |
|
81 | |||
72 | def test_new |
|
82 | def test_new | |
73 | @request.session[:user_id] = 2 |
|
83 | @request.session[:user_id] = 2 | |
74 | get :new, :project_id => 1 |
|
84 | get :new, :project_id => 1 | |
75 | assert_response :success |
|
85 | assert_response :success | |
76 | assert_template 'new' |
|
86 | assert_template 'new' | |
77 | end |
|
87 | end | |
78 |
|
88 | |||
79 | def test_create |
|
89 | def test_create | |
80 | @request.session[:user_id] = 2 |
|
90 | @request.session[:user_id] = 2 | |
81 | assert_difference 'Board.count' do |
|
91 | assert_difference 'Board.count' do | |
82 | post :create, :project_id => 1, :board => { :name => 'Testing', :description => 'Testing board creation'} |
|
92 | post :create, :project_id => 1, :board => { :name => 'Testing', :description => 'Testing board creation'} | |
83 | end |
|
93 | end | |
84 | assert_redirected_to '/projects/ecookbook/settings/boards' |
|
94 | assert_redirected_to '/projects/ecookbook/settings/boards' | |
85 | board = Board.first(:order => 'id DESC') |
|
95 | board = Board.first(:order => 'id DESC') | |
86 | assert_equal 'Testing', board.name |
|
96 | assert_equal 'Testing', board.name | |
87 | assert_equal 'Testing board creation', board.description |
|
97 | assert_equal 'Testing board creation', board.description | |
88 | end |
|
98 | end | |
89 |
|
99 | |||
90 | def test_create_with_failure |
|
100 | def test_create_with_failure | |
91 | @request.session[:user_id] = 2 |
|
101 | @request.session[:user_id] = 2 | |
92 | assert_no_difference 'Board.count' do |
|
102 | assert_no_difference 'Board.count' do | |
93 | post :create, :project_id => 1, :board => { :name => '', :description => 'Testing board creation'} |
|
103 | post :create, :project_id => 1, :board => { :name => '', :description => 'Testing board creation'} | |
94 | end |
|
104 | end | |
95 | assert_response :success |
|
105 | assert_response :success | |
96 | assert_template 'new' |
|
106 | assert_template 'new' | |
97 | end |
|
107 | end | |
98 |
|
108 | |||
99 | def test_edit |
|
109 | def test_edit | |
100 | @request.session[:user_id] = 2 |
|
110 | @request.session[:user_id] = 2 | |
101 | get :edit, :project_id => 1, :id => 2 |
|
111 | get :edit, :project_id => 1, :id => 2 | |
102 | assert_response :success |
|
112 | assert_response :success | |
103 | assert_template 'edit' |
|
113 | assert_template 'edit' | |
104 | end |
|
114 | end | |
105 |
|
115 | |||
106 | def test_update |
|
116 | def test_update | |
107 | @request.session[:user_id] = 2 |
|
117 | @request.session[:user_id] = 2 | |
108 | assert_no_difference 'Board.count' do |
|
118 | assert_no_difference 'Board.count' do | |
109 | put :update, :project_id => 1, :id => 2, :board => { :name => 'Testing', :description => 'Testing board update'} |
|
119 | put :update, :project_id => 1, :id => 2, :board => { :name => 'Testing', :description => 'Testing board update'} | |
110 | end |
|
120 | end | |
111 | assert_redirected_to '/projects/ecookbook/settings/boards' |
|
121 | assert_redirected_to '/projects/ecookbook/settings/boards' | |
112 | assert_equal 'Testing', Board.find(2).name |
|
122 | assert_equal 'Testing', Board.find(2).name | |
113 | end |
|
123 | end | |
114 |
|
124 | |||
115 | def test_update_with_failure |
|
125 | def test_update_with_failure | |
116 | @request.session[:user_id] = 2 |
|
126 | @request.session[:user_id] = 2 | |
117 | put :update, :project_id => 1, :id => 2, :board => { :name => '', :description => 'Testing board update'} |
|
127 | put :update, :project_id => 1, :id => 2, :board => { :name => '', :description => 'Testing board update'} | |
118 | assert_response :success |
|
128 | assert_response :success | |
119 | assert_template 'edit' |
|
129 | assert_template 'edit' | |
120 | end |
|
130 | end | |
121 |
|
131 | |||
122 | def test_destroy |
|
132 | def test_destroy | |
123 | @request.session[:user_id] = 2 |
|
133 | @request.session[:user_id] = 2 | |
124 | assert_difference 'Board.count', -1 do |
|
134 | assert_difference 'Board.count', -1 do | |
125 | delete :destroy, :project_id => 1, :id => 2 |
|
135 | delete :destroy, :project_id => 1, :id => 2 | |
126 | end |
|
136 | end | |
127 | assert_redirected_to '/projects/ecookbook/settings/boards' |
|
137 | assert_redirected_to '/projects/ecookbook/settings/boards' | |
128 | assert_nil Board.find_by_id(2) |
|
138 | assert_nil Board.find_by_id(2) | |
129 | end |
|
139 | end | |
130 | end |
|
140 | end |
General Comments 0
You need to be logged in to leave comments.
Login now