From b214be493d9f179d4a929ee32d94a336da7b38f1 Mon Sep 17 00:00:00 2001 From: James Lopez Date: Fri, 2 Dec 2016 17:09:29 +0100 Subject: big refactor based on MR feedback --- .../cycle_analytics/code_event_fetcher_spec.rb | 12 ++++++++++++ spec/lib/gitlab/cycle_analytics/code_event_spec.rb | 12 ------------ .../cycle_analytics/issue_event_fetcher_spec.rb | 12 ++++++++++++ spec/lib/gitlab/cycle_analytics/issue_event_spec.rb | 12 ------------ .../cycle_analytics/plan_event_fetcher_spec.rb | 20 ++++++++++++++++++++ spec/lib/gitlab/cycle_analytics/plan_event_spec.rb | 20 -------------------- .../cycle_analytics/production_event_fetcher_spec.rb | 12 ++++++++++++ .../gitlab/cycle_analytics/production_event_spec.rb | 12 ------------ .../cycle_analytics/review_event_fetcher_spec.rb | 12 ++++++++++++ spec/lib/gitlab/cycle_analytics/review_event_spec.rb | 12 ------------ spec/lib/gitlab/cycle_analytics/shared_event_spec.rb | 5 +++-- spec/lib/gitlab/cycle_analytics/shared_stage_spec.rb | 2 +- .../cycle_analytics/staging_event_fetcher_spec.rb | 12 ++++++++++++ .../lib/gitlab/cycle_analytics/staging_event_spec.rb | 12 ------------ .../cycle_analytics/test_event_fetcher_spec.rb | 12 ++++++++++++ spec/lib/gitlab/cycle_analytics/test_event_spec.rb | 12 ------------ 16 files changed, 96 insertions(+), 95 deletions(-) create mode 100644 spec/lib/gitlab/cycle_analytics/code_event_fetcher_spec.rb delete mode 100644 spec/lib/gitlab/cycle_analytics/code_event_spec.rb create mode 100644 spec/lib/gitlab/cycle_analytics/issue_event_fetcher_spec.rb delete mode 100644 spec/lib/gitlab/cycle_analytics/issue_event_spec.rb create mode 100644 spec/lib/gitlab/cycle_analytics/plan_event_fetcher_spec.rb delete mode 100644 spec/lib/gitlab/cycle_analytics/plan_event_spec.rb create mode 100644 spec/lib/gitlab/cycle_analytics/production_event_fetcher_spec.rb delete mode 100644 spec/lib/gitlab/cycle_analytics/production_event_spec.rb create mode 100644 spec/lib/gitlab/cycle_analytics/review_event_fetcher_spec.rb delete mode 100644 spec/lib/gitlab/cycle_analytics/review_event_spec.rb create mode 100644 spec/lib/gitlab/cycle_analytics/staging_event_fetcher_spec.rb delete mode 100644 spec/lib/gitlab/cycle_analytics/staging_event_spec.rb create mode 100644 spec/lib/gitlab/cycle_analytics/test_event_fetcher_spec.rb delete mode 100644 spec/lib/gitlab/cycle_analytics/test_event_spec.rb (limited to 'spec/lib/gitlab/cycle_analytics') diff --git a/spec/lib/gitlab/cycle_analytics/code_event_fetcher_spec.rb b/spec/lib/gitlab/cycle_analytics/code_event_fetcher_spec.rb new file mode 100644 index 00000000000..abfd60d7f6a --- /dev/null +++ b/spec/lib/gitlab/cycle_analytics/code_event_fetcher_spec.rb @@ -0,0 +1,12 @@ +require 'spec_helper' +require 'lib/gitlab/cycle_analytics/shared_event_spec' + +describe Gitlab::CycleAnalytics::CodeEventFetcher do + let(:stage_name) { :code } + + it_behaves_like 'default query config' do + it 'does not have the default order' do + expect(event.order).not_to eq(event.start_time_attrs) + end + end +end diff --git a/spec/lib/gitlab/cycle_analytics/code_event_spec.rb b/spec/lib/gitlab/cycle_analytics/code_event_spec.rb deleted file mode 100644 index 0673906e678..00000000000 --- a/spec/lib/gitlab/cycle_analytics/code_event_spec.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'spec_helper' -require 'lib/gitlab/cycle_analytics/shared_event_spec' - -describe Gitlab::CycleAnalytics::CodeEvent do - let(:stage_name) { :code } - - it_behaves_like 'default query config' do - it 'does not have the default order' do - expect(event.order).not_to eq(event.start_time_attrs) - end - end -end diff --git a/spec/lib/gitlab/cycle_analytics/issue_event_fetcher_spec.rb b/spec/lib/gitlab/cycle_analytics/issue_event_fetcher_spec.rb new file mode 100644 index 00000000000..f4d995d072f --- /dev/null +++ b/spec/lib/gitlab/cycle_analytics/issue_event_fetcher_spec.rb @@ -0,0 +1,12 @@ +require 'spec_helper' +require 'lib/gitlab/cycle_analytics/shared_event_spec' + +describe Gitlab::CycleAnalytics::IssueEventFetcher do + let(:stage_name) { :issue } + + it_behaves_like 'default query config' do + it 'has the default order' do + expect(event.order).to eq(event.start_time_attrs) + end + end +end diff --git a/spec/lib/gitlab/cycle_analytics/issue_event_spec.rb b/spec/lib/gitlab/cycle_analytics/issue_event_spec.rb deleted file mode 100644 index 7967d3727db..00000000000 --- a/spec/lib/gitlab/cycle_analytics/issue_event_spec.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'spec_helper' -require 'lib/gitlab/cycle_analytics/shared_event_spec' - -describe Gitlab::CycleAnalytics::IssueEvent do - let(:stage_name) { :issue } - - it_behaves_like 'default query config' do - it 'has the default order' do - expect(event.order).to eq(event.start_time_attrs) - end - end -end diff --git a/spec/lib/gitlab/cycle_analytics/plan_event_fetcher_spec.rb b/spec/lib/gitlab/cycle_analytics/plan_event_fetcher_spec.rb new file mode 100644 index 00000000000..679779de51e --- /dev/null +++ b/spec/lib/gitlab/cycle_analytics/plan_event_fetcher_spec.rb @@ -0,0 +1,20 @@ +require 'spec_helper' +require 'lib/gitlab/cycle_analytics/shared_event_spec' + +describe Gitlab::CycleAnalytics::PlanEventFetcher do + let(:stage_name) { :plan } + + it_behaves_like 'default query config' do + it 'has the default order' do + expect(event.order).to eq(event.start_time_attrs) + end + + 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([{}]) + + expect { event.fetch }.not_to raise_error + end + end + end +end diff --git a/spec/lib/gitlab/cycle_analytics/plan_event_spec.rb b/spec/lib/gitlab/cycle_analytics/plan_event_spec.rb deleted file mode 100644 index df407e51c64..00000000000 --- a/spec/lib/gitlab/cycle_analytics/plan_event_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'spec_helper' -require 'lib/gitlab/cycle_analytics/shared_event_spec' - -describe Gitlab::CycleAnalytics::PlanEvent do - let(:stage_name) { :plan } - - it_behaves_like 'default query config' do - it 'has the default order' do - expect(event.order).to eq(event.start_time_attrs) - end - - 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([{}]) - - expect { event.fetch }.not_to raise_error - end - end - end -end diff --git a/spec/lib/gitlab/cycle_analytics/production_event_fetcher_spec.rb b/spec/lib/gitlab/cycle_analytics/production_event_fetcher_spec.rb new file mode 100644 index 00000000000..a9126b8fa1c --- /dev/null +++ b/spec/lib/gitlab/cycle_analytics/production_event_fetcher_spec.rb @@ -0,0 +1,12 @@ +require 'spec_helper' +require 'lib/gitlab/cycle_analytics/shared_event_spec' + +describe Gitlab::CycleAnalytics::ProductionEventFetcher do + let(:stage_name) { :production } + + it_behaves_like 'default query config' do + it 'has the default order' do + expect(event.order).to eq(event.start_time_attrs) + end + end +end diff --git a/spec/lib/gitlab/cycle_analytics/production_event_spec.rb b/spec/lib/gitlab/cycle_analytics/production_event_spec.rb deleted file mode 100644 index 99ed9a0ab5c..00000000000 --- a/spec/lib/gitlab/cycle_analytics/production_event_spec.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'spec_helper' -require 'lib/gitlab/cycle_analytics/shared_event_spec' - -describe Gitlab::CycleAnalytics::ProductionEvent do - let(:stage_name) { :production } - - it_behaves_like 'default query config' do - it 'has the default order' do - expect(event.order).to eq(event.start_time_attrs) - end - end -end diff --git a/spec/lib/gitlab/cycle_analytics/review_event_fetcher_spec.rb b/spec/lib/gitlab/cycle_analytics/review_event_fetcher_spec.rb new file mode 100644 index 00000000000..c3e66dcb861 --- /dev/null +++ b/spec/lib/gitlab/cycle_analytics/review_event_fetcher_spec.rb @@ -0,0 +1,12 @@ +require 'spec_helper' +require 'lib/gitlab/cycle_analytics/shared_event_spec' + +describe Gitlab::CycleAnalytics::ReviewEventFetcher do + let(:stage_name) { :review } + + it_behaves_like 'default query config' do + it 'has the default order' do + expect(event.order).to eq(event.start_time_attrs) + end + end +end diff --git a/spec/lib/gitlab/cycle_analytics/review_event_spec.rb b/spec/lib/gitlab/cycle_analytics/review_event_spec.rb deleted file mode 100644 index efc40d4ca4a..00000000000 --- a/spec/lib/gitlab/cycle_analytics/review_event_spec.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'spec_helper' -require 'lib/gitlab/cycle_analytics/shared_event_spec' - -describe Gitlab::CycleAnalytics::ReviewEvent do - let(:stage_name) { :review } - - it_behaves_like 'default query config' do - it 'has the default order' do - expect(event.order).to eq(event.start_time_attrs) - end - end -end diff --git a/spec/lib/gitlab/cycle_analytics/shared_event_spec.rb b/spec/lib/gitlab/cycle_analytics/shared_event_spec.rb index 5e1c7531fb5..60ec87255c8 100644 --- a/spec/lib/gitlab/cycle_analytics/shared_event_spec.rb +++ b/spec/lib/gitlab/cycle_analytics/shared_event_spec.rb @@ -4,10 +4,11 @@ shared_examples 'default query config' do let(:fetcher) do Gitlab::CycleAnalytics::MetricsFetcher.new(project: create(:empty_project), from: 1.day.ago, - branch: nil) + branch: nil, + stage: stage_name) end - let(:event) { described_class.new(fetcher: fetcher, options: {}) } + let(:event) { described_class.new(fetcher: fetcher, options: {}, stage: stage_name) } it 'has the start attributes' do expect(event.start_time_attrs).not_to be_nil diff --git a/spec/lib/gitlab/cycle_analytics/shared_stage_spec.rb b/spec/lib/gitlab/cycle_analytics/shared_stage_spec.rb index cfb5dc12ff1..8cc7875258e 100644 --- a/spec/lib/gitlab/cycle_analytics/shared_stage_spec.rb +++ b/spec/lib/gitlab/cycle_analytics/shared_stage_spec.rb @@ -5,7 +5,7 @@ shared_examples 'base stage' do before do allow_any_instance_of(Gitlab::CycleAnalytics::MetricsFetcher).to receive(:median).and_return(1.12) - allow_any_instance_of(Gitlab::CycleAnalytics::BaseEvent).to receive(:event_result).and_return({}) + allow_any_instance_of(Gitlab::CycleAnalytics::BaseEventFetcher).to receive(:event_result).and_return({}) end it 'has the median data value' do diff --git a/spec/lib/gitlab/cycle_analytics/staging_event_fetcher_spec.rb b/spec/lib/gitlab/cycle_analytics/staging_event_fetcher_spec.rb new file mode 100644 index 00000000000..8338e17b96d --- /dev/null +++ b/spec/lib/gitlab/cycle_analytics/staging_event_fetcher_spec.rb @@ -0,0 +1,12 @@ +require 'spec_helper' +require 'lib/gitlab/cycle_analytics/shared_event_spec' + +describe Gitlab::CycleAnalytics::StagingEventFetcher do + let(:stage_name) { :staging } + + it_behaves_like 'default query config' do + it 'does not have the default order' do + expect(event.order).not_to eq(event.start_time_attrs) + end + end +end diff --git a/spec/lib/gitlab/cycle_analytics/staging_event_spec.rb b/spec/lib/gitlab/cycle_analytics/staging_event_spec.rb deleted file mode 100644 index b7ab477067c..00000000000 --- a/spec/lib/gitlab/cycle_analytics/staging_event_spec.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'spec_helper' -require 'lib/gitlab/cycle_analytics/shared_event_spec' - -describe Gitlab::CycleAnalytics::StagingEvent do - let(:stage_name) { :staging } - - it_behaves_like 'default query config' do - it 'does not have the default order' do - expect(event.order).not_to eq(event.start_time_attrs) - end - end -end diff --git a/spec/lib/gitlab/cycle_analytics/test_event_fetcher_spec.rb b/spec/lib/gitlab/cycle_analytics/test_event_fetcher_spec.rb new file mode 100644 index 00000000000..9d4f7667f1d --- /dev/null +++ b/spec/lib/gitlab/cycle_analytics/test_event_fetcher_spec.rb @@ -0,0 +1,12 @@ +require 'spec_helper' +require 'lib/gitlab/cycle_analytics/shared_event_spec' + +describe Gitlab::CycleAnalytics::TestEventFetcher do + let(:stage_name) { :test } + + it_behaves_like 'default query config' do + it 'does not have the default order' do + expect(event.order).not_to eq(event.start_time_attrs) + end + end +end diff --git a/spec/lib/gitlab/cycle_analytics/test_event_spec.rb b/spec/lib/gitlab/cycle_analytics/test_event_spec.rb deleted file mode 100644 index a4fc8963e5b..00000000000 --- a/spec/lib/gitlab/cycle_analytics/test_event_spec.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'spec_helper' -require 'lib/gitlab/cycle_analytics/shared_event_spec' - -describe Gitlab::CycleAnalytics::TestEvent do - let(:stage_name) { :test } - - it_behaves_like 'default query config' do - it 'does not have the default order' do - expect(event.order).not_to eq(event.start_time_attrs) - end - end -end -- cgit v1.2.3