Mercurial > hg > soundsoftware-site
comparison .svn/pristine/e8/e8617c549b31d54d1ecceb4d7305f89a7f9997a3.svn-base @ 1296:038ba2d95de8 redmine-2.2
Fix redmine-2.2 branch update (add missing svn files)
author | Chris Cannam |
---|---|
date | Fri, 14 Jun 2013 09:05:06 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1294:3e4c3460b6ca | 1296:038ba2d95de8 |
---|---|
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_should_display_message_with_last_reply_first | |
73 Message.update_all(:sticky => 0) | |
74 | |
75 # Reply to an old topic | |
76 old_topic = Message.where(:board_id => 1, :parent_id => nil).order('created_on ASC').first | |
77 reply = Message.new(:board_id => 1, :subject => 'New reply', :content => 'New reply', :author_id => 2) | |
78 old_topic.children << reply | |
79 | |
80 get :show, :project_id => 1, :id => 1 | |
81 assert_response :success | |
82 topics = assigns(:topics) | |
83 assert_not_nil topics | |
84 assert_equal old_topic, topics.first | |
85 end | |
86 | |
87 def test_show_with_permission_should_display_the_new_message_form | |
88 @request.session[:user_id] = 2 | |
89 get :show, :project_id => 1, :id => 1 | |
90 assert_response :success | |
91 assert_template 'show' | |
92 | |
93 assert_tag 'form', :attributes => {:id => 'message-form'} | |
94 assert_tag 'input', :attributes => {:name => 'message[subject]'} | |
95 end | |
96 | |
97 def test_show_atom | |
98 get :show, :project_id => 1, :id => 1, :format => 'atom' | |
99 assert_response :success | |
100 assert_template 'common/feed' | |
101 assert_not_nil assigns(:board) | |
102 assert_not_nil assigns(:project) | |
103 assert_not_nil assigns(:messages) | |
104 end | |
105 | |
106 def test_show_not_found | |
107 get :index, :project_id => 1, :id => 97 | |
108 assert_response 404 | |
109 end | |
110 | |
111 def test_new | |
112 @request.session[:user_id] = 2 | |
113 get :new, :project_id => 1 | |
114 assert_response :success | |
115 assert_template 'new' | |
116 | |
117 assert_select 'select[name=?]', 'board[parent_id]' do | |
118 assert_select 'option', (Project.find(1).boards.size + 1) | |
119 assert_select 'option[value=]', :text => '' | |
120 assert_select 'option[value=1]', :text => 'Help' | |
121 end | |
122 end | |
123 | |
124 def test_new_without_project_boards | |
125 Project.find(1).boards.delete_all | |
126 @request.session[:user_id] = 2 | |
127 | |
128 get :new, :project_id => 1 | |
129 assert_response :success | |
130 assert_template 'new' | |
131 | |
132 assert_select 'select[name=?]', 'board[parent_id]', 0 | |
133 end | |
134 | |
135 def test_create | |
136 @request.session[:user_id] = 2 | |
137 assert_difference 'Board.count' do | |
138 post :create, :project_id => 1, :board => { :name => 'Testing', :description => 'Testing board creation'} | |
139 end | |
140 assert_redirected_to '/projects/ecookbook/settings/boards' | |
141 board = Board.first(:order => 'id DESC') | |
142 assert_equal 'Testing', board.name | |
143 assert_equal 'Testing board creation', board.description | |
144 end | |
145 | |
146 def test_create_with_parent | |
147 @request.session[:user_id] = 2 | |
148 assert_difference 'Board.count' do | |
149 post :create, :project_id => 1, :board => { :name => 'Testing', :description => 'Testing', :parent_id => 2} | |
150 end | |
151 assert_redirected_to '/projects/ecookbook/settings/boards' | |
152 board = Board.first(:order => 'id DESC') | |
153 assert_equal Board.find(2), board.parent | |
154 end | |
155 | |
156 def test_create_with_failure | |
157 @request.session[:user_id] = 2 | |
158 assert_no_difference 'Board.count' do | |
159 post :create, :project_id => 1, :board => { :name => '', :description => 'Testing board creation'} | |
160 end | |
161 assert_response :success | |
162 assert_template 'new' | |
163 end | |
164 | |
165 def test_edit | |
166 @request.session[:user_id] = 2 | |
167 get :edit, :project_id => 1, :id => 2 | |
168 assert_response :success | |
169 assert_template 'edit' | |
170 end | |
171 | |
172 def test_edit_with_parent | |
173 board = Board.generate!(:project_id => 1, :parent_id => 2) | |
174 @request.session[:user_id] = 2 | |
175 get :edit, :project_id => 1, :id => board.id | |
176 assert_response :success | |
177 assert_template 'edit' | |
178 | |
179 assert_select 'select[name=?]', 'board[parent_id]' do | |
180 assert_select 'option[value=2][selected=selected]' | |
181 end | |
182 end | |
183 | |
184 def test_update | |
185 @request.session[:user_id] = 2 | |
186 assert_no_difference 'Board.count' do | |
187 put :update, :project_id => 1, :id => 2, :board => { :name => 'Testing', :description => 'Testing board update'} | |
188 end | |
189 assert_redirected_to '/projects/ecookbook/settings/boards' | |
190 assert_equal 'Testing', Board.find(2).name | |
191 end | |
192 | |
193 def test_update_position | |
194 @request.session[:user_id] = 2 | |
195 put :update, :project_id => 1, :id => 2, :board => { :move_to => 'highest'} | |
196 assert_redirected_to '/projects/ecookbook/settings/boards' | |
197 board = Board.find(2) | |
198 assert_equal 1, board.position | |
199 end | |
200 | |
201 def test_update_with_failure | |
202 @request.session[:user_id] = 2 | |
203 put :update, :project_id => 1, :id => 2, :board => { :name => '', :description => 'Testing board update'} | |
204 assert_response :success | |
205 assert_template 'edit' | |
206 end | |
207 | |
208 def test_destroy | |
209 @request.session[:user_id] = 2 | |
210 assert_difference 'Board.count', -1 do | |
211 delete :destroy, :project_id => 1, :id => 2 | |
212 end | |
213 assert_redirected_to '/projects/ecookbook/settings/boards' | |
214 assert_nil Board.find_by_id(2) | |
215 end | |
216 end |