1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
require 'spec_helper'
describe 'CycleAnalytics#plan', feature: true do
let(:project) { create(:project) }
let(:from_date) { 10.days.ago }
let(:user) { create(:user, :admin) }
subject { CycleAnalytics.new(project, from: from_date) }
def create_commit_referencing_issue(issue)
sha = project.repository.commit_file(user, FFaker::Product.brand, "content", "Commit for ##{issue.iid}", "master", false)
commit = project.repository.commit(sha)
commit.create_cross_references!
end
generate_cycle_analytics_spec(phase: :plan,
data_fn: -> (context) { { issue: context.create(:issue, project: context.project) } },
start_time_conditions: [["issue associated with a milestone", -> (context, data) { data[:issue].update(milestone: context.create(:milestone, project: context.project)) }],
["list label added to issue", -> (context, data) { data[:issue].update(label_ids: [context.create(:label, lists: [context.create(:list)]).id]) }]],
end_time_conditions: [["issue mentioned in a commit", -> (context, data) { context.create_commit_referencing_issue(data[:issue]) }]])
context "when a regular label (instead of a list label) is added to the issue" do
it "returns nil" do
label = create(:label)
issue = create(:issue, project: project)
issue.update(label_ids: [label.id])
create_commit_referencing_issue(issue)
expect(subject.issue).to be_nil
end
end
it "does not include issues from other projects" do
other_project = create(:project)
list_label = create(:label, lists: [create(:list)])
issue = create(:issue, project: other_project)
issue.update(milestone: create(:milestone))
issue.update(label_ids: [list_label.id])
create_commit_referencing_issue(issue)
expect(subject.issue).to be_nil
end
end
|