summaryrefslogtreecommitdiff
path: root/spec/lib
diff options
context:
space:
mode:
authorJacob Vosmaer <jacob@gitlab.com>2017-07-31 15:23:05 +0200
committerJacob Vosmaer <jacob@gitlab.com>2017-08-01 10:48:46 +0200
commit67de82cf5fa5a6408621cbf955c730e2825d9c39 (patch)
tree82b65479cc85b0426d09045d88f6d68d09cdcaf7 /spec/lib
parente99564568b2fefab8973ce571594aaa888cf8494 (diff)
downloadgitlab-ce-67de82cf5fa5a6408621cbf955c730e2825d9c39.tar.gz
Add option to use CommitLanguages RPC
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/gitlab/git/repository_spec.rb39
1 files changed, 39 insertions, 0 deletions
diff --git a/spec/lib/gitlab/git/repository_spec.rb b/spec/lib/gitlab/git/repository_spec.rb
index 50736d353ad..8e4a1f31ced 100644
--- a/spec/lib/gitlab/git/repository_spec.rb
+++ b/spec/lib/gitlab/git/repository_spec.rb
@@ -1127,6 +1127,45 @@ describe Gitlab::Git::Repository, seed_helper: true do
end
end
+ describe '#languages' do
+ shared_examples 'languages' do
+ it 'returns exactly the expected results' do
+ languages = repository.languages('4b4918a572fa86f9771e5ba40fbd48e1eb03e2c6')
+ expected_languages = [
+ { value: 66.63, label: "Ruby", color: "#701516", highlight: "#701516" },
+ { value: 22.96, label: "JavaScript", color: "#f1e05a", highlight: "#f1e05a" },
+ { value: 7.9, label: "HTML", color: "#e44b23", highlight: "#e44b23" },
+ { value: 2.51, label: "CoffeeScript", color: "#244776", highlight: "#244776" }
+ ]
+
+ expect(languages.size).to eq(expected_languages.size)
+
+ expected_languages.size.times do |i|
+ a = expected_languages[i]
+ b = languages[i]
+
+ expect(a.keys.sort).to eq(b.keys.sort)
+ expect(a[:value]).to be_within(0.1).of(b[:value])
+
+ non_float_keys = a.keys - [:value]
+ 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
+
+ it_behaves_like 'languages'
+
+ context 'with rugged', skip_gitaly_mock: true do
+ it_behaves_like 'languages'
+ end
+ end
+
def create_remote_branch(repository, remote_name, branch_name, source_branch_name)
source_branch = repository.branches.find { |branch| branch.name == source_branch_name }
rugged = repository.rugged