Merged r12660 (#13544).

git-svn-id: http://svn.redmine.org/redmine/branches/2.4-stable@12845 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2014-02-06 17:58:24 +00:00
parent a9f44b323f
commit a11aec0d4c
2 changed files with 17 additions and 6 deletions

View File

@ -154,13 +154,14 @@ class Changeset < ActiveRecord::Base
end
def text_tag(ref_project=nil)
tag = if scmid?
"commit:#{scmid}"
else
"r#{revision}"
end
repo = ""
if repository && repository.identifier.present?
tag = "#{repository.identifier}|#{tag}"
repo = "#{repository.identifier}|"
end
tag = if scmid?
"commit:#{repo}#{scmid}"
else
"#{repo}r#{revision}"
end
if ref_project && project && ref_project != project
tag = "#{project.identifier}:#{tag}"

View File

@ -345,6 +345,16 @@ class ChangesetTest < ActiveSupport::TestCase
assert_equal 'commit:0123456789', c.text_tag
end
def test_text_tag_hash_with_repository_identifier
r = Repository::Subversion.new(
:project_id => 1,
:url => 'svn://localhost/test',
:identifier => 'documents')
c = Changeset.new(:revision => '7234cb27', :scmid => '7234cb27', :repository => r)
assert_equal 'commit:documents|7234cb27', c.text_tag
assert_equal 'ecookbook:commit:documents|7234cb27', c.text_tag(Project.find(2))
end
def test_previous
changeset = Changeset.find_by_revision('3')
assert_equal Changeset.find_by_revision('2'), changeset.previous