annotate .svn/pristine/97/97df7b6827e22c2665eace13dd5952db27af0ff3.svn-base @ 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
rev   line source
Chris@1295 1 # Redmine - project management software
Chris@1295 2 # Copyright (C) 2006-2013 Jean-Philippe Lang
Chris@1295 3 #
Chris@1295 4 # This program is free software; you can redistribute it and/or
Chris@1295 5 # modify it under the terms of the GNU General Public License
Chris@1295 6 # as published by the Free Software Foundation; either version 2
Chris@1295 7 # of the License, or (at your option) any later version.
Chris@1295 8 #
Chris@1295 9 # This program is distributed in the hope that it will be useful,
Chris@1295 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@1295 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@1295 12 # GNU General Public License for more details.
Chris@1295 13 #
Chris@1295 14 # You should have received a copy of the GNU General Public License
Chris@1295 15 # along with this program; if not, write to the Free Software
Chris@1295 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Chris@1295 17
Chris@1295 18 require File.expand_path('../../test_helper', __FILE__)
Chris@1295 19
Chris@1295 20 class IssueStatusesControllerTest < ActionController::TestCase
Chris@1295 21 fixtures :issue_statuses, :issues, :users
Chris@1295 22
Chris@1295 23 def setup
Chris@1295 24 User.current = nil
Chris@1295 25 @request.session[:user_id] = 1 # admin
Chris@1295 26 end
Chris@1295 27
Chris@1295 28 def test_index
Chris@1295 29 get :index
Chris@1295 30 assert_response :success
Chris@1295 31 assert_template 'index'
Chris@1295 32 end
Chris@1295 33
Chris@1295 34 def test_index_by_anonymous_should_redirect_to_login_form
Chris@1295 35 @request.session[:user_id] = nil
Chris@1295 36 get :index
Chris@1295 37 assert_redirected_to '/login?back_url=http%3A%2F%2Ftest.host%2Fissue_statuses'
Chris@1295 38 end
Chris@1295 39
Chris@1295 40 def test_index_by_user_should_respond_with_406
Chris@1295 41 @request.session[:user_id] = 2
Chris@1295 42 get :index
Chris@1295 43 assert_response 406
Chris@1295 44 end
Chris@1295 45
Chris@1295 46 def test_new
Chris@1295 47 get :new
Chris@1295 48 assert_response :success
Chris@1295 49 assert_template 'new'
Chris@1295 50 end
Chris@1295 51
Chris@1295 52 def test_create
Chris@1295 53 assert_difference 'IssueStatus.count' do
Chris@1295 54 post :create, :issue_status => {:name => 'New status'}
Chris@1295 55 end
Chris@1295 56 assert_redirected_to :action => 'index'
Chris@1295 57 status = IssueStatus.order('id DESC').first
Chris@1295 58 assert_equal 'New status', status.name
Chris@1295 59 end
Chris@1295 60
Chris@1295 61 def test_create_with_failure
Chris@1295 62 post :create, :issue_status => {:name => ''}
Chris@1295 63 assert_response :success
Chris@1295 64 assert_template 'new'
Chris@1295 65 assert_error_tag :content => /name can&#x27;t be blank/i
Chris@1295 66 end
Chris@1295 67
Chris@1295 68 def test_edit
Chris@1295 69 get :edit, :id => '3'
Chris@1295 70 assert_response :success
Chris@1295 71 assert_template 'edit'
Chris@1295 72 end
Chris@1295 73
Chris@1295 74 def test_update
Chris@1295 75 put :update, :id => '3', :issue_status => {:name => 'Renamed status'}
Chris@1295 76 assert_redirected_to :action => 'index'
Chris@1295 77 status = IssueStatus.find(3)
Chris@1295 78 assert_equal 'Renamed status', status.name
Chris@1295 79 end
Chris@1295 80
Chris@1295 81 def test_update_with_failure
Chris@1295 82 put :update, :id => '3', :issue_status => {:name => ''}
Chris@1295 83 assert_response :success
Chris@1295 84 assert_template 'edit'
Chris@1295 85 assert_error_tag :content => /name can&#x27;t be blank/i
Chris@1295 86 end
Chris@1295 87
Chris@1295 88 def test_destroy
Chris@1295 89 Issue.delete_all("status_id = 1")
Chris@1295 90
Chris@1295 91 assert_difference 'IssueStatus.count', -1 do
Chris@1295 92 delete :destroy, :id => '1'
Chris@1295 93 end
Chris@1295 94 assert_redirected_to :action => 'index'
Chris@1295 95 assert_nil IssueStatus.find_by_id(1)
Chris@1295 96 end
Chris@1295 97
Chris@1295 98 def test_destroy_should_block_if_status_in_use
Chris@1295 99 assert_not_nil Issue.find_by_status_id(1)
Chris@1295 100
Chris@1295 101 assert_no_difference 'IssueStatus.count' do
Chris@1295 102 delete :destroy, :id => '1'
Chris@1295 103 end
Chris@1295 104 assert_redirected_to :action => 'index'
Chris@1295 105 assert_not_nil IssueStatus.find_by_id(1)
Chris@1295 106 end
Chris@1295 107
Chris@1295 108 def test_update_issue_done_ratio_with_issue_done_ratio_set_to_issue_field
Chris@1295 109 with_settings :issue_done_ratio => 'issue_field' do
Chris@1295 110 post :update_issue_done_ratio
Chris@1295 111 assert_match /not updated/, flash[:error].to_s
Chris@1295 112 assert_redirected_to '/issue_statuses'
Chris@1295 113 end
Chris@1295 114 end
Chris@1295 115
Chris@1295 116 def test_update_issue_done_ratio_with_issue_done_ratio_set_to_issue_status
Chris@1295 117 with_settings :issue_done_ratio => 'issue_status' do
Chris@1295 118 post :update_issue_done_ratio
Chris@1295 119 assert_match /Issue done ratios updated/, flash[:notice].to_s
Chris@1295 120 assert_redirected_to '/issue_statuses'
Chris@1295 121 end
Chris@1295 122 end
Chris@1295 123 end