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

62 lines
1.8 KiB
Ruby
Raw Normal View History

2019-07-31 22:56:46 +05:30
# frozen_string_literal: true
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)
2018-11-18 11:00:15 +05:30
project.add_maintainer(user)
2016-11-03 12:29:30 +05:30
end
2017-08-17 22:00:37 +05:30
describe 'GET languages' do
it "redirects_to action charts" do
2019-02-15 15:39:39 +05:30
get(:commits, params: { namespace_id: project.namespace.path, project_id: project.path, id: 'master' })
2017-08-17 22:00:37 +05:30
expect(response).to redirect_to action: :charts
end
end
describe 'GET commits' do
it "redirects_to action charts" do
2019-02-15 15:39:39 +05:30
get(:commits, params: { namespace_id: project.namespace.path, project_id: project.path, id: 'master' })
2017-08-17 22:00:37 +05:30
expect(response).to redirect_to action: :charts
end
end
2019-07-07 11:18:12 +05:30
describe 'charts' do
2019-09-04 21:01:54 +05:30
context 'with an anonymous user' do
let(:project) { create(:project, :repository, :public) }
before do
sign_out(user)
end
it 'renders charts with 200 status code' do
get(:charts, params: { namespace_id: project.namespace.path, project_id: project.path, id: 'master' })
expect(response).to have_gitlab_http_status(:ok)
expect(response).to render_template(:charts)
end
end
2019-07-07 11:18:12 +05:30
context 'when languages were previously detected' do
let(:project) { create(:project, :repository, detected_repository_languages: true) }
let!(:repository_language) { create(:repository_language, project: project) }
it 'sets the languages properly' do
get(:charts, params: { namespace_id: project.namespace.path, project_id: project.path, id: 'master' })
expect(assigns[:languages]).to eq(
[value: repository_language.share,
label: repository_language.name,
color: repository_language.color,
highlight: repository_language.color])
end
end
end
2016-11-03 12:29:30 +05:30
end