@@ -1,130 +1,140 | |||
|
1 | 1 | # Redmine - project management software |
|
2 | 2 | # Copyright (C) 2006-2011 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | require File.expand_path('../../test_helper', __FILE__) |
|
19 | 19 | |
|
20 | 20 | class BoardsControllerTest < ActionController::TestCase |
|
21 | 21 | fixtures :projects, :users, :members, :member_roles, :roles, :boards, :messages, :enabled_modules |
|
22 | 22 | |
|
23 | 23 | def setup |
|
24 | 24 | User.current = nil |
|
25 | 25 | end |
|
26 | 26 | |
|
27 | 27 | def test_index |
|
28 | 28 | get :index, :project_id => 1 |
|
29 | 29 | assert_response :success |
|
30 | 30 | assert_template 'index' |
|
31 | 31 | assert_not_nil assigns(:boards) |
|
32 | 32 | assert_not_nil assigns(:project) |
|
33 | 33 | end |
|
34 | 34 | |
|
35 | 35 | def test_index_not_found |
|
36 | 36 | get :index, :project_id => 97 |
|
37 | 37 | assert_response 404 |
|
38 | 38 | end |
|
39 | 39 | |
|
40 | 40 | def test_index_should_show_messages_if_only_one_board |
|
41 | 41 | Project.find(1).boards.slice(1..-1).each(&:destroy) |
|
42 | 42 | |
|
43 | 43 | get :index, :project_id => 1 |
|
44 | 44 | assert_response :success |
|
45 | 45 | assert_template 'show' |
|
46 | 46 | assert_not_nil assigns(:topics) |
|
47 | 47 | end |
|
48 | 48 | |
|
49 | 49 | def test_show |
|
50 | 50 | get :show, :project_id => 1, :id => 1 |
|
51 | 51 | assert_response :success |
|
52 | 52 | assert_template 'show' |
|
53 | 53 | assert_not_nil assigns(:board) |
|
54 | 54 | assert_not_nil assigns(:project) |
|
55 | 55 | assert_not_nil assigns(:topics) |
|
56 | 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 | 68 | def test_show_atom |
|
59 | 69 | get :show, :project_id => 1, :id => 1, :format => 'atom' |
|
60 | 70 | assert_response :success |
|
61 | 71 | assert_template 'common/feed.atom' |
|
62 | 72 | assert_not_nil assigns(:board) |
|
63 | 73 | assert_not_nil assigns(:project) |
|
64 | 74 | assert_not_nil assigns(:messages) |
|
65 | 75 | end |
|
66 | 76 | |
|
67 | 77 | def test_show_not_found |
|
68 | 78 | get :index, :project_id => 1, :id => 97 |
|
69 | 79 | assert_response 404 |
|
70 | 80 | end |
|
71 | 81 | |
|
72 | 82 | def test_new |
|
73 | 83 | @request.session[:user_id] = 2 |
|
74 | 84 | get :new, :project_id => 1 |
|
75 | 85 | assert_response :success |
|
76 | 86 | assert_template 'new' |
|
77 | 87 | end |
|
78 | 88 | |
|
79 | 89 | def test_create |
|
80 | 90 | @request.session[:user_id] = 2 |
|
81 | 91 | assert_difference 'Board.count' do |
|
82 | 92 | post :create, :project_id => 1, :board => { :name => 'Testing', :description => 'Testing board creation'} |
|
83 | 93 | end |
|
84 | 94 | assert_redirected_to '/projects/ecookbook/settings/boards' |
|
85 | 95 | board = Board.first(:order => 'id DESC') |
|
86 | 96 | assert_equal 'Testing', board.name |
|
87 | 97 | assert_equal 'Testing board creation', board.description |
|
88 | 98 | end |
|
89 | 99 | |
|
90 | 100 | def test_create_with_failure |
|
91 | 101 | @request.session[:user_id] = 2 |
|
92 | 102 | assert_no_difference 'Board.count' do |
|
93 | 103 | post :create, :project_id => 1, :board => { :name => '', :description => 'Testing board creation'} |
|
94 | 104 | end |
|
95 | 105 | assert_response :success |
|
96 | 106 | assert_template 'new' |
|
97 | 107 | end |
|
98 | 108 | |
|
99 | 109 | def test_edit |
|
100 | 110 | @request.session[:user_id] = 2 |
|
101 | 111 | get :edit, :project_id => 1, :id => 2 |
|
102 | 112 | assert_response :success |
|
103 | 113 | assert_template 'edit' |
|
104 | 114 | end |
|
105 | 115 | |
|
106 | 116 | def test_update |
|
107 | 117 | @request.session[:user_id] = 2 |
|
108 | 118 | assert_no_difference 'Board.count' do |
|
109 | 119 | put :update, :project_id => 1, :id => 2, :board => { :name => 'Testing', :description => 'Testing board update'} |
|
110 | 120 | end |
|
111 | 121 | assert_redirected_to '/projects/ecookbook/settings/boards' |
|
112 | 122 | assert_equal 'Testing', Board.find(2).name |
|
113 | 123 | end |
|
114 | 124 | |
|
115 | 125 | def test_update_with_failure |
|
116 | 126 | @request.session[:user_id] = 2 |
|
117 | 127 | put :update, :project_id => 1, :id => 2, :board => { :name => '', :description => 'Testing board update'} |
|
118 | 128 | assert_response :success |
|
119 | 129 | assert_template 'edit' |
|
120 | 130 | end |
|
121 | 131 | |
|
122 | 132 | def test_destroy |
|
123 | 133 | @request.session[:user_id] = 2 |
|
124 | 134 | assert_difference 'Board.count', -1 do |
|
125 | 135 | delete :destroy, :project_id => 1, :id => 2 |
|
126 | 136 | end |
|
127 | 137 | assert_redirected_to '/projects/ecookbook/settings/boards' |
|
128 | 138 | assert_nil Board.find_by_id(2) |
|
129 | 139 | end |
|
130 | 140 | end |
General Comments 0
You need to be logged in to leave comments.
Login now