2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-05-09 12:01:36 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe 'Project Graph', :js do
|
|
|
|
let(:user) { create :user }
|
|
|
|
let(:project) { create(:project, :repository, namespace: user.namespace) }
|
2018-06-27 16:04:02 +05:30
|
|
|
let(:branch_name) { 'master' }
|
2018-05-09 12:01:36 +05:30
|
|
|
|
|
|
|
before do
|
2019-07-07 11:18:12 +05:30
|
|
|
::Projects::DetectRepositoryLanguagesService.new(project, user).execute
|
|
|
|
|
2018-11-18 11:00:15 +05:30
|
|
|
project.add_maintainer(user)
|
2018-05-09 12:01:36 +05:30
|
|
|
|
|
|
|
sign_in(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
shared_examples 'page should have commits graphs' do
|
|
|
|
it 'renders commits' do
|
2018-06-27 16:04:02 +05:30
|
|
|
expect(page).to have_content("Commit statistics for #{branch_name}")
|
2018-05-09 12:01:36 +05:30
|
|
|
expect(page).to have_content('Commits per day of month')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'commits graph' do
|
|
|
|
before do
|
|
|
|
visit commits_project_graph_path(project, 'master')
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'page should have commits graphs'
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'languages graph' do
|
|
|
|
before do
|
|
|
|
visit languages_project_graph_path(project, 'master')
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'page should have commits graphs'
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'charts graph' do
|
|
|
|
before do
|
|
|
|
visit charts_project_graph_path(project, 'master')
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'page should have commits graphs'
|
|
|
|
end
|
|
|
|
|
2018-06-27 16:04:02 +05:30
|
|
|
context 'chart graph with HTML escaped branch name' do
|
|
|
|
let(:branch_name) { '<h1>evil</h1>' }
|
|
|
|
|
|
|
|
before do
|
2020-03-09 13:42:32 +05:30
|
|
|
project.repository.create_branch(branch_name)
|
2018-06-27 16:04:02 +05:30
|
|
|
|
|
|
|
visit charts_project_graph_path(project, branch_name)
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'page should have commits graphs'
|
|
|
|
|
|
|
|
it 'HTML escapes branch name' do
|
|
|
|
expect(page.body).to include("Commit statistics for <strong>#{ERB::Util.html_escape(branch_name)}</strong>")
|
|
|
|
expect(page.body).not_to include(branch_name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-05-09 12:01:36 +05:30
|
|
|
context 'when CI enabled' do
|
|
|
|
before do
|
|
|
|
project.enable_ci
|
|
|
|
|
|
|
|
visit ci_project_graph_path(project, 'master')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders CI graphs' do
|
|
|
|
expect(page).to have_content 'Overall'
|
|
|
|
expect(page).to have_content 'Pipelines for last week'
|
|
|
|
expect(page).to have_content 'Pipelines for last month'
|
|
|
|
expect(page).to have_content 'Pipelines for last year'
|
2020-03-09 13:42:32 +05:30
|
|
|
expect(page).to have_content 'Duration for the last 30 commits'
|
2018-05-09 12:01:36 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|