Commit 89627d03 authored by Toshi MARUYAMA's avatar Toshi MARUYAMA

scm: mercurial: fix error on revision page for empty revision (#7307).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4704 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 98b3a506
......@@ -71,6 +71,7 @@ class Repository::Mercurial < Repository
# Finds and returns a revision with a number or the beginning of a hash
def find_changeset_by_name(name)
return nil if name.nil? || name.empty?
if /[^\d]/ =~ name or name.to_s.size > 8
e = changesets.find(:first, :conditions => ['scmid = ?', name.to_s])
else
......
......@@ -195,6 +195,16 @@ class RepositoriesMercurialControllerTest < ActionController::TestCase
:attributes => { :class => 'line-num' },
:sibling => { :tag => 'td', :content => /watcher =/ }
end
def test_empty_revision
@repository.fetch_changesets
@repository.reload
['', ' ', nil].each do |r|
get :revision, :id => 1, :rev => r
assert_response 500
assert_error_tag :content => /was not found/
end
end
else
puts "Mercurial test repository NOT FOUND. Skipping functional tests !!!"
def test_fake; assert true end
......
......@@ -154,6 +154,14 @@ class RepositoryMercurialTest < ActiveSupport::TestCase
assert_equal '2:400bb8672109', c.format_identifier
end
def test_find_changeset_by_empty_name
@repository.fetch_changesets
@repository.reload
['', ' ', nil].each do |r|
assert_nil @repository.find_changeset_by_name(r)
end
end
def test_activities
c = Changeset.new(:repository => @repository,
:committed_on => Time.now,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment