2016-08-26 07:19:32 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-07-10 14:24:02 +00:00
|
|
|
describe 'CycleAnalytics#issue' 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-08-26 10:48:52 +00:00
|
|
|
let(:from_date) { 10.days.ago }
|
2016-09-20 05:47:36 +00:00
|
|
|
let(:user) { create(:user, :admin) }
|
2016-12-01 11:44:35 +00:00
|
|
|
subject { CycleAnalytics.new(project, from: from_date) }
|
2016-08-26 07:19:32 +00:00
|
|
|
|
2016-09-20 19:17:37 +00:00
|
|
|
generate_cycle_analytics_spec(
|
|
|
|
phase: :issue,
|
|
|
|
data_fn: -> (context) { { issue: context.build(:issue, project: context.project) } },
|
|
|
|
start_time_conditions: [["issue created", -> (context, data) { data[:issue].save }]],
|
|
|
|
end_time_conditions: [["issue associated with a milestone",
|
|
|
|
-> (context, data) do
|
|
|
|
if data[:issue].persisted?
|
|
|
|
data[:issue].update(milestone: context.create(:milestone, project: context.project))
|
|
|
|
end
|
|
|
|
end],
|
|
|
|
["list label added to issue",
|
|
|
|
-> (context, data) do
|
|
|
|
if data[:issue].persisted?
|
|
|
|
data[:issue].update(label_ids: [context.create(:label, lists: [context.create(:list)]).id])
|
|
|
|
end
|
|
|
|
end]],
|
|
|
|
post_fn: -> (context, data) do
|
|
|
|
if data[:issue].persisted?
|
|
|
|
context.create_merge_request_closing_issue(data[:issue].reload)
|
|
|
|
context.merge_merge_requests_closing_issue(data[:issue])
|
|
|
|
end
|
|
|
|
end)
|
2016-09-02 12:03:32 +00:00
|
|
|
|
|
|
|
context "when a regular label (instead of a list label) is added to the issue" do
|
|
|
|
it "returns nil" do
|
2017-01-29 22:53:48 +00:00
|
|
|
regular_label = create(:label)
|
|
|
|
issue = create(:issue, project: project)
|
|
|
|
issue.update(label_ids: [regular_label.id])
|
2016-09-20 05:47:36 +00:00
|
|
|
|
2017-01-29 22:53:48 +00:00
|
|
|
create_merge_request_closing_issue(issue)
|
|
|
|
merge_merge_requests_closing_issue(issue)
|
2016-09-02 06:49:40 +00:00
|
|
|
|
2016-12-01 11:44:35 +00:00
|
|
|
expect(subject[:issue].median).to be_nil
|
2016-08-26 07:19:32 +00:00
|
|
|
end
|
2016-09-02 06:49:40 +00:00
|
|
|
end
|
2016-08-26 07:19:32 +00:00
|
|
|
end
|