Mercurial > hg > soundsoftware-site
comparison test/functional/boards_controller_test.rb @ 909:cbb26bc654de redmine-1.3
Update to Redmine 1.3-stable branch (Redmine SVN rev 8964)
author | Chris Cannam |
---|---|
date | Fri, 24 Feb 2012 19:09:32 +0000 |
parents | 8661b858af72 |
children | 5f33065ddc4b |
comparison
equal
deleted
inserted
replaced
908:c6c2cbd0afee | 909:cbb26bc654de |
---|---|
1 # Redmine - project management software | 1 # Redmine - project management software |
2 # Copyright (C) 2006-2009 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__) |
21 # Re-raise errors caught by the controller. | 21 # Re-raise errors caught by the controller. |
22 class BoardsController; def rescue_action(e) raise e end; end | 22 class BoardsController; def rescue_action(e) raise e end; end |
23 | 23 |
24 class BoardsControllerTest < ActionController::TestCase | 24 class BoardsControllerTest < ActionController::TestCase |
25 fixtures :projects, :users, :members, :member_roles, :roles, :boards, :messages, :enabled_modules | 25 fixtures :projects, :users, :members, :member_roles, :roles, :boards, :messages, :enabled_modules |
26 | 26 |
27 def setup | 27 def setup |
28 @controller = BoardsController.new | 28 @controller = BoardsController.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 end | 32 end |
33 | 33 |
34 def test_index | 34 def test_index |
35 get :index, :project_id => 1 | 35 get :index, :project_id => 1 |
36 assert_response :success | 36 assert_response :success |
37 assert_template 'index' | 37 assert_template 'index' |
38 assert_not_nil assigns(:boards) | 38 assert_not_nil assigns(:boards) |
39 assert_not_nil assigns(:project) | 39 assert_not_nil assigns(:project) |
40 end | 40 end |
41 | 41 |
42 def test_index_not_found | 42 def test_index_not_found |
43 get :index, :project_id => 97 | 43 get :index, :project_id => 97 |
44 assert_response 404 | 44 assert_response 404 |
45 end | 45 end |
46 | 46 |
47 def test_index_should_show_messages_if_only_one_board | 47 def test_index_should_show_messages_if_only_one_board |
48 Project.find(1).boards.slice(1..-1).each(&:destroy) | 48 Project.find(1).boards.slice(1..-1).each(&:destroy) |
49 | 49 |
50 get :index, :project_id => 1 | 50 get :index, :project_id => 1 |
51 assert_response :success | 51 assert_response :success |
52 assert_template 'show' | 52 assert_template 'show' |
53 assert_not_nil assigns(:topics) | 53 assert_not_nil assigns(:topics) |
54 end | 54 end |
55 | 55 |
56 def test_post_new | 56 def test_post_new |
57 @request.session[:user_id] = 2 | 57 @request.session[:user_id] = 2 |
58 assert_difference 'Board.count' do | 58 assert_difference 'Board.count' do |
59 post :new, :project_id => 1, :board => { :name => 'Testing', :description => 'Testing board creation'} | 59 post :new, :project_id => 1, :board => { :name => 'Testing', :description => 'Testing board creation'} |
60 end | 60 end |
61 assert_redirected_to '/projects/ecookbook/settings/boards' | 61 assert_redirected_to '/projects/ecookbook/settings/boards' |
62 end | 62 end |
63 | 63 |
64 def test_show | 64 def test_show |
65 get :show, :project_id => 1, :id => 1 | 65 get :show, :project_id => 1, :id => 1 |
66 assert_response :success | 66 assert_response :success |
67 assert_template 'show' | 67 assert_template 'show' |
68 assert_not_nil assigns(:board) | 68 assert_not_nil assigns(:board) |
69 assert_not_nil assigns(:project) | 69 assert_not_nil assigns(:project) |
70 assert_not_nil assigns(:topics) | 70 assert_not_nil assigns(:topics) |
71 end | 71 end |
72 | 72 |
73 def test_show_atom | 73 def test_show_atom |
74 get :show, :project_id => 1, :id => 1, :format => 'atom' | 74 get :show, :project_id => 1, :id => 1, :format => 'atom' |
75 assert_response :success | 75 assert_response :success |
76 assert_template 'common/feed.atom' | 76 assert_template 'common/feed.atom' |
77 assert_not_nil assigns(:board) | 77 assert_not_nil assigns(:board) |
78 assert_not_nil assigns(:project) | 78 assert_not_nil assigns(:project) |
79 assert_not_nil assigns(:messages) | 79 assert_not_nil assigns(:messages) |
80 end | 80 end |
81 | 81 |
82 def test_post_edit | 82 def test_post_edit |
83 @request.session[:user_id] = 2 | 83 @request.session[:user_id] = 2 |
84 assert_no_difference 'Board.count' do | 84 assert_no_difference 'Board.count' do |
85 post :edit, :project_id => 1, :id => 2, :board => { :name => 'Testing', :description => 'Testing board update'} | 85 post :edit, :project_id => 1, :id => 2, :board => { :name => 'Testing', :description => 'Testing board update'} |
86 end | 86 end |
87 assert_redirected_to '/projects/ecookbook/settings/boards' | 87 assert_redirected_to '/projects/ecookbook/settings/boards' |
88 assert_equal 'Testing', Board.find(2).name | 88 assert_equal 'Testing', Board.find(2).name |
89 end | 89 end |
90 | 90 |
91 def test_post_destroy | 91 def test_post_destroy |
92 @request.session[:user_id] = 2 | 92 @request.session[:user_id] = 2 |
93 assert_difference 'Board.count', -1 do | 93 assert_difference 'Board.count', -1 do |
94 post :destroy, :project_id => 1, :id => 2 | 94 post :destroy, :project_id => 1, :id => 2 |
95 end | 95 end |