2016-09-07 05:23:01 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe 'CycleAnalytics#review', feature: true do
|
2016-09-20 19:17:37 +00:00
|
|
|
extend CycleAnalyticsHelpers::TestGeneration
|
|
|
|
|
2017-01-26 22:44:58 +00:00
|
|
|
let(:project) { create(:project, :repository) }
|
2016-09-07 05:23:01 +00:00
|
|
|
let(:from_date) { 10.days.ago }
|
|
|
|
let(:user) { create(:user, :admin) }
|
2016-12-01 11:44:35 +00:00
|
|
|
subject { CycleAnalytics.new(project, from: from_date) }
|
2016-09-07 05:23:01 +00:00
|
|
|
|
2016-09-20 19:17:37 +00:00
|
|
|
generate_cycle_analytics_spec(
|
|
|
|
phase: :review,
|
|
|
|
data_fn: -> (context) { { issue: context.create(:issue, project: context.project) } },
|
|
|
|
start_time_conditions: [["merge request that closes issue is created",
|
|
|
|
-> (context, data) do
|
|
|
|
context.create_merge_request_closing_issue(data[:issue])
|
|
|
|
end]],
|
|
|
|
end_time_conditions: [["merge request that closes issue is merged",
|
|
|
|
-> (context, data) do
|
|
|
|
context.merge_merge_requests_closing_issue(data[:issue])
|
|
|
|
end]],
|
2016-10-11 10:58:56 +00:00
|
|
|
post_fn: nil)
|
2016-09-07 05:23:01 +00:00
|
|
|
|
|
|
|
context "when a regular merge request (that doesn't close the issue) is created and merged" do
|
|
|
|
it "returns nil" do
|
|
|
|
5.times do
|
|
|
|
MergeRequests::MergeService.new(project, user).execute(create(:merge_request))
|
|
|
|
end
|
|
|
|
|
2016-12-01 11:44:35 +00:00
|
|
|
expect(subject[:review].median).to be_nil
|
2016-09-07 05:23:01 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|