Commit 30c6703f authored by James Lopez's avatar James Lopez

fix specs

parent 982d5a05
......@@ -19,6 +19,10 @@ module Gitlab
end.compact
end
def order
@order || default_order
end
private
def update_author!
......@@ -37,10 +41,6 @@ module Gitlab
base_query.project(extract_diff_epoch(diff_fn).as('total_time'), *projections).order(order.desc)
end
def order
@order || default_order
end
def default_order
@options[:start_time_attrs].is_a?(Array) ? @options[:start_time_attrs].first : @options[:start_time_attrs]
end
......
......@@ -23,7 +23,7 @@ module Gitlab
cmd << "--after=#{@from.iso8601}"
cmd << sha
output, status = Gitlab::Popen.popen(cmd) { |io| io.read }
output, status = Gitlab::Popen.popen(cmd)
raise IOError, output unless status.zero?
......
......@@ -7,7 +7,7 @@ describe Gitlab::CycleAnalytics::PlanEventFetcher do
it_behaves_like 'default query config' do
context 'no commits' do
it 'does not blow up if there are no commits' do
allow_any_instance_of(Gitlab::CycleAnalytics::MetricsFetcher).to receive(:events).and_return([{}])
allow(event).to receive(:event_result).and_return([{}])
expect { event.fetch }.not_to raise_error
end
......
require 'spec_helper'
shared_examples 'default query config' do
let(:fetcher) do
Gitlab::CycleAnalytics::MetricsFetcher.new(project: create(:empty_project),
from: 1.day.ago,
branch: nil,
stage: stage_name)
end
let(project)
let(:event) { described_class.new(project: project, stage: stage_name, options: {}) }
let(:project) { create(:empty_project) }
let(:event) { described_class.new(project: project, stage: stage_name, options: { from: 1.day.ago }) }
it 'has the stage attribute' do
expect(event.name).not_to be_nil
expect(event.stage).not_to be_nil
end
it 'has the projection attributes' do
......
......@@ -4,18 +4,10 @@ shared_examples 'base stage' do
let(:stage) { described_class.new(project: double, options: {}) }
before do
allow_any_instance_of(Gitlab::CycleAnalytics::MetricsFetcher).to receive(:median).and_return(1.12)
allow(stage).to receive(:median).and_return(1.12)
allow_any_instance_of(Gitlab::CycleAnalytics::BaseEventFetcher).to receive(:event_result).and_return({})
end
it 'has the start attributes' do
expect(stage.start_time_attrs).not_to be_nil
end
it 'has the end attributes' do
expect(stage.end_time_attrs).not_to be_nil
end
it 'has the median data value' do
expect(stage.median_data[:value]).not_to be_nil
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment