Mercurial > hg > soundsoftware-site
comparison .svn/pristine/67/673796e159cf85c017eed0e9ba7ade50c519b16a.svn-base @ 1295:622f24f53b42 redmine-2.3
Update to Redmine SVN revision 11972 on 2.3-stable branch
author | Chris Cannam |
---|---|
date | Fri, 14 Jun 2013 09:02:21 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1294:3e4c3460b6ca | 1295:622f24f53b42 |
---|---|
1 # Redmine - project management software | |
2 # Copyright (C) 2006-2012 Jean-Philippe Lang | |
3 # | |
4 # This program is free software; you can redistribute it and/or | |
5 # modify it under the terms of the GNU General Public License | |
6 # as published by the Free Software Foundation; either version 2 | |
7 # of the License, or (at your option) any later version. | |
8 # | |
9 # This program is distributed in the hope that it will be useful, | |
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 # GNU General Public License for more details. | |
13 # | |
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 | |
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 | |
18 require File.expand_path('../../test_helper', __FILE__) | |
19 | |
20 class BoardsControllerTest < ActionController::TestCase | |
21 fixtures :projects, :users, :members, :member_roles, :roles, :boards, :messages, :enabled_modules | |
22 | |
23 def setup | |
24 User.current = nil | |
25 end | |
26 | |
27 def test_index | |
28 get :index, :project_id => 1 | |
29 assert_response :success | |
30 assert_template 'index' | |
31 assert_not_nil assigns(:boards) | |
32 assert_not_nil assigns(:project) | |
33 end | |
34 | |
35 def test_index_not_found | |
36 get :index, :project_id => 97 | |
37 assert_response 404 | |
38 end | |
39 | |
40 def test_index_should_show_messages_if_only_one_board | |
41 Project.find(1).boards.slice(1..-1).each(&:destroy) | |
42 | |
43 get :index, :project_id => 1 | |
44 assert_response :success | |
45 assert_template 'show' | |
46 assert_not_nil assigns(:topics) | |
47 end | |
48 | |
49 def test_show | |
50 get :show, :project_id => 1, :id => 1 | |
51 assert_response :success | |
52 assert_template 'show' | |
53 assert_not_nil assigns(:board) | |
54 assert_not_nil assigns(:project) | |
55 assert_not_nil assigns(:topics) | |
56 end | |
57 | |
58 def test_show_should_display_sticky_messages_first | |
59 Message.update_all(:sticky => 0) | |
60 Message.update_all({:sticky => 1}, {:id => 1}) | |
61 | |
62 get :show, :project_id => 1, :id => 1 | |
63 assert_response :success | |
64 | |
65 topics = assigns(:topics) | |
66 assert_not_nil topics | |
67 assert topics.size > 1, "topics size was #{topics.size}" | |
68 assert topics.first.sticky? | |
69 assert topics.first.updated_on < topics.second.updated_on | |
70 end | |
71 | |
72 def test_show_with_permission_should_display_the_new_message_form | |
73 @request.session[:user_id] = 2 | |
74 get :show, :project_id => 1, :id => 1 | |
75 assert_response :success | |
76 assert_template 'show' | |
77 | |
78 assert_tag 'form', :attributes => {:id => 'message-form'} | |
79 assert_tag 'input', :attributes => {:name => 'message[subject]'} | |
80 end | |
81 | |
82 def test_show_atom | |
83 get :show, :project_id => 1, :id => 1, :format => 'atom' | |
84 assert_response :success | |
85 assert_template 'common/feed' | |
86 assert_not_nil assigns(:board) | |
87 assert_not_nil assigns(:project) | |
88 assert_not_nil assigns(:messages) | |
89 end | |
90 | |
91 def test_show_not_found | |
92 get :index, :project_id => 1, :id => 97 | |
93 assert_response 404 | |
94 end | |
95 | |
96 def test_new | |
97 @request.session[:user_id] = 2 | |
98 get :new, :project_id => 1 | |
99 assert_response :success | |
100 assert_template 'new' | |
101 | |
102 assert_select 'select[name=?]', 'board[parent_id]' do | |
103 assert_select 'option', (Project.find(1).boards.size + 1) | |
104 assert_select 'option[value=]', :text => '' | |
105 assert_select 'option[value=1]', :text => 'Help' | |
106 end | |
107 end | |
108 | |
109 def test_new_without_project_boards | |
110 Project.find(1).boards.delete_all | |
111 @request.session[:user_id] = 2 | |
112 | |
113 get :new, :project_id => 1 | |
114 assert_response :success | |
115 assert_template 'new' | |
116 | |
117 assert_select 'select[name=?]', 'board[parent_id]', 0 | |
118 end | |
119 | |
120 def test_create | |
121 @request.session[:user_id] = 2 | |
122 assert_difference 'Board.count' do | |
123 post :create, :project_id => 1, :board => { :name => 'Testing', :description => 'Testing board creation'} | |
124 end | |
125 assert_redirected_to '/projects/ecookbook/settings/boards' | |
126 board = Board.first(:order => 'id DESC') | |
127 assert_equal 'Testing', board.name | |
128 assert_equal 'Testing board creation', board.description | |
129 end | |
130 | |
131 def test_create_with_parent | |
132 @request.session[:user_id] = 2 | |
133 assert_difference 'Board.count' do | |
134 post :create, :project_id => 1, :board => { :name => 'Testing', :description => 'Testing', :parent_id => 2} | |
135 end | |
136 assert_redirected_to '/projects/ecookbook/settings/boards' | |
137 board = Board.first(:order => 'id DESC') | |
138 assert_equal Board.find(2), board.parent | |
139 end | |
140 | |
141 def test_create_with_failure | |
142 @request.session[:user_id] = 2 | |
143 assert_no_difference 'Board.count' do | |
144 post :create, :project_id => 1, :board => { :name => '', :description => 'Testing board creation'} | |
145 end | |
146 assert_response :success | |
147 assert_template 'new' | |
148 end | |
149 | |
150 def test_edit | |
151 @request.session[:user_id] = 2 | |
152 get :edit, :project_id => 1, :id => 2 | |
153 assert_response :success | |
154 assert_template 'edit' | |
155 end | |
156 | |
157 def test_edit_with_parent | |
158 board = Board.generate!(:project_id => 1, :parent_id => 2) | |
159 @request.session[:user_id] = 2 | |
160 get :edit, :project_id => 1, :id => board.id | |
161 assert_response :success | |
162 assert_template 'edit' | |
163 | |
164 assert_select 'select[name=?]', 'board[parent_id]' do | |
165 assert_select 'option[value=2][selected=selected]' | |
166 end | |
167 end | |
168 | |
169 def test_update | |
170 @request.session[:user_id] = 2 | |
171 assert_no_difference 'Board.count' do | |
172 put :update, :project_id => 1, :id => 2, :board => { :name => 'Testing', :description => 'Testing board update'} | |
173 end | |
174 assert_redirected_to '/projects/ecookbook/settings/boards' | |
175 assert_equal 'Testing', Board.find(2).name | |
176 end | |
177 | |
178 def test_update_position | |
179 @request.session[:user_id] = 2 | |
180 put :update, :project_id => 1, :id => 2, :board => { :move_to => 'highest'} | |
181 assert_redirected_to '/projects/ecookbook/settings/boards' | |
182 board = Board.find(2) | |
183 assert_equal 1, board.position | |
184 end | |
185 | |
186 def test_update_with_failure | |
187 @request.session[:user_id] = 2 | |
188 put :update, :project_id => 1, :id => 2, :board => { :name => '', :description => 'Testing board update'} | |
189 assert_response :success | |
190 assert_template 'edit' | |
191 end | |
192 | |
193 def test_destroy | |
194 @request.session[:user_id] = 2 | |
195 assert_difference 'Board.count', -1 do | |
196 delete :destroy, :project_id => 1, :id => 2 | |
197 end | |
198 assert_redirected_to '/projects/ecookbook/settings/boards' | |
199 assert_nil Board.find_by_id(2) | |
200 end | |
201 end |