summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Lopez <james@jameslopez.es>2016-11-02 16:21:49 +0100
committerJames Lopez <james@jameslopez.es>2016-11-17 08:22:56 +0100
commit9ead268cfaee7cb23fa00c7cf8bcf536cafab91a (patch)
tree752fcc1bba376437565e70ab822a176bb795e46b
parent85c448d76f382538898344b07b2c635c7215ca7b (diff)
downloadgitlab-ce-9ead268cfaee7cb23fa00c7cf8bcf536cafab91a.tar.gz
some more integration scenarios testing order. Also, fixed bug in the staging and test stages.
-rw-r--r--lib/gitlab/cycle_analytics/events.rb2
-rw-r--r--lib/gitlab/cycle_analytics/query_config.rb4
-rw-r--r--spec/requests/projects/cycle_analytics_events_spec.rb55
3 files changed, 44 insertions, 17 deletions
diff --git a/lib/gitlab/cycle_analytics/events.rb b/lib/gitlab/cycle_analytics/events.rb
index 08070c2bac2..0ec5aeb03c7 100644
--- a/lib/gitlab/cycle_analytics/events.rb
+++ b/lib/gitlab/cycle_analytics/events.rb
@@ -9,8 +9,6 @@ module Gitlab
@fetcher = EventsFetcher.new(project: project, from: from)
end
- # TODO: backend pagination - specially for commits, etc...
-
def issue_events
@fetcher.fetch(stage: :issue).each { |event| parse_event(event) }
end
diff --git a/lib/gitlab/cycle_analytics/query_config.rb b/lib/gitlab/cycle_analytics/query_config.rb
index c096e632724..3852ed7a2ab 100644
--- a/lib/gitlab/cycle_analytics/query_config.rb
+++ b/lib/gitlab/cycle_analytics/query_config.rb
@@ -50,7 +50,7 @@ module Gitlab
def test
{ start_time_attrs: mr_metrics_table[:latest_build_started_at],
end_time_attrs: mr_metrics_table[:latest_build_finished_at],
- projections: mr_metrics_table[:ci_commit_id],
+ projections: [mr_metrics_table[:ci_commit_id]],
order: mr_table[:created_at]
}
end
@@ -68,7 +68,7 @@ module Gitlab
def staging
{ start_time_attrs: mr_metrics_table[:merged_at],
end_time_attrs: mr_metrics_table[:first_deployed_to_production_at],
- projections: mr_metrics_table[:ci_commit_id]
+ projections: [mr_metrics_table[:ci_commit_id]]
}
end
diff --git a/spec/requests/projects/cycle_analytics_events_spec.rb b/spec/requests/projects/cycle_analytics_events_spec.rb
index 51db9bb07fa..e2733be4c3a 100644
--- a/spec/requests/projects/cycle_analytics_events_spec.rb
+++ b/spec/requests/projects/cycle_analytics_events_spec.rb
@@ -3,66 +3,95 @@ require 'spec_helper'
describe 'cycle analytics events' do
let(:user) { create(:user) }
let(:project) { create(:project) }
- let!(:issue) { create(:issue, project: project, created_at: 2.days.ago) }
describe 'GET /:namespace/:project/cycle_analytics/events/issues' do
before do
project.team << [user, :developer]
- milestone = create(:milestone, project: project)
- issue.update(milestone: milestone)
- create_merge_request_closing_issue(issue)
-
- merge_merge_requests_closing_issue(issue)
+ 3.times { create_cycle }
deploy_master
login_as(user)
end
- it 'lists the issue events' do
+ it 'lists the issue events in the right order' do
get namespace_project_cycle_analytics_issue_path(project.namespace, project, format: :json)
expect(json_response['events']).not_to be_empty
+
+ first_issue_iid = Issue.order(created_at: :desc).pluck(:iid).first.to_s
+
+ expect(json_response['events'].first['iid']).to eq(first_issue_iid)
end
- it 'lists the plan events' do
+ it 'lists the plan events in the right order' do
get namespace_project_cycle_analytics_plan_path(project.namespace, project, format: :json)
expect(json_response['events']).not_to be_empty
+
+ first_date = DateTime.parse(json_response['events'].first['commit']['authored_date'])
+ last_date = DateTime.parse(json_response['events'].last['commit']['authored_date'])
+
+ expect(first_date).to be > last_date
end
- it 'lists the code events' do
+ it 'lists the code events in the right order' do
get namespace_project_cycle_analytics_code_path(project.namespace, project, format: :json)
expect(json_response['events']).not_to be_empty
+
+ first_mr_iid = Issue.order(created_at: :desc).pluck(:iid).first.to_s
+
+ expect(json_response['events'].first['iid']).to eq(first_mr_iid)
end
- it 'lists the test events' do
+ it 'lists the test events in the right order' do
get namespace_project_cycle_analytics_test_path(project.namespace, project, format: :json)
expect(json_response['events']).not_to be_empty
+
+ # TODO create builds
end
- it 'lists the review events' do
+ it 'lists the review events in the right order' do
get namespace_project_cycle_analytics_review_path(project.namespace, project, format: :json)
expect(json_response['events']).not_to be_empty
+
+ first_mr_iid = Issue.order(created_at: :desc).pluck(:iid).first.to_s
+
+ expect(json_response['events'].first['iid']).to eq(first_mr_iid)
end
- it 'lists the staging events' do
+ it 'lists the staging events in the right order' do
get namespace_project_cycle_analytics_staging_path(project.namespace, project, format: :json)
expect(json_response['events']).not_to be_empty
+
+ # TODO create builds
end
- it 'lists the production events' do
+ it 'lists the production events in the right order' do
get namespace_project_cycle_analytics_production_path(project.namespace, project, format: :json)
expect(json_response['events']).not_to be_empty
+
+ first_issue_iid = Issue.order(created_at: :desc).pluck(:iid).first.to_s
+
+ expect(json_response['events'].first['iid']).to eq(first_issue_iid)
end
end
def json_response
JSON.parse(response.body)
end
+
+ def create_cycle
+ issue = create(:issue, project: project, created_at: 2.days.ago)
+ milestone = create(:milestone, project: project)
+ issue.update(milestone: milestone)
+
+ create_merge_request_closing_issue(issue)
+ merge_merge_requests_closing_issue(issue)
+ end
end