annotate .svn/pristine/65/654eed5f8ba853c7ac2821da31a191c9de40b17b.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 SysControllerTest < ActionController::TestCase
Chris@1494 21 fixtures :projects, :repositories, :enabled_modules
Chris@1494 22
Chris@1494 23 def setup
Chris@1494 24 Setting.sys_api_enabled = '1'
Chris@1494 25 Setting.enabled_scm = %w(Subversion Git)
Chris@1494 26 end
Chris@1494 27
Chris@1494 28 def teardown
Chris@1494 29 Setting.clear_cache
Chris@1494 30 end
Chris@1494 31
Chris@1494 32 def test_projects_with_repository_enabled
Chris@1494 33 get :projects
Chris@1494 34 assert_response :success
Chris@1494 35 assert_equal 'application/xml', @response.content_type
Chris@1494 36 with_options :tag => 'projects' do |test|
Chris@1494 37 test.assert_tag :children => { :count => Project.active.has_module(:repository).count }
Chris@1494 38 test.assert_tag 'project', :child => {:tag => 'identifier', :sibling => {:tag => 'is-public'}}
Chris@1494 39 end
Chris@1494 40 assert_no_tag 'extra-info'
Chris@1494 41 assert_no_tag 'extra_info'
Chris@1494 42 end
Chris@1494 43
Chris@1494 44 def test_create_project_repository
Chris@1494 45 assert_nil Project.find(4).repository
Chris@1494 46
Chris@1494 47 post :create_project_repository, :id => 4,
Chris@1494 48 :vendor => 'Subversion',
Chris@1494 49 :repository => { :url => 'file:///create/project/repository/subproject2'}
Chris@1494 50 assert_response :created
Chris@1494 51 assert_equal 'application/xml', @response.content_type
Chris@1494 52
Chris@1494 53 r = Project.find(4).repository
Chris@1494 54 assert r.is_a?(Repository::Subversion)
Chris@1494 55 assert_equal 'file:///create/project/repository/subproject2', r.url
Chris@1494 56
Chris@1494 57 assert_tag 'repository-subversion',
Chris@1494 58 :child => {
Chris@1494 59 :tag => 'id', :content => r.id.to_s,
Chris@1494 60 :sibling => {:tag => 'url', :content => r.url}
Chris@1494 61 }
Chris@1494 62 assert_no_tag 'extra-info'
Chris@1494 63 assert_no_tag 'extra_info'
Chris@1494 64 end
Chris@1494 65
Chris@1494 66 def test_create_already_existing
Chris@1494 67 post :create_project_repository, :id => 1,
Chris@1494 68 :vendor => 'Subversion',
Chris@1494 69 :repository => { :url => 'file:///create/project/repository/subproject2'}
Chris@1494 70
Chris@1494 71 assert_response :conflict
Chris@1494 72 end
Chris@1494 73
Chris@1494 74 def test_create_with_failure
Chris@1494 75 post :create_project_repository, :id => 4,
Chris@1494 76 :vendor => 'Subversion',
Chris@1494 77 :repository => { :url => 'invalid url'}
Chris@1494 78
Chris@1494 79 assert_response :unprocessable_entity
Chris@1494 80 end
Chris@1494 81
Chris@1494 82 def test_fetch_changesets
Chris@1494 83 Repository::Subversion.any_instance.expects(:fetch_changesets).twice.returns(true)
Chris@1494 84 get :fetch_changesets
Chris@1494 85 assert_response :success
Chris@1494 86 end
Chris@1494 87
Chris@1494 88 def test_fetch_changesets_one_project_by_identifier
Chris@1494 89 Repository::Subversion.any_instance.expects(:fetch_changesets).once.returns(true)
Chris@1494 90 get :fetch_changesets, :id => 'ecookbook'
Chris@1494 91 assert_response :success
Chris@1494 92 end
Chris@1494 93
Chris@1494 94 def test_fetch_changesets_one_project_by_id
Chris@1494 95 Repository::Subversion.any_instance.expects(:fetch_changesets).once.returns(true)
Chris@1494 96 get :fetch_changesets, :id => '1'
Chris@1494 97 assert_response :success
Chris@1494 98 end
Chris@1494 99
Chris@1494 100 def test_fetch_changesets_unknown_project
Chris@1494 101 get :fetch_changesets, :id => 'unknown'
Chris@1494 102 assert_response 404
Chris@1494 103 end
Chris@1494 104
Chris@1494 105 def test_disabled_ws_should_respond_with_403_error
Chris@1494 106 with_settings :sys_api_enabled => '0' do
Chris@1494 107 get :projects
Chris@1494 108 assert_response 403
Chris@1494 109 end
Chris@1494 110 end
Chris@1494 111
Chris@1494 112 def test_api_key
Chris@1494 113 with_settings :sys_api_key => 'my_secret_key' do
Chris@1494 114 get :projects, :key => 'my_secret_key'
Chris@1494 115 assert_response :success
Chris@1494 116 end
Chris@1494 117 end
Chris@1494 118
Chris@1494 119 def test_wrong_key_should_respond_with_403_error
Chris@1494 120 with_settings :sys_api_enabled => 'my_secret_key' do
Chris@1494 121 get :projects, :key => 'wrong_key'
Chris@1494 122 assert_response 403
Chris@1494 123 end
Chris@1494 124 end
Chris@1494 125 end