debian-mirror-gitlab/spec/controllers/projects/graphs_controller_spec.rb

61 lines
1.7 KiB
Ruby
Raw Normal View History

2016-11-03 12:29:30 +05:30
require 'spec_helper'
describe Projects::GraphsController do
2017-08-17 22:00:37 +05:30
let(:project) { create(:project, :repository) }
2016-11-03 12:29:30 +05:30
let(:user) { create(:user) }
before do
sign_in(user)
project.team << [user, :master]
end
2017-08-17 22:00:37 +05:30
describe 'GET languages' do
it "redirects_to action charts" do
get(:commits, namespace_id: project.namespace.path, project_id: project.path, id: 'master')
expect(response).to redirect_to action: :charts
end
end
describe 'GET commits' do
it "redirects_to action charts" do
get(:commits, namespace_id: project.namespace.path, project_id: project.path, id: 'master')
expect(response).to redirect_to action: :charts
end
end
describe 'GET charts' do
2016-11-03 12:29:30 +05:30
let(:linguist_repository) do
double(languages: {
'Ruby' => 1000,
'CoffeeScript' => 350,
2017-08-17 22:00:37 +05:30
'NSIS' => 15
2016-11-03 12:29:30 +05:30
})
end
let(:expected_values) do
2017-08-17 22:00:37 +05:30
nsis_color = "##{Digest::SHA256.hexdigest('NSIS')[0...6]}"
2016-11-03 12:29:30 +05:30
[
# colors from Linguist:
2017-08-17 22:00:37 +05:30
{ label: "Ruby", color: "#701516", highlight: "#701516" },
{ label: "CoffeeScript", color: "#244776", highlight: "#244776" },
2016-11-03 12:29:30 +05:30
# colors from SHA256 fallback:
2017-08-17 22:00:37 +05:30
{ label: "NSIS", color: nsis_color, highlight: nsis_color }
2016-11-03 12:29:30 +05:30
]
end
before do
allow(Linguist::Repository).to receive(:new).and_return(linguist_repository)
end
it 'sets the correct colour according to language' do
2017-08-17 22:00:37 +05:30
get(:charts, namespace_id: project.namespace, project_id: project, id: 'master')
2016-11-03 12:29:30 +05:30
expected_values.each do |val|
expect(assigns(:languages)).to include(a_hash_including(val))
end
end
end
end