Commit f70c581d authored by Douwe Maan's avatar Douwe Maan

Merge branch 'zj-linguist-gitaly-mandatory' into 'master'

Move language detection to mandatory

Closes gitaly#732 and gitaly#360

See merge request gitlab-org/gitlab-ce!19985
parents 51334904 9ae8b574
...@@ -1688,41 +1688,33 @@ describe Gitlab::Git::Repository, seed_helper: true do ...@@ -1688,41 +1688,33 @@ describe Gitlab::Git::Repository, seed_helper: true do
end end
describe '#languages' do describe '#languages' do
shared_examples 'languages' do it 'returns exactly the expected results' do
it 'returns exactly the expected results' do languages = repository.languages('4b4918a572fa86f9771e5ba40fbd48e1eb03e2c6')
languages = repository.languages('4b4918a572fa86f9771e5ba40fbd48e1eb03e2c6') expected_languages = [
expected_languages = [ { value: 66.63, label: "Ruby", color: "#701516", highlight: "#701516" },
{ value: 66.63, label: "Ruby", color: "#701516", highlight: "#701516" }, { value: 22.96, label: "JavaScript", color: "#f1e05a", highlight: "#f1e05a" },
{ value: 22.96, label: "JavaScript", color: "#f1e05a", highlight: "#f1e05a" }, { value: 7.9, label: "HTML", color: "#e34c26", highlight: "#e34c26" },
{ value: 7.9, label: "HTML", color: "#e34c26", highlight: "#e34c26" }, { value: 2.51, label: "CoffeeScript", color: "#244776", highlight: "#244776" }
{ value: 2.51, label: "CoffeeScript", color: "#244776", highlight: "#244776" } ]
]
expect(languages.size).to eq(expected_languages.size) expect(languages.size).to eq(expected_languages.size)
expected_languages.size.times do |i| expected_languages.size.times do |i|
a = expected_languages[i] a = expected_languages[i]
b = languages[i] b = languages[i]
expect(a.keys.sort).to eq(b.keys.sort) expect(a.keys.sort).to eq(b.keys.sort)
expect(a[:value]).to be_within(0.1).of(b[:value]) expect(a[:value]).to be_within(0.1).of(b[:value])
non_float_keys = a.keys - [:value] non_float_keys = a.keys - [:value]
expect(a.values_at(*non_float_keys)).to eq(b.values_at(*non_float_keys)) expect(a.values_at(*non_float_keys)).to eq(b.values_at(*non_float_keys))
end
end
it "uses the repository's HEAD when no ref is passed" do
lang = repository.languages.first
expect(lang[:label]).to eq('Ruby')
end end
end end
it_behaves_like 'languages' it "uses the repository's HEAD when no ref is passed" do
lang = repository.languages.first
context 'with rugged', :skip_gitaly_mock do expect(lang[:label]).to eq('Ruby')
it_behaves_like 'languages'
end end
end end
......
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