82b6e5378a
When hashed storage is in use, it's helpful to have the project name associated with the request. Closes https://gitlab.com/gitlab-org/gitaly/issues/1394
71 lines
1.9 KiB
Ruby
71 lines
1.9 KiB
Ruby
# coding: utf-8
|
|
require "spec_helper"
|
|
|
|
describe Gitlab::Git::Blame, :seed_helper do
|
|
let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '', 'group/project') }
|
|
let(:blame) do
|
|
Gitlab::Git::Blame.new(repository, SeedRepo::Commit::ID, "CONTRIBUTING.md")
|
|
end
|
|
|
|
describe 'blaming a file' do
|
|
context "each count" do
|
|
it do
|
|
data = []
|
|
blame.each do |commit, line|
|
|
data << {
|
|
commit: commit,
|
|
line: line
|
|
}
|
|
end
|
|
|
|
expect(data.size).to eq(95)
|
|
expect(data.first[:commit]).to be_kind_of(Gitlab::Git::Commit)
|
|
expect(data.first[:line]).to eq("# Contribute to GitLab")
|
|
expect(data.first[:line]).to be_utf8
|
|
end
|
|
end
|
|
|
|
context "ISO-8859 encoding" do
|
|
let(:blame) do
|
|
Gitlab::Git::Blame.new(repository, SeedRepo::EncodingCommit::ID, "encoding/iso8859.txt")
|
|
end
|
|
|
|
it 'converts to UTF-8' do
|
|
data = []
|
|
blame.each do |commit, line|
|
|
data << {
|
|
commit: commit,
|
|
line: line
|
|
}
|
|
end
|
|
|
|
expect(data.size).to eq(1)
|
|
expect(data.first[:commit]).to be_kind_of(Gitlab::Git::Commit)
|
|
expect(data.first[:line]).to eq("Ä ü")
|
|
expect(data.first[:line]).to be_utf8
|
|
end
|
|
end
|
|
|
|
context "unknown encoding" do
|
|
let(:blame) do
|
|
Gitlab::Git::Blame.new(repository, SeedRepo::EncodingCommit::ID, "encoding/iso8859.txt")
|
|
end
|
|
|
|
it 'converts to UTF-8' do
|
|
expect(CharlockHolmes::EncodingDetector).to receive(:detect).and_return(nil)
|
|
data = []
|
|
blame.each do |commit, line|
|
|
data << {
|
|
commit: commit,
|
|
line: line
|
|
}
|
|
end
|
|
|
|
expect(data.size).to eq(1)
|
|
expect(data.first[:commit]).to be_kind_of(Gitlab::Git::Commit)
|
|
expect(data.first[:line]).to eq(" ")
|
|
expect(data.first[:line]).to be_utf8
|
|
end
|
|
end
|
|
end
|
|
end
|