Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Lopez <james@jameslopez.es>2016-12-09 17:23:09 +0300
committerJames Lopez <james@jameslopez.es>2017-01-17 13:32:55 +0300
commit30c6703f0afbf570ca3e3613a55afcbc7094c4eb (patch)
treeec7b891bb58f8d6b3bf8108e50ca8d791b4e6e09
parent982d5a050667c517bbc996a08ca0922f2c5fbfb4 (diff)
fix specs
-rw-r--r--lib/gitlab/cycle_analytics/base_event_fetcher.rb8
-rw-r--r--lib/gitlab/cycle_analytics/summary/commit.rb2
-rw-r--r--spec/lib/gitlab/cycle_analytics/plan_event_fetcher_spec.rb2
-rw-r--r--spec/lib/gitlab/cycle_analytics/shared_event_spec.rb13
-rw-r--r--spec/lib/gitlab/cycle_analytics/shared_stage_spec.rb10
5 files changed, 10 insertions, 25 deletions
diff --git a/lib/gitlab/cycle_analytics/base_event_fetcher.rb b/lib/gitlab/cycle_analytics/base_event_fetcher.rb
index 8b4ccfd5363..8d10ddf15d7 100644
--- a/lib/gitlab/cycle_analytics/base_event_fetcher.rb
+++ b/lib/gitlab/cycle_analytics/base_event_fetcher.rb
@@ -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
diff --git a/lib/gitlab/cycle_analytics/summary/commit.rb b/lib/gitlab/cycle_analytics/summary/commit.rb
index 61a50762164..7b8faa4d854 100644
--- a/lib/gitlab/cycle_analytics/summary/commit.rb
+++ b/lib/gitlab/cycle_analytics/summary/commit.rb
@@ -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?
diff --git a/spec/lib/gitlab/cycle_analytics/plan_event_fetcher_spec.rb b/spec/lib/gitlab/cycle_analytics/plan_event_fetcher_spec.rb
index 1c3c1728fc6..2e5dc5b5547 100644
--- a/spec/lib/gitlab/cycle_analytics/plan_event_fetcher_spec.rb
+++ b/spec/lib/gitlab/cycle_analytics/plan_event_fetcher_spec.rb
@@ -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
diff --git a/spec/lib/gitlab/cycle_analytics/shared_event_spec.rb b/spec/lib/gitlab/cycle_analytics/shared_event_spec.rb
index 03b013ffae8..9c5e57342e9 100644
--- a/spec/lib/gitlab/cycle_analytics/shared_event_spec.rb
+++ b/spec/lib/gitlab/cycle_analytics/shared_event_spec.rb
@@ -1,18 +1,11 @@
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
diff --git a/spec/lib/gitlab/cycle_analytics/shared_stage_spec.rb b/spec/lib/gitlab/cycle_analytics/shared_stage_spec.rb
index c88e3e22f5c..6f3883d80f8 100644
--- a/spec/lib/gitlab/cycle_analytics/shared_stage_spec.rb
+++ b/spec/lib/gitlab/cycle_analytics/shared_stage_spec.rb
@@ -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