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
@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
......
......@@ -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
......
......@@ -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
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