Mercurial > hg > soundsoftware-site
comparison test/functional/messages_controller_test.rb @ 1298:4f746d8966dd redmine_2.3_integration
Merge from redmine-2.3 branch to create new branch redmine-2.3-integration
author | Chris Cannam |
---|---|
date | Fri, 14 Jun 2013 09:28:30 +0100 |
parents | 622f24f53b42 |
children | e248c7af89ec |
comparison
equal
deleted
inserted
replaced
1297:0a574315af3e | 1298:4f746d8966dd |
---|---|
1 # Redmine - project management software | 1 # Redmine - project management software |
2 # Copyright (C) 2006-2012 Jean-Philippe Lang | 2 # Copyright (C) 2006-2013 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. |
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 require 'messages_controller' | |
20 | |
21 # Re-raise errors caught by the controller. | |
22 class MessagesController; def rescue_action(e) raise e end; end | |
23 | 19 |
24 class MessagesControllerTest < ActionController::TestCase | 20 class MessagesControllerTest < ActionController::TestCase |
25 fixtures :projects, :users, :members, :member_roles, :roles, :boards, :messages, :enabled_modules | 21 fixtures :projects, :users, :members, :member_roles, :roles, :boards, :messages, :enabled_modules |
26 | 22 |
27 def setup | 23 def setup |
28 @controller = MessagesController.new | |
29 @request = ActionController::TestRequest.new | |
30 @response = ActionController::TestResponse.new | |
31 User.current = nil | 24 User.current = nil |
32 end | 25 end |
33 | 26 |
34 def test_show | 27 def test_show |
35 get :show, :board_id => 1, :id => 1 | 28 get :show, :board_id => 1, :id => 1 |
89 def test_get_new | 82 def test_get_new |
90 @request.session[:user_id] = 2 | 83 @request.session[:user_id] = 2 |
91 get :new, :board_id => 1 | 84 get :new, :board_id => 1 |
92 assert_response :success | 85 assert_response :success |
93 assert_template 'new' | 86 assert_template 'new' |
87 end | |
88 | |
89 def test_get_new_with_invalid_board | |
90 @request.session[:user_id] = 2 | |
91 get :new, :board_id => 99 | |
92 assert_response 404 | |
94 end | 93 end |
95 | 94 |
96 def test_post_new | 95 def test_post_new |
97 @request.session[:user_id] = 2 | 96 @request.session[:user_id] = 2 |
98 ActionMailer::Base.deliveries.clear | 97 ActionMailer::Base.deliveries.clear |
162 end | 161 end |
163 | 162 |
164 def test_reply | 163 def test_reply |
165 @request.session[:user_id] = 2 | 164 @request.session[:user_id] = 2 |
166 post :reply, :board_id => 1, :id => 1, :reply => { :content => 'This is a test reply', :subject => 'Test reply' } | 165 post :reply, :board_id => 1, :id => 1, :reply => { :content => 'This is a test reply', :subject => 'Test reply' } |
167 reply = Message.find(:first, :order => 'id DESC') | 166 reply = Message.order('id DESC').first |
168 assert_redirected_to "/boards/1/topics/1?r=#{reply.id}" | 167 assert_redirected_to "/boards/1/topics/1?r=#{reply.id}" |
169 assert Message.find_by_subject('Test reply') | 168 assert Message.find_by_subject('Test reply') |
170 end | 169 end |
171 | 170 |
172 def test_destroy_topic | 171 def test_destroy_topic |