annotate .svn/pristine/f7/f7c2b45b45491e8fd7f3b0695d07f65e9f19cf76.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 RepositoriesDarcsControllerTest < ActionController::TestCase
Chris@1494 21 tests RepositoriesController
Chris@1494 22
Chris@1494 23 fixtures :projects, :users, :roles, :members, :member_roles,
Chris@1494 24 :repositories, :enabled_modules
Chris@1494 25
Chris@1494 26 REPOSITORY_PATH = Rails.root.join('tmp/test/darcs_repository').to_s
Chris@1494 27 PRJ_ID = 3
Chris@1494 28 NUM_REV = 6
Chris@1494 29
Chris@1494 30 def setup
Chris@1494 31 User.current = nil
Chris@1494 32 @project = Project.find(PRJ_ID)
Chris@1494 33 @repository = Repository::Darcs.create(
Chris@1494 34 :project => @project,
Chris@1494 35 :url => REPOSITORY_PATH,
Chris@1494 36 :log_encoding => 'UTF-8'
Chris@1494 37 )
Chris@1494 38 assert @repository
Chris@1494 39 end
Chris@1494 40
Chris@1494 41 if File.directory?(REPOSITORY_PATH)
Chris@1494 42 def test_get_new
Chris@1494 43 @request.session[:user_id] = 1
Chris@1494 44 @project.repository.destroy
Chris@1494 45 get :new, :project_id => 'subproject1', :repository_scm => 'Darcs'
Chris@1494 46 assert_response :success
Chris@1494 47 assert_template 'new'
Chris@1494 48 assert_kind_of Repository::Darcs, assigns(:repository)
Chris@1494 49 assert assigns(:repository).new_record?
Chris@1494 50 end
Chris@1494 51
Chris@1494 52 def test_browse_root
Chris@1494 53 assert_equal 0, @repository.changesets.count
Chris@1494 54 @repository.fetch_changesets
Chris@1494 55 @project.reload
Chris@1494 56 assert_equal NUM_REV, @repository.changesets.count
Chris@1494 57 get :show, :id => PRJ_ID
Chris@1494 58 assert_response :success
Chris@1494 59 assert_template 'show'
Chris@1494 60 assert_not_nil assigns(:entries)
Chris@1494 61 assert_equal 3, assigns(:entries).size
Chris@1494 62 assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'}
Chris@1494 63 assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'}
Chris@1494 64 assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'}
Chris@1494 65 end
Chris@1494 66
Chris@1494 67 def test_browse_directory
Chris@1494 68 assert_equal 0, @repository.changesets.count
Chris@1494 69 @repository.fetch_changesets
Chris@1494 70 @project.reload
Chris@1494 71 assert_equal NUM_REV, @repository.changesets.count
Chris@1494 72 get :show, :id => PRJ_ID, :path => repository_path_hash(['images'])[:param]
Chris@1494 73 assert_response :success
Chris@1494 74 assert_template 'show'
Chris@1494 75 assert_not_nil assigns(:entries)
Chris@1494 76 assert_equal ['delete.png', 'edit.png'], assigns(:entries).collect(&:name)
Chris@1494 77 entry = assigns(:entries).detect {|e| e.name == 'edit.png'}
Chris@1494 78 assert_not_nil entry
Chris@1494 79 assert_equal 'file', entry.kind
Chris@1494 80 assert_equal 'images/edit.png', entry.path
Chris@1494 81 end
Chris@1494 82
Chris@1494 83 def test_browse_at_given_revision
Chris@1494 84 assert_equal 0, @repository.changesets.count
Chris@1494 85 @repository.fetch_changesets
Chris@1494 86 @project.reload
Chris@1494 87 assert_equal NUM_REV, @repository.changesets.count
Chris@1494 88 get :show, :id => PRJ_ID, :path => repository_path_hash(['images'])[:param],
Chris@1494 89 :rev => 1
Chris@1494 90 assert_response :success
Chris@1494 91 assert_template 'show'
Chris@1494 92 assert_not_nil assigns(:entries)
Chris@1494 93 assert_equal ['delete.png'], assigns(:entries).collect(&:name)
Chris@1494 94 end
Chris@1494 95
Chris@1494 96 def test_changes
Chris@1494 97 assert_equal 0, @repository.changesets.count
Chris@1494 98 @repository.fetch_changesets
Chris@1494 99 @project.reload
Chris@1494 100 assert_equal NUM_REV, @repository.changesets.count
Chris@1494 101 get :changes, :id => PRJ_ID,
Chris@1494 102 :path => repository_path_hash(['images', 'edit.png'])[:param]
Chris@1494 103 assert_response :success
Chris@1494 104 assert_template 'changes'
Chris@1494 105 assert_tag :tag => 'h2', :content => 'edit.png'
Chris@1494 106 end
Chris@1494 107
Chris@1494 108 def test_diff
Chris@1494 109 assert_equal 0, @repository.changesets.count
Chris@1494 110 @repository.fetch_changesets
Chris@1494 111 @project.reload
Chris@1494 112 assert_equal NUM_REV, @repository.changesets.count
Chris@1494 113 # Full diff of changeset 5
Chris@1494 114 ['inline', 'sbs'].each do |dt|
Chris@1494 115 get :diff, :id => PRJ_ID, :rev => 5, :type => dt
Chris@1494 116 assert_response :success
Chris@1494 117 assert_template 'diff'
Chris@1494 118 # Line 22 removed
Chris@1494 119 assert_tag :tag => 'th',
Chris@1494 120 :content => '22',
Chris@1494 121 :sibling => { :tag => 'td',
Chris@1494 122 :attributes => { :class => /diff_out/ },
Chris@1494 123 :content => /def remove/ }
Chris@1494 124 end
Chris@1494 125 end
Chris@1494 126
Chris@1494 127 def test_destroy_valid_repository
Chris@1494 128 @request.session[:user_id] = 1 # admin
Chris@1494 129 assert_equal 0, @repository.changesets.count
Chris@1494 130 @repository.fetch_changesets
Chris@1494 131 @project.reload
Chris@1494 132 assert_equal NUM_REV, @repository.changesets.count
Chris@1494 133
Chris@1494 134 assert_difference 'Repository.count', -1 do
Chris@1494 135 delete :destroy, :id => @repository.id
Chris@1494 136 end
Chris@1494 137 assert_response 302
Chris@1494 138 @project.reload
Chris@1494 139 assert_nil @project.repository
Chris@1494 140 end
Chris@1494 141
Chris@1494 142 def test_destroy_invalid_repository
Chris@1494 143 @request.session[:user_id] = 1 # admin
Chris@1494 144 @project.repository.destroy
Chris@1494 145 @repository = Repository::Darcs.create!(
Chris@1494 146 :project => @project,
Chris@1494 147 :url => "/invalid",
Chris@1494 148 :log_encoding => 'UTF-8'
Chris@1494 149 )
Chris@1494 150 @repository.fetch_changesets
Chris@1494 151 @project.reload
Chris@1494 152 assert_equal 0, @repository.changesets.count
Chris@1494 153
Chris@1494 154 assert_difference 'Repository.count', -1 do
Chris@1494 155 delete :destroy, :id => @repository.id
Chris@1494 156 end
Chris@1494 157 assert_response 302
Chris@1494 158 @project.reload
Chris@1494 159 assert_nil @project.repository
Chris@1494 160 end
Chris@1494 161 else
Chris@1494 162 puts "Darcs test repository NOT FOUND. Skipping functional tests !!!"
Chris@1494 163 def test_fake; assert true end
Chris@1494 164 end
Chris@1494 165 end