2016-10-12 12:48:53 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Projects::GraphsController do
|
|
|
|
let(:project) { create(:project) }
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
project.team << [user, :master]
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'GET #languages' do
|
|
|
|
let(:linguist_repository) do
|
2016-10-13 01:01:34 -04:00
|
|
|
double(languages: {
|
2016-10-13 07:08:19 -04:00
|
|
|
'Ruby' => 1000,
|
|
|
|
'CoffeeScript' => 350,
|
|
|
|
'PowerShell' => 15
|
|
|
|
})
|
2016-10-12 12:48:53 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
let(:expected_values) do
|
|
|
|
ps_color = "##{Digest::SHA256.hexdigest('PowerShell')[0...6]}"
|
|
|
|
[
|
|
|
|
# colors from Linguist:
|
2016-10-13 01:01:34 -04:00
|
|
|
{ label: "Ruby", color: "#701516", highlight: "#701516" },
|
|
|
|
{ label: "CoffeeScript", color: "#244776", highlight: "#244776" },
|
2016-10-12 12:48:53 -04:00
|
|
|
# colors from SHA256 fallback:
|
2016-10-13 01:01:34 -04:00
|
|
|
{ label: "PowerShell", color: ps_color, highlight: ps_color }
|
2016-10-12 12:48:53 -04:00
|
|
|
]
|
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
|
|
|
allow(Linguist::Repository).to receive(:new).and_return(linguist_repository)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'sets the correct colour according to language' do
|
|
|
|
get(:languages, namespace_id: project.namespace.path, project_id: project.path, id: 'master')
|
|
|
|
|
2016-10-13 01:01:34 -04:00
|
|
|
expected_values.each do |val|
|
2016-10-13 07:08:19 -04:00
|
|
|
expect(assigns(:languages)).to include(a_hash_including(val))
|
2016-10-13 01:01:34 -04:00
|
|
|
end
|
2016-10-12 12:48:53 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|