annotate .svn/pristine/96/968c52a5e006bdb4585c4f356aec193b91c41bdd.svn-base @ 1524:82fac3dcf466 redmine-2.5-integration

Fix failure to interpret Javascript when autocompleting members for project
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Thu, 11 Sep 2014 10:24:38 +0100
parents e248c7af89ec
children
rev   line source
Chris@1494 1 # Redmine - project management software
Chris@1494 2 # Copyright (C) 2006-2014 Jean-Philippe Lang
Chris@1494 3 #
Chris@1494 4 # This program is free software; you can redistribute it and/or
Chris@1494 5 # modify it under the terms of the GNU General Public License
Chris@1494 6 # as published by the Free Software Foundation; either version 2
Chris@1494 7 # of the License, or (at your option) any later version.
Chris@1494 8 #
Chris@1494 9 # This program is distributed in the hope that it will be useful,
Chris@1494 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@1494 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@1494 12 # GNU General Public License for more details.
Chris@1494 13 #
Chris@1494 14 # You should have received a copy of the GNU General Public License
Chris@1494 15 # along with this program; if not, write to the Free Software
Chris@1494 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Chris@1494 17
Chris@1494 18 require File.expand_path('../../test_helper', __FILE__)
Chris@1494 19
Chris@1494 20 class EnumerationsControllerTest < ActionController::TestCase
Chris@1494 21 fixtures :enumerations, :issues, :users
Chris@1494 22
Chris@1494 23 def setup
Chris@1494 24 @request.session[:user_id] = 1 # admin
Chris@1494 25 end
Chris@1494 26
Chris@1494 27 def test_index
Chris@1494 28 get :index
Chris@1494 29 assert_response :success
Chris@1494 30 assert_template 'index'
Chris@1494 31 end
Chris@1494 32
Chris@1494 33 def test_index_should_require_admin
Chris@1494 34 @request.session[:user_id] = nil
Chris@1494 35 get :index
Chris@1494 36 assert_response 302
Chris@1494 37 end
Chris@1494 38
Chris@1494 39 def test_new
Chris@1494 40 get :new, :type => 'IssuePriority'
Chris@1494 41 assert_response :success
Chris@1494 42 assert_template 'new'
Chris@1494 43 assert_kind_of IssuePriority, assigns(:enumeration)
Chris@1494 44 assert_tag 'input', :attributes => {:name => 'enumeration[type]', :value => 'IssuePriority'}
Chris@1494 45 assert_tag 'input', :attributes => {:name => 'enumeration[name]'}
Chris@1494 46 end
Chris@1494 47
Chris@1494 48 def test_new_with_invalid_type_should_respond_with_404
Chris@1494 49 get :new, :type => 'UnknownType'
Chris@1494 50 assert_response 404
Chris@1494 51 end
Chris@1494 52
Chris@1494 53 def test_create
Chris@1494 54 assert_difference 'IssuePriority.count' do
Chris@1494 55 post :create, :enumeration => {:type => 'IssuePriority', :name => 'Lowest'}
Chris@1494 56 end
Chris@1494 57 assert_redirected_to '/enumerations'
Chris@1494 58 e = IssuePriority.find_by_name('Lowest')
Chris@1494 59 assert_not_nil e
Chris@1494 60 end
Chris@1494 61
Chris@1494 62 def test_create_with_failure
Chris@1494 63 assert_no_difference 'IssuePriority.count' do
Chris@1494 64 post :create, :enumeration => {:type => 'IssuePriority', :name => ''}
Chris@1494 65 end
Chris@1494 66 assert_response :success
Chris@1494 67 assert_template 'new'
Chris@1494 68 end
Chris@1494 69
Chris@1494 70 def test_edit
Chris@1494 71 get :edit, :id => 6
Chris@1494 72 assert_response :success
Chris@1494 73 assert_template 'edit'
Chris@1494 74 assert_tag 'input', :attributes => {:name => 'enumeration[name]', :value => 'High'}
Chris@1494 75 end
Chris@1494 76
Chris@1494 77 def test_edit_invalid_should_respond_with_404
Chris@1494 78 get :edit, :id => 999
Chris@1494 79 assert_response 404
Chris@1494 80 end
Chris@1494 81
Chris@1494 82 def test_update
Chris@1494 83 assert_no_difference 'IssuePriority.count' do
Chris@1494 84 put :update, :id => 6, :enumeration => {:type => 'IssuePriority', :name => 'New name'}
Chris@1494 85 end
Chris@1494 86 assert_redirected_to '/enumerations'
Chris@1494 87 e = IssuePriority.find(6)
Chris@1494 88 assert_equal 'New name', e.name
Chris@1494 89 end
Chris@1494 90
Chris@1494 91 def test_update_with_failure
Chris@1494 92 assert_no_difference 'IssuePriority.count' do
Chris@1494 93 put :update, :id => 6, :enumeration => {:type => 'IssuePriority', :name => ''}
Chris@1494 94 end
Chris@1494 95 assert_response :success
Chris@1494 96 assert_template 'edit'
Chris@1494 97 end
Chris@1494 98
Chris@1494 99 def test_destroy_enumeration_not_in_use
Chris@1494 100 assert_difference 'IssuePriority.count', -1 do
Chris@1494 101 delete :destroy, :id => 7
Chris@1494 102 end
Chris@1494 103 assert_redirected_to :controller => 'enumerations', :action => 'index'
Chris@1494 104 assert_nil Enumeration.find_by_id(7)
Chris@1494 105 end
Chris@1494 106
Chris@1494 107 def test_destroy_enumeration_in_use
Chris@1494 108 assert_no_difference 'IssuePriority.count' do
Chris@1494 109 delete :destroy, :id => 4
Chris@1494 110 end
Chris@1494 111 assert_response :success
Chris@1494 112 assert_template 'destroy'
Chris@1494 113 assert_not_nil Enumeration.find_by_id(4)
Chris@1494 114 assert_select 'select[name=reassign_to_id]' do
Chris@1494 115 assert_select 'option[value=6]', :text => 'High'
Chris@1494 116 end
Chris@1494 117 end
Chris@1494 118
Chris@1494 119 def test_destroy_enumeration_in_use_with_reassignment
Chris@1494 120 issue = Issue.where(:priority_id => 4).first
Chris@1494 121 assert_difference 'IssuePriority.count', -1 do
Chris@1494 122 delete :destroy, :id => 4, :reassign_to_id => 6
Chris@1494 123 end
Chris@1494 124 assert_redirected_to :controller => 'enumerations', :action => 'index'
Chris@1494 125 assert_nil Enumeration.find_by_id(4)
Chris@1494 126 # check that the issue was reassign
Chris@1494 127 assert_equal 6, issue.reload.priority_id
Chris@1494 128 end
Chris@1494 129
Chris@1494 130 def test_destroy_enumeration_in_use_with_blank_reassignment
Chris@1494 131 assert_no_difference 'IssuePriority.count' do
Chris@1494 132 delete :destroy, :id => 4, :reassign_to_id => ''
Chris@1494 133 end
Chris@1494 134 assert_response :success
Chris@1494 135 end
Chris@1494 136 end