diff options
author | Timothy Andrew <mail@timothyandrew.net> | 2016-08-26 13:48:52 +0300 |
---|---|---|
committer | Timothy Andrew <mail@timothyandrew.net> | 2016-08-26 13:58:20 +0300 |
commit | 331080bca683fdab73520f68c53f6a5367d17f22 (patch) | |
tree | 2aaf99f087b86c25fe7e0d25feb22f501437bdf9 /spec/models | |
parent | ce6bcdd0043caf267d5d4478d45741aa4ecf1ac9 (diff) |
Fetch cycle analytics data for a specific date range.
1. Supported date ranges are 30 / 90 days ago. The default is 90 days
ago.
2. All issues created before "x days ago" are filtered out, even if they
have other related data (test runs, merge requests) within the filter
range.
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/cycle_analytics/issue_spec.rb | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/spec/models/cycle_analytics/issue_spec.rb b/spec/models/cycle_analytics/issue_spec.rb index 6fdce020642..4dc7f62af98 100644 --- a/spec/models/cycle_analytics/issue_spec.rb +++ b/spec/models/cycle_analytics/issue_spec.rb @@ -2,7 +2,8 @@ require 'spec_helper' describe 'CycleAnalytics#issue', models: true do let(:project) { create(:project) } - subject { CycleAnalytics.new(project) } + let(:from_date) { 10.days.ago } + subject { CycleAnalytics.new(project, from: from_date) } context "when calculating the median of times between: start: issue created_at @@ -26,16 +27,6 @@ describe 'CycleAnalytics#issue', models: true do median_start_time, median_end_time = start_and_end_times[2] expect(subject.issue).to eq(median_end_time - median_start_time) end - - it "does not include issues from other projects" do - 5.times do - milestone = create(:milestone, project: project) - issue = create(:issue) - issue.update(milestone: milestone) - end - - expect(subject.issue).to be_nil - end end context "when a label is added to the issue" do @@ -80,6 +71,29 @@ describe 'CycleAnalytics#issue', models: true do expect(subject.issue).to eq(milestone_add_time - start_time) end + + + it "does not include issues from other projects" do + milestone = create(:milestone, project: project) + list_label = create(:label, lists: [create(:list)]) + issue = create(:issue) + issue.update(milestone: milestone) + issue.update(label_ids: [list_label.id]) + + expect(subject.issue).to be_nil + end + + it "excludes issues created before the 'from' date" do + before_from_date = from_date - 5.days + + milestone = create(:milestone, project: project) + list_label = create(:label, lists: [create(:list)]) + issue = Timecop.freeze(before_from_date) { create(:issue, project: project)} + issue.update(milestone: milestone) + issue.update(label_ids: [list_label.id]) + + expect(subject.issue).to be_nil + end end end end |