Commit 9ead268c authored by James Lopez's avatar James Lopez

some more integration scenarios testing order. Also, fixed bug in the staging and test stages.

parent 85c448d7
...@@ -9,8 +9,6 @@ module Gitlab ...@@ -9,8 +9,6 @@ module Gitlab
@fetcher = EventsFetcher.new(project: project, from: from) @fetcher = EventsFetcher.new(project: project, from: from)
end end
# TODO: backend pagination - specially for commits, etc...
def issue_events def issue_events
@fetcher.fetch(stage: :issue).each { |event| parse_event(event) } @fetcher.fetch(stage: :issue).each { |event| parse_event(event) }
end end
......
...@@ -50,7 +50,7 @@ module Gitlab ...@@ -50,7 +50,7 @@ module Gitlab
def test def test
{ start_time_attrs: mr_metrics_table[:latest_build_started_at], { start_time_attrs: mr_metrics_table[:latest_build_started_at],
end_time_attrs: mr_metrics_table[:latest_build_finished_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] order: mr_table[:created_at]
} }
end end
...@@ -68,7 +68,7 @@ module Gitlab ...@@ -68,7 +68,7 @@ module Gitlab
def staging def staging
{ start_time_attrs: mr_metrics_table[:merged_at], { start_time_attrs: mr_metrics_table[:merged_at],
end_time_attrs: mr_metrics_table[:first_deployed_to_production_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 end
......
...@@ -3,66 +3,95 @@ require 'spec_helper' ...@@ -3,66 +3,95 @@ require 'spec_helper'
describe 'cycle analytics events' do describe 'cycle analytics events' do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project) } let(:project) { create(:project) }
let!(:issue) { create(:issue, project: project, created_at: 2.days.ago) }
describe 'GET /:namespace/:project/cycle_analytics/events/issues' do describe 'GET /:namespace/:project/cycle_analytics/events/issues' do
before do before do
project.team << [user, :developer] project.team << [user, :developer]
milestone = create(:milestone, project: project) 3.times { create_cycle }
issue.update(milestone: milestone)
create_merge_request_closing_issue(issue)
merge_merge_requests_closing_issue(issue)
deploy_master deploy_master
login_as(user) login_as(user)
end 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) get namespace_project_cycle_analytics_issue_path(project.namespace, project, format: :json)
expect(json_response['events']).not_to be_empty 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
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) get namespace_project_cycle_analytics_plan_path(project.namespace, project, format: :json)
expect(json_response['events']).not_to be_empty 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 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) get namespace_project_cycle_analytics_code_path(project.namespace, project, format: :json)
expect(json_response['events']).not_to be_empty 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 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) get namespace_project_cycle_analytics_test_path(project.namespace, project, format: :json)
expect(json_response['events']).not_to be_empty expect(json_response['events']).not_to be_empty
# TODO create builds
end 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) get namespace_project_cycle_analytics_review_path(project.namespace, project, format: :json)
expect(json_response['events']).not_to be_empty 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 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) get namespace_project_cycle_analytics_staging_path(project.namespace, project, format: :json)
expect(json_response['events']).not_to be_empty expect(json_response['events']).not_to be_empty
# TODO create builds
end 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) get namespace_project_cycle_analytics_production_path(project.namespace, project, format: :json)
expect(json_response['events']).not_to be_empty 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
end end
def json_response def json_response
JSON.parse(response.body) JSON.parse(response.body)
end 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 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