2019-10-29 00:06:10 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-10-24 14:24:56 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 06:09:01 +00:00
|
|
|
RSpec.describe 'value stream analytics events' do
|
2016-10-24 14:24:56 +00:00
|
|
|
let(:user) { create(:user) }
|
2017-01-26 23:51:57 +00:00
|
|
|
let(:project) { create(:project, :repository, public_builds: false) }
|
2019-01-16 12:09:29 +00:00
|
|
|
let(:issue) { create(:issue, project: project, created_at: 2.days.ago) }
|
2016-10-24 14:24:56 +00:00
|
|
|
|
2020-02-07 21:08:39 +00:00
|
|
|
describe 'GET /:namespace/:project/value_stream_analytics/events/issues' do
|
2016-10-24 14:24:56 +00:00
|
|
|
before do
|
2017-12-22 08:18:28 +00:00
|
|
|
project.add_developer(user)
|
2016-10-24 14:24:56 +00:00
|
|
|
|
2017-01-25 10:55:11 +00:00
|
|
|
3.times do |count|
|
2020-10-02 12:09:03 +00:00
|
|
|
travel_to(Time.now + count.days) do
|
2017-01-25 10:55:11 +00:00
|
|
|
create_cycle
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-02-21 12:13:56 +00:00
|
|
|
deploy_master(user, project)
|
2016-10-24 14:49:25 +00:00
|
|
|
|
2016-10-24 14:24:56 +00:00
|
|
|
login_as(user)
|
|
|
|
end
|
|
|
|
|
2016-11-04 16:14:35 +00:00
|
|
|
it 'lists the issue events' do
|
2017-06-29 17:06:35 +00:00
|
|
|
get project_cycle_analytics_issue_path(project, format: :json)
|
2016-10-24 14:49:25 +00:00
|
|
|
|
2018-04-04 09:19:47 +00:00
|
|
|
first_issue_iid = project.issues.sort_by_attribute(:created_desc).pluck(:iid).first.to_s
|
2016-11-02 15:21:49 +00:00
|
|
|
|
2017-01-16 19:39:38 +00:00
|
|
|
expect(json_response['events']).not_to be_empty
|
2016-11-09 10:44:29 +00:00
|
|
|
expect(json_response['events'].first['iid']).to eq(first_issue_iid)
|
2016-10-24 14:49:25 +00:00
|
|
|
end
|
|
|
|
|
2016-11-04 16:14:35 +00:00
|
|
|
it 'lists the plan events' do
|
2017-06-29 17:06:35 +00:00
|
|
|
get project_cycle_analytics_plan_path(project, format: :json)
|
2016-10-24 14:49:25 +00:00
|
|
|
|
2019-06-17 13:17:18 +00:00
|
|
|
first_issue_iid = project.issues.sort_by_attribute(:created_desc).pluck(:iid).first.to_s
|
2016-11-02 15:21:49 +00:00
|
|
|
|
2017-01-16 19:39:38 +00:00
|
|
|
expect(json_response['events']).not_to be_empty
|
2019-06-17 13:17:18 +00:00
|
|
|
expect(json_response['events'].first['iid']).to eq(first_issue_iid)
|
2016-10-24 14:49:25 +00:00
|
|
|
end
|
|
|
|
|
2016-11-04 16:14:35 +00:00
|
|
|
it 'lists the code events' do
|
2017-06-29 17:06:35 +00:00
|
|
|
get project_cycle_analytics_code_path(project, format: :json)
|
2016-10-24 14:49:25 +00:00
|
|
|
|
2016-11-09 10:44:29 +00:00
|
|
|
expect(json_response['events']).not_to be_empty
|
2016-11-02 15:21:49 +00:00
|
|
|
|
2018-04-04 09:19:47 +00:00
|
|
|
first_mr_iid = project.merge_requests.sort_by_attribute(:created_desc).pluck(:iid).first.to_s
|
2016-11-02 15:21:49 +00:00
|
|
|
|
2016-11-09 10:44:29 +00:00
|
|
|
expect(json_response['events'].first['iid']).to eq(first_mr_iid)
|
2016-10-24 14:49:25 +00:00
|
|
|
end
|
|
|
|
|
2019-10-23 09:06:03 +00:00
|
|
|
it 'lists the test events', :sidekiq_might_not_need_inline do
|
2017-06-29 17:06:35 +00:00
|
|
|
get project_cycle_analytics_test_path(project, format: :json)
|
2016-10-24 14:49:25 +00:00
|
|
|
|
2016-11-09 10:44:29 +00:00
|
|
|
expect(json_response['events']).not_to be_empty
|
|
|
|
expect(json_response['events'].first['date']).not_to be_empty
|
2016-10-24 14:49:25 +00:00
|
|
|
end
|
|
|
|
|
2016-11-04 16:14:35 +00:00
|
|
|
it 'lists the review events' do
|
2017-06-29 17:06:35 +00:00
|
|
|
get project_cycle_analytics_review_path(project, format: :json)
|
2016-10-24 14:49:25 +00:00
|
|
|
|
2018-04-04 09:19:47 +00:00
|
|
|
first_mr_iid = project.merge_requests.sort_by_attribute(:created_desc).pluck(:iid).first.to_s
|
2016-11-02 15:21:49 +00:00
|
|
|
|
2017-01-16 19:39:38 +00:00
|
|
|
expect(json_response['events']).not_to be_empty
|
2016-11-09 10:44:29 +00:00
|
|
|
expect(json_response['events'].first['iid']).to eq(first_mr_iid)
|
2016-10-24 14:49:25 +00:00
|
|
|
end
|
|
|
|
|
2019-10-23 09:06:03 +00:00
|
|
|
it 'lists the staging events', :sidekiq_might_not_need_inline do
|
2017-06-29 17:06:35 +00:00
|
|
|
get project_cycle_analytics_staging_path(project, format: :json)
|
2016-10-24 14:49:25 +00:00
|
|
|
|
2016-11-09 10:44:29 +00:00
|
|
|
expect(json_response['events']).not_to be_empty
|
|
|
|
expect(json_response['events'].first['date']).not_to be_empty
|
2016-10-24 14:49:25 +00:00
|
|
|
end
|
|
|
|
|
2016-11-09 10:44:29 +00:00
|
|
|
context 'specific branch' do
|
2019-10-23 09:06:03 +00:00
|
|
|
it 'lists the test events', :sidekiq_might_not_need_inline do
|
2017-01-16 19:39:38 +00:00
|
|
|
branch = project.merge_requests.first.source_branch
|
2016-11-09 10:44:29 +00:00
|
|
|
|
2017-06-29 17:06:35 +00:00
|
|
|
get project_cycle_analytics_test_path(project, format: :json, branch: branch)
|
2016-11-09 10:44:29 +00:00
|
|
|
|
|
|
|
expect(json_response['events']).not_to be_empty
|
|
|
|
expect(json_response['events'].first['date']).not_to be_empty
|
|
|
|
end
|
2016-10-24 14:24:56 +00:00
|
|
|
end
|
2016-11-15 15:25:37 +00:00
|
|
|
|
|
|
|
context 'with private project and builds' do
|
|
|
|
before do
|
2017-08-15 10:27:37 +00:00
|
|
|
project.members.last.update(access_level: Gitlab::Access::GUEST)
|
2016-11-15 15:25:37 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not list the test events' do
|
2017-06-29 17:06:35 +00:00
|
|
|
get project_cycle_analytics_test_path(project, format: :json)
|
2016-11-15 15:25:37 +00:00
|
|
|
|
2017-10-19 18:28:19 +00:00
|
|
|
expect(response).to have_gitlab_http_status(:not_found)
|
2016-11-15 15:25:37 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not list the staging events' do
|
2017-06-29 17:06:35 +00:00
|
|
|
get project_cycle_analytics_staging_path(project, format: :json)
|
2016-11-15 15:25:37 +00:00
|
|
|
|
2017-10-19 18:28:19 +00:00
|
|
|
expect(response).to have_gitlab_http_status(:not_found)
|
2016-11-15 15:25:37 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'lists the issue events' do
|
2017-06-29 17:06:35 +00:00
|
|
|
get project_cycle_analytics_issue_path(project, format: :json)
|
2016-11-15 15:25:37 +00:00
|
|
|
|
2017-10-19 18:28:19 +00:00
|
|
|
expect(response).to have_gitlab_http_status(:ok)
|
2016-11-15 15:25:37 +00:00
|
|
|
end
|
|
|
|
end
|
2016-10-24 14:24:56 +00:00
|
|
|
end
|
|
|
|
|
2016-11-02 15:21:49 +00:00
|
|
|
def create_cycle
|
|
|
|
milestone = create(:milestone, project: project)
|
|
|
|
issue.update(milestone: milestone)
|
2018-02-21 12:13:56 +00:00
|
|
|
mr = create_merge_request_closing_issue(user, project, issue, commit_message: "References #{issue.to_reference}")
|
2016-11-03 10:28:14 +00:00
|
|
|
|
2017-05-19 20:51:07 +00:00
|
|
|
pipeline = create(:ci_empty_pipeline, status: 'created', project: project, ref: mr.source_branch, sha: mr.source_branch_sha, head_pipeline_of: mr)
|
2016-11-03 10:28:14 +00:00
|
|
|
pipeline.run
|
2016-11-02 15:21:49 +00:00
|
|
|
|
2016-11-04 16:14:35 +00:00
|
|
|
create(:ci_build, pipeline: pipeline, status: :success, author: user)
|
|
|
|
create(:ci_build, pipeline: pipeline, status: :success, author: user)
|
|
|
|
|
2018-02-21 12:13:56 +00:00
|
|
|
merge_merge_requests_closing_issue(user, project, issue)
|
2016-11-16 08:58:23 +00:00
|
|
|
|
2016-11-24 14:07:44 +00:00
|
|
|
ProcessCommitWorker.new.perform(project.id, user.id, mr.commits.last.to_hash)
|
2016-11-02 15:21:49 +00:00
|
|
|
end
|
2016-10-24 14:24:56 +00:00
|
|
|
end
|