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
path: root/spec
diff options
context:
space:
mode:
authorJames Lopez <james@jameslopez.es>2016-11-16 14:01:10 +0300
committerJames Lopez <james@jameslopez.es>2016-11-17 10:22:59 +0300
commitcf2dcf043c0054785bc0258ab6393104499b8d70 (patch)
tree1502646c438eb383a82f73d5a62f2b19b38d954c /spec
parentcbc9f0cd1aa9f379952b6e4d3ad6df9971f9092a (diff)
Refactor all query config stuff into separate classes and added specs
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/gitlab/cycle_analytics/code_config_spec.rb10
-rw-r--r--spec/lib/gitlab/cycle_analytics/events_spec.rb6
-rw-r--r--spec/lib/gitlab/cycle_analytics/issue_config_spec.rb10
-rw-r--r--spec/lib/gitlab/cycle_analytics/plan_config_spec.rb10
-rw-r--r--spec/lib/gitlab/cycle_analytics/production_config_spec.rb10
-rw-r--r--spec/lib/gitlab/cycle_analytics/review_config_spec.rb10
-rw-r--r--spec/lib/gitlab/cycle_analytics/shared_config_spec.rb15
-rw-r--r--spec/lib/gitlab/cycle_analytics/staging_config_spec.rb10
-rw-r--r--spec/lib/gitlab/cycle_analytics/test_config_spec.rb10
-rw-r--r--spec/requests/projects/cycle_analytics_events_spec.rb4
-rw-r--r--spec/serializers/analytics_generic_entity_spec.rb4
-rw-r--r--spec/serializers/analytics_generic_serializer_spec.rb4
12 files changed, 97 insertions, 6 deletions
diff --git a/spec/lib/gitlab/cycle_analytics/code_config_spec.rb b/spec/lib/gitlab/cycle_analytics/code_config_spec.rb
new file mode 100644
index 00000000000..7b89fdd76aa
--- /dev/null
+++ b/spec/lib/gitlab/cycle_analytics/code_config_spec.rb
@@ -0,0 +1,10 @@
+require 'spec_helper'
+require 'lib/gitlab/cycle_analytics/shared_config_spec'
+
+describe Gitlab::CycleAnalytics::CodeConfig do
+ it_behaves_like 'default query config'
+
+ it 'has the default order' do
+ expect(described_class.order).not_to eq(described_class.start_time_attrs)
+ end
+end
diff --git a/spec/lib/gitlab/cycle_analytics/events_spec.rb b/spec/lib/gitlab/cycle_analytics/events_spec.rb
index d46e70e9ba2..aa0e54582f1 100644
--- a/spec/lib/gitlab/cycle_analytics/events_spec.rb
+++ b/spec/lib/gitlab/cycle_analytics/events_spec.rb
@@ -9,6 +9,8 @@ describe Gitlab::CycleAnalytics::Events do
subject { described_class.new(project: project, options: { from: from_date }) }
before do
+ allow_any_instance_of(Gitlab::ReferenceExtractor).to receive(:issues).and_return([context])
+
setup(context)
end
@@ -317,6 +319,8 @@ describe Gitlab::CycleAnalytics::Events do
def setup(context)
milestone = create(:milestone, project: project)
context.update(milestone: milestone)
- create_merge_request_closing_issue(context)
+ mr = create_merge_request_closing_issue(context)
+
+ ProcessCommitWorker.new.perform(project.id, user.id, mr.commits.last.sha)
end
end
diff --git a/spec/lib/gitlab/cycle_analytics/issue_config_spec.rb b/spec/lib/gitlab/cycle_analytics/issue_config_spec.rb
new file mode 100644
index 00000000000..ff8cd1e8068
--- /dev/null
+++ b/spec/lib/gitlab/cycle_analytics/issue_config_spec.rb
@@ -0,0 +1,10 @@
+require 'spec_helper'
+require 'lib/gitlab/cycle_analytics/shared_config_spec'
+
+describe Gitlab::CycleAnalytics::IssueConfig do
+ it_behaves_like 'default query config'
+
+ it 'has the default order' do
+ expect(described_class.order).to eq(described_class.start_time_attrs)
+ end
+end
diff --git a/spec/lib/gitlab/cycle_analytics/plan_config_spec.rb b/spec/lib/gitlab/cycle_analytics/plan_config_spec.rb
new file mode 100644
index 00000000000..92698defa5d
--- /dev/null
+++ b/spec/lib/gitlab/cycle_analytics/plan_config_spec.rb
@@ -0,0 +1,10 @@
+require 'spec_helper'
+require 'lib/gitlab/cycle_analytics/shared_config_spec'
+
+describe Gitlab::CycleAnalytics::PlanConfig do
+ it_behaves_like 'default query config'
+
+ it 'has the default order' do
+ expect(described_class.order).to eq(described_class.start_time_attrs)
+ end
+end
diff --git a/spec/lib/gitlab/cycle_analytics/production_config_spec.rb b/spec/lib/gitlab/cycle_analytics/production_config_spec.rb
new file mode 100644
index 00000000000..92485777334
--- /dev/null
+++ b/spec/lib/gitlab/cycle_analytics/production_config_spec.rb
@@ -0,0 +1,10 @@
+require 'spec_helper'
+require 'lib/gitlab/cycle_analytics/shared_config_spec'
+
+describe Gitlab::CycleAnalytics::ProductionConfig do
+ it_behaves_like 'default query config'
+
+ it 'has the default order' do
+ expect(described_class.order).to eq(described_class.start_time_attrs)
+ end
+end
diff --git a/spec/lib/gitlab/cycle_analytics/review_config_spec.rb b/spec/lib/gitlab/cycle_analytics/review_config_spec.rb
new file mode 100644
index 00000000000..59cb18ac16d
--- /dev/null
+++ b/spec/lib/gitlab/cycle_analytics/review_config_spec.rb
@@ -0,0 +1,10 @@
+require 'spec_helper'
+require 'lib/gitlab/cycle_analytics/shared_config_spec'
+
+describe Gitlab::CycleAnalytics::ReviewConfig do
+ it_behaves_like 'default query config'
+
+ it 'has the default order' do
+ expect(described_class.order).to eq(described_class.start_time_attrs)
+ end
+end
diff --git a/spec/lib/gitlab/cycle_analytics/shared_config_spec.rb b/spec/lib/gitlab/cycle_analytics/shared_config_spec.rb
new file mode 100644
index 00000000000..060a59151d8
--- /dev/null
+++ b/spec/lib/gitlab/cycle_analytics/shared_config_spec.rb
@@ -0,0 +1,15 @@
+require 'spec_helper'
+
+shared_examples 'default query config' do
+ it 'has the start attributes' do
+ expect(described_class.start_time_attrs).not_to be_nil
+ end
+
+ it 'has the end attributes' do
+ expect(described_class.end_time_attrs ).not_to be_nil
+ end
+
+ it 'has the projection attributes' do
+ expect(described_class.projections).not_to be_nil
+ end
+end
diff --git a/spec/lib/gitlab/cycle_analytics/staging_config_spec.rb b/spec/lib/gitlab/cycle_analytics/staging_config_spec.rb
new file mode 100644
index 00000000000..f13885d7f48
--- /dev/null
+++ b/spec/lib/gitlab/cycle_analytics/staging_config_spec.rb
@@ -0,0 +1,10 @@
+require 'spec_helper'
+require 'lib/gitlab/cycle_analytics/shared_config_spec'
+
+describe Gitlab::CycleAnalytics::StagingConfig do
+ it_behaves_like 'default query config'
+
+ it 'has the default order' do
+ expect(described_class.order).not_to eq(described_class.start_time_attrs)
+ end
+end
diff --git a/spec/lib/gitlab/cycle_analytics/test_config_spec.rb b/spec/lib/gitlab/cycle_analytics/test_config_spec.rb
new file mode 100644
index 00000000000..59421b99513
--- /dev/null
+++ b/spec/lib/gitlab/cycle_analytics/test_config_spec.rb
@@ -0,0 +1,10 @@
+require 'spec_helper'
+require 'lib/gitlab/cycle_analytics/shared_config_spec'
+
+describe Gitlab::CycleAnalytics::TestConfig do
+ it_behaves_like 'default query config'
+
+ it 'has the default order' do
+ expect(described_class.order).not_to eq(described_class.start_time_attrs)
+ end
+end
diff --git a/spec/requests/projects/cycle_analytics_events_spec.rb b/spec/requests/projects/cycle_analytics_events_spec.rb
index 280aa2152b1..1c78cd368db 100644
--- a/spec/requests/projects/cycle_analytics_events_spec.rb
+++ b/spec/requests/projects/cycle_analytics_events_spec.rb
@@ -12,6 +12,8 @@ describe 'cycle analytics events' do
deploy_master
login_as(user)
+
+ allow_any_instance_of(Gitlab::ReferenceExtractor).to receive(:issues).and_return([context])
end
it 'lists the issue events' do
@@ -143,6 +145,6 @@ describe 'cycle analytics events' do
merge_merge_requests_closing_issue(issue)
- Issue::Metrics.update_all(first_mentioned_in_commit_at: mr.commits.last.committed_date)
+ ProcessCommitWorker.new.perform(project.id, user.id, mr.commits.last.sha)
end
end
diff --git a/spec/serializers/analytics_generic_entity_spec.rb b/spec/serializers/analytics_generic_entity_spec.rb
index 7c731da1dd1..3bb15cb9475 100644
--- a/spec/serializers/analytics_generic_entity_spec.rb
+++ b/spec/serializers/analytics_generic_entity_spec.rb
@@ -2,7 +2,7 @@ require 'spec_helper'
describe AnalyticsGenericEntity do
let(:user) { create(:user) }
- let(:entity_hash) {
+ let(:entity_hash) do
{
total_time: "172802.724419",
title: "Eos voluptatem inventore in sed.",
@@ -11,7 +11,7 @@ describe AnalyticsGenericEntity do
created_at: "2016-11-12 15:04:02.948604",
author: user,
}
- }
+ end
let(:project) { create(:empty_project) }
let(:request) { EntityRequest.new(project: project, entity: :merge_request) }
diff --git a/spec/serializers/analytics_generic_serializer_spec.rb b/spec/serializers/analytics_generic_serializer_spec.rb
index 9eeb7bee562..99f2254d22c 100644
--- a/spec/serializers/analytics_generic_serializer_spec.rb
+++ b/spec/serializers/analytics_generic_serializer_spec.rb
@@ -10,7 +10,7 @@ describe AnalyticsGenericSerializer do
let(:user) { create(:user) }
let(:json) { serializer.as_json }
let(:project) { create(:project) }
- let(:resource) {
+ let(:resource) do
{
total_time: "172802.724419",
title: "Eos voluptatem inventore in sed.",
@@ -19,7 +19,7 @@ describe AnalyticsGenericSerializer do
created_at: "2016-11-12 15:04:02.948604",
author: user,
}
- }
+ end
context 'when there is a single object provided' do
it 'it generates payload for single object' do