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

fix specs

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