mirror of
https://github.com/redmine/redmine.git
synced 2025-11-14 01:06:00 +01:00
scm: git: add test of UTF-8 Emoji committer and comments (#24030)
git-svn-id: http://svn.redmine.org/redmine/trunk@19699 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -163,6 +163,21 @@ class ActiveSupport::TestCase
|
|||||||
File.directory?(repository_path(vendor))
|
File.directory?(repository_path(vendor))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.is_mysql_utf8mb4
|
||||||
|
return false unless Redmine::Database::mysql?
|
||||||
|
character_sets = %w[
|
||||||
|
character_set_connection
|
||||||
|
character_set_database
|
||||||
|
character_set_results
|
||||||
|
character_set_server
|
||||||
|
]
|
||||||
|
ActiveRecord::Base.connection.
|
||||||
|
select_rows('show variables like "character%"').each do |r|
|
||||||
|
return false if character_sets.include?(r[0]) && r[1] != "utf8mb4"
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
def repository_path_hash(arr)
|
def repository_path_hash(arr)
|
||||||
hs = {}
|
hs = {}
|
||||||
hs[:path] = arr.join("/")
|
hs[:path] = arr.join("/")
|
||||||
|
|||||||
@@ -27,6 +27,9 @@ class RepositoryGitTest < ActiveSupport::TestCase
|
|||||||
REPOSITORY_PATH = Rails.root.join('tmp/test/git_repository').to_s
|
REPOSITORY_PATH = Rails.root.join('tmp/test/git_repository').to_s
|
||||||
REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
|
REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
|
||||||
|
|
||||||
|
REPOSITORY_UTF8_PATH = Rails.root.join('tmp/test/git_utf8_repository').to_s
|
||||||
|
REPOSITORY_UTF8_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
|
||||||
|
|
||||||
NUM_REV = 28
|
NUM_REV = 28
|
||||||
NUM_HEAD = 8
|
NUM_HEAD = 8
|
||||||
|
|
||||||
@@ -587,4 +590,32 @@ class RepositoryGitTest < ActiveSupport::TestCase
|
|||||||
puts "Git test repository NOT FOUND. Skipping unit tests !!!"
|
puts "Git test repository NOT FOUND. Skipping unit tests !!!"
|
||||||
def test_fake; assert true end
|
def test_fake; assert true end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if File.directory?(REPOSITORY_UTF8_PATH) &&
|
||||||
|
!(Redmine::Database::mysql? && !is_mysql_utf8mb4)
|
||||||
|
def test_utf8_emoji
|
||||||
|
repo = Repository::Git.create(
|
||||||
|
:project => @project,
|
||||||
|
:url => REPOSITORY_UTF8_PATH,
|
||||||
|
:identifier => 'utf8',
|
||||||
|
:path_encoding => 'UTF-8'
|
||||||
|
)
|
||||||
|
assert repo
|
||||||
|
assert_equal 0, repo.changesets.count
|
||||||
|
repo.fetch_changesets
|
||||||
|
@project.reload
|
||||||
|
assert_equal 1, repo.changesets.count
|
||||||
|
changeset = repo.find_changeset_by_name('9da6b5c6748cc62ee26616718c9bb0e9acfb3e15')
|
||||||
|
assert_equal "U+1F603\u{1F603} <none@none>", changeset.committer
|
||||||
|
assert_equal "U+1F603\u{1F603}", changeset.comments
|
||||||
|
end
|
||||||
|
elsif !File.directory?(REPOSITORY_UTF8_PATH)
|
||||||
|
puts "Git UTF-8 test repository NOT FOUND. Skipping unit tests !!!"
|
||||||
|
def test_fake; assert true end
|
||||||
|
else
|
||||||
|
puts "Git UTF-8 test repository contains Emoji."
|
||||||
|
puts "Tests connot run on NOT utf8mb4 MySQL."
|
||||||
|
puts "Skipping unit tests !!!"
|
||||||
|
def test_fake; assert true end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user