2016-10-13 11:11:28 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Gitlab::CycleAnalytics::Events do
|
|
|
|
let(:project) { create(:project) }
|
|
|
|
let(:from_date) { 10.days.ago }
|
|
|
|
let(:user) { create(:user, :admin) }
|
2016-11-03 10:41:46 -04:00
|
|
|
let!(:context) { create(:issue, project: project, created_at: 2.days.ago) }
|
2016-10-13 11:11:28 -04:00
|
|
|
|
2016-11-04 07:57:23 -04:00
|
|
|
subject { described_class.new(project: project, options: { from: from_date }) }
|
2016-10-13 11:11:28 -04:00
|
|
|
|
|
|
|
before do
|
|
|
|
setup(context)
|
|
|
|
end
|
|
|
|
|
2016-10-19 06:47:09 -04:00
|
|
|
describe '#issue_events' do
|
|
|
|
it 'has the total time' do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.issue_events.first[:total_time]).to eq('2 days')
|
2016-10-17 08:57:23 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has a title' do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.issue_events.first[:title]).to eq(context.title)
|
2016-10-17 08:57:23 -04:00
|
|
|
end
|
|
|
|
|
2016-11-04 11:16:15 -04:00
|
|
|
it 'has the URL' do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.issue_events.first[:url]).not_to be_nil
|
2016-11-04 11:16:15 -04:00
|
|
|
end
|
|
|
|
|
2016-10-17 08:57:23 -04:00
|
|
|
it 'has an iid' do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.issue_events.first[:iid]).to eq(context.iid.to_s)
|
2016-10-17 08:57:23 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has a created_at timestamp' do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.issue_events.first[:created_at]).to end_with('ago')
|
2016-10-17 08:57:23 -04:00
|
|
|
end
|
|
|
|
|
2016-11-03 08:06:14 -04:00
|
|
|
it "has the author's URL" do
|
2016-11-15 04:33:01 -05:00
|
|
|
expect(subject.issue_events.first[:author][:web_url]).not_to be_nil
|
2016-11-03 08:06:14 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "has the author's avatar URL" do
|
2016-11-15 04:33:01 -05:00
|
|
|
expect(subject.issue_events.first[:author][:avatar_url]).not_to be_nil
|
2016-10-27 12:52:42 -04:00
|
|
|
end
|
|
|
|
|
2016-10-17 08:57:23 -04:00
|
|
|
it "has the author's name" do
|
2016-11-15 04:33:01 -05:00
|
|
|
expect(subject.issue_events.first[:author][:name]).to eq(context.author.name)
|
2016-10-13 11:11:28 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-10-19 06:47:09 -04:00
|
|
|
describe '#plan_events' do
|
2016-11-03 10:41:46 -04:00
|
|
|
it 'has a title' do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.plan_events.first[:title]).not_to be_nil
|
2016-11-03 10:41:46 -04:00
|
|
|
end
|
2016-10-19 06:47:09 -04:00
|
|
|
|
2016-11-03 10:41:46 -04:00
|
|
|
it 'has a sha short ID' do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.plan_events.first[:sha]).not_to be_nil
|
2016-10-19 06:47:09 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has the total time' do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.plan_events.first[:total_time]).to eq('less than a minute')
|
2016-10-20 04:08:53 -04:00
|
|
|
end
|
2016-11-03 10:41:46 -04:00
|
|
|
|
|
|
|
it "has the author's URL" do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.plan_events.first[:author_profile_url]).not_to be_nil
|
2016-11-03 10:41:46 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "has the author's avatar URL" do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.plan_events.first[:author_avatar_url]).not_to be_nil
|
2016-11-03 10:41:46 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "has the author's name" do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.plan_events.first[:author_name]).not_to be_nil
|
2016-11-03 10:41:46 -04:00
|
|
|
end
|
2016-10-20 04:08:53 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
describe '#code_events' do
|
|
|
|
before do
|
|
|
|
create_commit_referencing_issue(context)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has the total time' do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.code_events.first[:total_time]).to eq('less than a minute')
|
2016-10-20 04:08:53 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has a title' do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.code_events.first[:title]).to eq('Awesome merge_request')
|
2016-10-20 04:08:53 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has an iid' do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.code_events.first[:iid]).to eq(context.iid.to_s)
|
2016-10-20 04:08:53 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has a created_at timestamp' do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.code_events.first[:created_at]).to end_with('ago')
|
2016-10-20 04:08:53 -04:00
|
|
|
end
|
|
|
|
|
2016-11-03 11:31:30 -04:00
|
|
|
it "has the author's URL" do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.code_events.first[:author_profile_url]).not_to be_nil
|
2016-11-03 11:31:30 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "has the author's avatar URL" do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.code_events.first[:author_avatar_url]).not_to be_nil
|
2016-10-27 12:52:42 -04:00
|
|
|
end
|
|
|
|
|
2016-10-20 04:08:53 -04:00
|
|
|
it "has the author's name" do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.code_events.first[:author_name]).to eq(context.author.name)
|
2016-10-19 06:47:09 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-10-20 10:20:04 -04:00
|
|
|
describe '#test_events' do
|
|
|
|
let(:merge_request) { MergeRequest.first }
|
2016-10-21 03:44:04 -04:00
|
|
|
let!(:pipeline) do
|
|
|
|
create(:ci_pipeline,
|
|
|
|
ref: merge_request.source_branch,
|
|
|
|
sha: merge_request.diff_head_sha,
|
|
|
|
project: context.project)
|
|
|
|
end
|
2016-10-20 10:20:04 -04:00
|
|
|
|
|
|
|
before do
|
2016-11-14 08:53:06 -05:00
|
|
|
create(:ci_build, pipeline: pipeline, status: :success, author: user)
|
|
|
|
create(:ci_build, pipeline: pipeline, status: :success, author: user)
|
2016-11-04 06:56:24 -04:00
|
|
|
|
2016-10-20 10:20:04 -04:00
|
|
|
pipeline.run!
|
|
|
|
pipeline.succeed!
|
|
|
|
end
|
|
|
|
|
2016-11-04 06:56:24 -04:00
|
|
|
it 'has the name' do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.test_events.first[:name]).not_to be_nil
|
2016-11-04 06:56:24 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has the ID' do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.test_events.first[:id]).not_to be_nil
|
2016-11-04 06:56:24 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has the URL' do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.test_events.first[:url]).not_to be_nil
|
2016-11-04 06:56:24 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has the branch name' do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.test_events.first[:branch]).not_to be_nil
|
2016-11-04 06:56:24 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has the branch URL' do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.test_events.first[:branch][:url]).not_to be_nil
|
2016-11-04 06:56:24 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has the short SHA' do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.test_events.first[:short_sha]).not_to be_nil
|
2016-11-04 06:56:24 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has the commit URL' do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.test_events.first[:commit_url]).not_to be_nil
|
2016-11-04 06:56:24 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has the date' do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.test_events.first[:date]).not_to be_nil
|
2016-10-20 10:20:04 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has the total time' do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.test_events.first[:total_time]).not_to be_nil
|
2016-10-20 10:20:04 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-10-21 02:50:27 -04:00
|
|
|
describe '#review_events' do
|
|
|
|
let!(:context) { create(:issue, project: project, created_at: 2.days.ago) }
|
|
|
|
|
|
|
|
it 'has the total time' do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.review_events.first[:total_time]).to eq('less than a minute')
|
2016-10-21 02:50:27 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has a title' do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.review_events.first[:title]).to eq('Awesome merge_request')
|
2016-10-21 02:50:27 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has an iid' do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.review_events.first[:iid]).to eq(context.iid.to_s)
|
2016-10-21 02:50:27 -04:00
|
|
|
end
|
|
|
|
|
2016-11-04 10:59:27 -04:00
|
|
|
it 'has the URL' do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.review_events.first[:url]).not_to be_nil
|
2016-11-04 10:59:27 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has a state' do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.review_events.first[:state]).not_to be_nil
|
2016-11-04 10:59:27 -04:00
|
|
|
end
|
|
|
|
|
2016-10-21 02:50:27 -04:00
|
|
|
it 'has a created_at timestamp' do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.review_events.first[:opened_at]).not_to be_nil
|
2016-10-21 02:50:27 -04:00
|
|
|
end
|
|
|
|
|
2016-11-04 10:59:27 -04:00
|
|
|
it "has the author's URL" do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.review_events.first[:author_profile_url]).not_to be_nil
|
2016-11-04 10:59:27 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "has the author's avatar URL" do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.review_events.first[:author_avatar_url]).not_to be_nil
|
2016-10-27 12:52:42 -04:00
|
|
|
end
|
|
|
|
|
2016-10-21 02:50:27 -04:00
|
|
|
it "has the author's name" do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.review_events.first[:author_name]).to eq(MergeRequest.first.author.name)
|
2016-10-21 02:50:27 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-10-21 05:33:37 -04:00
|
|
|
describe '#staging_events' do
|
|
|
|
let(:merge_request) { MergeRequest.first }
|
|
|
|
let!(:pipeline) do
|
|
|
|
create(:ci_pipeline,
|
|
|
|
ref: merge_request.source_branch,
|
|
|
|
sha: merge_request.diff_head_sha,
|
|
|
|
project: context.project)
|
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
2016-11-04 10:59:27 -04:00
|
|
|
create(:ci_build, pipeline: pipeline, status: :success, author: user)
|
|
|
|
create(:ci_build, pipeline: pipeline, status: :success, author: user)
|
|
|
|
|
2016-10-21 05:33:37 -04:00
|
|
|
pipeline.run!
|
|
|
|
pipeline.succeed!
|
2016-11-03 10:41:46 -04:00
|
|
|
|
2016-10-21 05:33:37 -04:00
|
|
|
merge_merge_requests_closing_issue(context)
|
|
|
|
deploy_master
|
|
|
|
end
|
|
|
|
|
2016-11-04 10:59:27 -04:00
|
|
|
it 'has the name' do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.staging_events.first[:name]).not_to be_nil
|
2016-11-04 10:59:27 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has the ID' do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.staging_events.first[:id]).not_to be_nil
|
2016-11-04 10:59:27 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has the URL' do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.staging_events.first[:url]).not_to be_nil
|
2016-11-04 10:59:27 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has the branch name' do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.staging_events.first[:branch]).not_to be_nil
|
2016-11-04 10:59:27 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has the branch URL' do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.staging_events.first[:branch_url]).not_to be_nil
|
2016-11-04 10:59:27 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has the short SHA' do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.staging_events.first[:sha]).not_to be_nil
|
2016-11-04 10:59:27 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has the commit URL' do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.staging_events.first[:commit_url]).not_to be_nil
|
2016-11-04 10:59:27 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has the date' do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.staging_events.first[:date]).not_to be_nil
|
2016-10-21 05:33:37 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has the total time' do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.staging_events.first[:total_time]).not_to be_nil
|
2016-11-04 10:59:27 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has the author name' do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.staging_events.first[:author_name]).not_to be_nil
|
2016-10-21 05:33:37 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-10-21 11:30:38 -04:00
|
|
|
describe '#production_events' do
|
|
|
|
let!(:context) { create(:issue, project: project, created_at: 2.days.ago) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
merge_merge_requests_closing_issue(context)
|
|
|
|
deploy_master
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has the total time' do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.production_events.first[:total_time]).to eq('2 days')
|
2016-10-21 11:30:38 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has a title' do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.production_events.first[:title]).to eq(context.title)
|
2016-10-21 11:30:38 -04:00
|
|
|
end
|
|
|
|
|
2016-11-04 11:16:15 -04:00
|
|
|
it 'has the URL' do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.production_events.first[:url]).not_to be_nil
|
2016-11-04 11:16:15 -04:00
|
|
|
end
|
|
|
|
|
2016-10-21 11:30:38 -04:00
|
|
|
it 'has an iid' do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.production_events.first[:iid]).to eq(context.iid.to_s)
|
2016-10-21 11:30:38 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has a created_at timestamp' do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.production_events.first[:created_at]).to end_with('ago')
|
2016-10-21 11:30:38 -04:00
|
|
|
end
|
|
|
|
|
2016-11-04 11:16:15 -04:00
|
|
|
it "has the author's URL" do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.production_events.first[:author_profile_url]).not_to be_nil
|
2016-11-04 11:16:15 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "has the author's avatar URL" do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.production_events.first[:author_avatar_url]).not_to be_nil
|
2016-10-27 12:52:42 -04:00
|
|
|
end
|
|
|
|
|
2016-10-21 11:30:38 -04:00
|
|
|
it "has the author's name" do
|
2016-11-14 08:53:06 -05:00
|
|
|
expect(subject.production_events.first[:author_name]).to eq(context.author.name)
|
2016-10-21 11:30:38 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-10-13 11:11:28 -04:00
|
|
|
def setup(context)
|
2016-10-14 11:33:21 -04:00
|
|
|
milestone = create(:milestone, project: project)
|
|
|
|
context.update(milestone: milestone)
|
2016-10-13 11:11:28 -04:00
|
|
|
create_merge_request_closing_issue(context)
|
|
|
|
end
|
|
|
|
end
|