annotate .svn/pristine/b0/b02c60eec1517017e4be344103ca5e9fef268321.svn-base @ 1519:afce8026aaeb redmine-2.4-integration

Merge from branch "live"
author Chris Cannam
date Tue, 09 Sep 2014 09:34:53 +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 RepositoryDarcsTest < ActiveSupport::TestCase
Chris@1494 21 fixtures :projects
Chris@1494 22
Chris@1494 23 include Redmine::I18n
Chris@1494 24
Chris@1494 25 REPOSITORY_PATH = Rails.root.join('tmp/test/darcs_repository').to_s
Chris@1494 26 NUM_REV = 6
Chris@1494 27
Chris@1494 28 def setup
Chris@1494 29 @project = Project.find(3)
Chris@1494 30 @repository = Repository::Darcs.create(
Chris@1494 31 :project => @project,
Chris@1494 32 :url => REPOSITORY_PATH,
Chris@1494 33 :log_encoding => 'UTF-8'
Chris@1494 34 )
Chris@1494 35 assert @repository
Chris@1494 36 end
Chris@1494 37
Chris@1494 38 def test_blank_path_to_repository_error_message
Chris@1494 39 set_language_if_valid 'en'
Chris@1494 40 repo = Repository::Darcs.new(
Chris@1494 41 :project => @project,
Chris@1494 42 :identifier => 'test',
Chris@1494 43 :log_encoding => 'UTF-8'
Chris@1494 44 )
Chris@1494 45 assert !repo.save
Chris@1494 46 assert_include "Path to repository can't be blank",
Chris@1494 47 repo.errors.full_messages
Chris@1494 48 end
Chris@1494 49
Chris@1494 50 def test_blank_path_to_repository_error_message_fr
Chris@1494 51 set_language_if_valid 'fr'
Chris@1494 52 str = "Chemin du d\xc3\xa9p\xc3\xb4t doit \xc3\xaatre renseign\xc3\xa9(e)"
Chris@1494 53 str.force_encoding('UTF-8') if str.respond_to?(:force_encoding)
Chris@1494 54 repo = Repository::Darcs.new(
Chris@1494 55 :project => @project,
Chris@1494 56 :url => "",
Chris@1494 57 :identifier => 'test',
Chris@1494 58 :log_encoding => 'UTF-8'
Chris@1494 59 )
Chris@1494 60 assert !repo.save
Chris@1494 61 assert_include str, repo.errors.full_messages
Chris@1494 62 end
Chris@1494 63
Chris@1494 64 if File.directory?(REPOSITORY_PATH)
Chris@1494 65 def test_fetch_changesets_from_scratch
Chris@1494 66 assert_equal 0, @repository.changesets.count
Chris@1494 67 @repository.fetch_changesets
Chris@1494 68 @project.reload
Chris@1494 69
Chris@1494 70 assert_equal NUM_REV, @repository.changesets.count
Chris@1494 71 assert_equal 13, @repository.filechanges.count
Chris@1494 72 assert_equal "Initial commit.", @repository.changesets.find_by_revision('1').comments
Chris@1494 73 end
Chris@1494 74
Chris@1494 75 def test_fetch_changesets_incremental
Chris@1494 76 assert_equal 0, @repository.changesets.count
Chris@1494 77 @repository.fetch_changesets
Chris@1494 78 @project.reload
Chris@1494 79 assert_equal NUM_REV, @repository.changesets.count
Chris@1494 80
Chris@1494 81 # Remove changesets with revision > 3
Chris@1494 82 @repository.changesets.all.each {|c| c.destroy if c.revision.to_i > 3}
Chris@1494 83 @project.reload
Chris@1494 84 assert_equal 3, @repository.changesets.count
Chris@1494 85
Chris@1494 86 @repository.fetch_changesets
Chris@1494 87 @project.reload
Chris@1494 88 assert_equal NUM_REV, @repository.changesets.count
Chris@1494 89 end
Chris@1494 90
Chris@1494 91 def test_entries
Chris@1494 92 entries = @repository.entries
Chris@1494 93 assert_kind_of Redmine::Scm::Adapters::Entries, entries
Chris@1494 94 end
Chris@1494 95
Chris@1494 96 def test_entries_invalid_revision
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 assert_nil @repository.entries('', '123')
Chris@1494 102 end
Chris@1494 103
Chris@1494 104 def test_deleted_files_should_not_be_listed
Chris@1494 105 assert_equal 0, @repository.changesets.count
Chris@1494 106 @repository.fetch_changesets
Chris@1494 107 @project.reload
Chris@1494 108 assert_equal NUM_REV, @repository.changesets.count
Chris@1494 109 entries = @repository.entries('sources')
Chris@1494 110 assert entries.detect {|e| e.name == 'watchers_controller.rb'}
Chris@1494 111 assert_nil entries.detect {|e| e.name == 'welcome_controller.rb'}
Chris@1494 112 end
Chris@1494 113
Chris@1494 114 def test_cat
Chris@1494 115 if @repository.scm.supports_cat?
Chris@1494 116 assert_equal 0, @repository.changesets.count
Chris@1494 117 @repository.fetch_changesets
Chris@1494 118 @project.reload
Chris@1494 119 assert_equal NUM_REV, @repository.changesets.count
Chris@1494 120 cat = @repository.cat("sources/welcome_controller.rb", 2)
Chris@1494 121 assert_not_nil cat
Chris@1494 122 assert cat.include?('class WelcomeController < ApplicationController')
Chris@1494 123 end
Chris@1494 124 end
Chris@1494 125 else
Chris@1494 126 puts "Darcs test repository NOT FOUND. Skipping unit tests !!!"
Chris@1494 127 def test_fake; assert true end
Chris@1494 128 end
Chris@1494 129 end