2010-03-06 23:35:38 +03:00
|
|
|
require File.dirname(__FILE__) + '/../../../../../test_helper'
|
2009-08-16 02:41:40 +04:00
|
|
|
|
2009-09-13 21:14:35 +04:00
|
|
|
class GitAdapterTest < ActiveSupport::TestCase
|
2009-08-16 02:41:40 +04:00
|
|
|
REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/git_repository'
|
|
|
|
|
|
|
|
if File.directory?(REPOSITORY_PATH)
|
|
|
|
def setup
|
|
|
|
@adapter = Redmine::Scm::Adapters::GitAdapter.new(REPOSITORY_PATH)
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_branches
|
|
|
|
assert_equal @adapter.branches, ['master', 'test_branch']
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_getting_all_revisions
|
2010-07-06 06:07:46 +04:00
|
|
|
assert_equal 13, @adapter.revisions('',nil,nil,:all => true).length
|
2009-08-16 02:41:40 +04:00
|
|
|
end
|
2010-02-28 15:09:09 +03:00
|
|
|
|
2010-08-08 11:07:30 +04:00
|
|
|
def test_getting_certain_revisions
|
|
|
|
assert_equal 1, @adapter.revisions('','899a15d^','899a15d').length
|
|
|
|
end
|
|
|
|
|
2010-02-28 15:09:09 +03:00
|
|
|
def test_annotate
|
|
|
|
annotate = @adapter.annotate('sources/watchers_controller.rb')
|
|
|
|
assert_kind_of Redmine::Scm::Adapters::Annotate, annotate
|
|
|
|
assert_equal 41, annotate.lines.size
|
2010-03-04 00:15:46 +03:00
|
|
|
assert_equal "# This program is free software; you can redistribute it and/or", annotate.lines[4].strip
|
|
|
|
assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", annotate.revisions[4].identifier
|
|
|
|
assert_equal "jsmith", annotate.revisions[4].author
|
2010-02-28 15:09:09 +03:00
|
|
|
end
|
|
|
|
|
2010-09-26 22:41:06 +04:00
|
|
|
def test_last_rev
|
|
|
|
last_rev = @adapter.lastrev("README", "4f26664364207fa8b1af9f8722647ab2d4ac5d43")
|
|
|
|
assert_equal "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8", last_rev.scmid
|
|
|
|
assert_equal "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8", last_rev.identifier
|
|
|
|
assert_equal "Adam Soltys <asoltys@gmail.com>", last_rev.author
|
|
|
|
assert_equal "2009-06-24 05:27:38".to_time, last_rev.time
|
|
|
|
end
|
|
|
|
|
2010-02-28 15:09:09 +03:00
|
|
|
def test_annotate_moved_file
|
|
|
|
annotate = @adapter.annotate('renamed_test.txt')
|
|
|
|
assert_kind_of Redmine::Scm::Adapters::Annotate, annotate
|
|
|
|
assert_equal 2, annotate.lines.size
|
|
|
|
end
|
2009-08-16 02:41:40 +04:00
|
|
|
else
|
|
|
|
puts "Git test repository NOT FOUND. Skipping unit tests !!!"
|
|
|
|
def test_fake; assert true end
|
|
|
|
end
|
|
|
|
end
|