To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / test / functional / boards_controller_test.rb @ 442:753f1380d6bc
History | View | Annotate | Download (3.19 KB)
| 1 |
# Redmine - project management software
|
|---|---|
| 2 |
# Copyright (C) 2006-2009 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 |
require 'boards_controller'
|
| 20 |
|
| 21 |
# Re-raise errors caught by the controller.
|
| 22 |
class BoardsController; def rescue_action(e) raise e end; end |
| 23 |
|
| 24 |
class BoardsControllerTest < ActionController::TestCase |
| 25 |
fixtures :projects, :users, :members, :member_roles, :roles, :boards, :messages, :enabled_modules |
| 26 |
|
| 27 |
def setup |
| 28 |
@controller = BoardsController.new |
| 29 |
@request = ActionController::TestRequest.new |
| 30 |
@response = ActionController::TestResponse.new |
| 31 |
User.current = nil |
| 32 |
end
|
| 33 |
|
| 34 |
def test_index |
| 35 |
get :index, :project_id => 1 |
| 36 |
assert_response :success
|
| 37 |
assert_template 'index'
|
| 38 |
assert_not_nil assigns(:boards)
|
| 39 |
assert_not_nil assigns(:project)
|
| 40 |
end
|
| 41 |
|
| 42 |
def test_index_not_found |
| 43 |
get :index, :project_id => 97 |
| 44 |
assert_response 404
|
| 45 |
end
|
| 46 |
|
| 47 |
def test_index_should_show_messages_if_only_one_board |
| 48 |
Project.find(1).boards.slice(1..-1).each(&:destroy) |
| 49 |
|
| 50 |
get :index, :project_id => 1 |
| 51 |
assert_response :success
|
| 52 |
assert_template 'show'
|
| 53 |
assert_not_nil assigns(:topics)
|
| 54 |
end
|
| 55 |
|
| 56 |
def test_post_new |
| 57 |
@request.session[:user_id] = 2 |
| 58 |
assert_difference 'Board.count' do |
| 59 |
post :new, :project_id => 1, :board => { :name => 'Testing', :description => 'Testing board creation'} |
| 60 |
end
|
| 61 |
assert_redirected_to '/projects/ecookbook/settings/boards'
|
| 62 |
end
|
| 63 |
|
| 64 |
def test_show |
| 65 |
get :show, :project_id => 1, :id => 1 |
| 66 |
assert_response :success
|
| 67 |
assert_template 'show'
|
| 68 |
assert_not_nil assigns(:board)
|
| 69 |
assert_not_nil assigns(:project)
|
| 70 |
assert_not_nil assigns(:topics)
|
| 71 |
end
|
| 72 |
|
| 73 |
def test_show_atom |
| 74 |
get :show, :project_id => 1, :id => 1, :format => 'atom' |
| 75 |
assert_response :success
|
| 76 |
assert_template 'common/feed.atom'
|
| 77 |
assert_not_nil assigns(:board)
|
| 78 |
assert_not_nil assigns(:project)
|
| 79 |
assert_not_nil assigns(:messages)
|
| 80 |
end
|
| 81 |
|
| 82 |
def test_post_edit |
| 83 |
@request.session[:user_id] = 2 |
| 84 |
assert_no_difference 'Board.count' do |
| 85 |
post :edit, :project_id => 1, :id => 2, :board => { :name => 'Testing', :description => 'Testing board update'} |
| 86 |
end
|
| 87 |
assert_redirected_to '/projects/ecookbook/settings/boards'
|
| 88 |
assert_equal 'Testing', Board.find(2).name |
| 89 |
end
|
| 90 |
|
| 91 |
def test_post_destroy |
| 92 |
@request.session[:user_id] = 2 |
| 93 |
assert_difference 'Board.count', -1 do |
| 94 |
post :destroy, :project_id => 1, :id => 2 |
| 95 |
end
|
| 96 |
assert_redirected_to '/projects/ecookbook/settings/boards'
|
| 97 |
assert_nil Board.find_by_id(2) |
| 98 |
end
|
| 99 |
end
|