2015-08-25 21:42:46 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-09-06 07:11:00 -04:00
|
|
|
describe Gitlab::Ci::Charts do
|
2018-03-05 11:07:52 -05:00
|
|
|
context "yearchart" do
|
|
|
|
let(:project) { create(:project) }
|
|
|
|
let(:chart) { Gitlab::Ci::Charts::YearChart.new(project) }
|
|
|
|
|
|
|
|
subject { chart.to }
|
|
|
|
|
|
|
|
it 'goes until the end of the current month (including the whole last day of the month)' do
|
|
|
|
is_expected.to eq(Date.today.end_of_month.end_of_day)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'starts at the beginning of the current year' do
|
|
|
|
expect(chart.from).to eq(chart.to.years_ago(1).beginning_of_month.beginning_of_day)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "monthchart" do
|
|
|
|
let(:project) { create(:project) }
|
|
|
|
let(:chart) { Gitlab::Ci::Charts::MonthChart.new(project) }
|
|
|
|
|
|
|
|
subject { chart.to }
|
|
|
|
|
|
|
|
it 'includes the whole current day' do
|
|
|
|
is_expected.to eq(Date.today.end_of_day)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'starts one month ago' do
|
|
|
|
expect(chart.from).to eq(1.month.ago.beginning_of_day)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "weekchart" do
|
|
|
|
let(:project) { create(:project) }
|
|
|
|
let(:chart) { Gitlab::Ci::Charts::WeekChart.new(project) }
|
|
|
|
|
|
|
|
subject { chart.to }
|
|
|
|
|
|
|
|
it 'includes the whole current day' do
|
|
|
|
is_expected.to eq(Date.today.end_of_day)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'starts one week ago' do
|
|
|
|
expect(chart.from).to eq(1.week.ago.beginning_of_day)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-06-23 06:18:52 -04:00
|
|
|
context "pipeline_times" do
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:project) { create(:project) }
|
2017-09-06 07:11:00 -04:00
|
|
|
let(:chart) { Gitlab::Ci::Charts::PipelineTime.new(project) }
|
2016-08-11 16:54:25 -04:00
|
|
|
|
2017-06-23 06:18:52 -04:00
|
|
|
subject { chart.pipeline_times }
|
2016-08-11 16:54:25 -04:00
|
|
|
|
2015-08-25 21:42:46 -04:00
|
|
|
before do
|
2016-08-11 16:54:25 -04:00
|
|
|
create(:ci_empty_pipeline, project: project, duration: 120)
|
2015-08-25 21:42:46 -04:00
|
|
|
end
|
|
|
|
|
2017-06-23 06:18:52 -04:00
|
|
|
it 'returns pipeline times in minutes' do
|
2016-08-11 16:54:25 -04:00
|
|
|
is_expected.to contain_exactly(2)
|
2015-08-25 21:42:46 -04:00
|
|
|
end
|
2016-05-23 02:35:18 -04:00
|
|
|
|
2017-06-23 06:18:52 -04:00
|
|
|
it 'handles nil pipeline times' do
|
2016-08-11 16:54:25 -04:00
|
|
|
create(:ci_empty_pipeline, project: project, duration: nil)
|
2016-05-23 02:35:18 -04:00
|
|
|
|
2016-08-11 16:54:25 -04:00
|
|
|
is_expected.to contain_exactly(2, 0)
|
2016-05-23 02:35:18 -04:00
|
|
|
end
|
2015-08-25 21:42:46 -04:00
|
|
|
end
|
|
|
|
end
|