diff options
author | Timothy Andrew <mail@timothyandrew.net> | 2016-08-26 15:45:00 +0530 |
---|---|---|
committer | Timothy Andrew <mail@timothyandrew.net> | 2016-08-26 16:28:20 +0530 |
commit | df6c9c33b69e411d4f7d27cc46e9769a07d12285 (patch) | |
tree | 0a6e0a20a2371c0462371001542a34a9c9d00537 /spec/models/cycle_analytics | |
parent | a81de9ab4fc3c3720449069e91ee2431fd9eb024 (diff) | |
download | gitlab-ce-df6c9c33b69e411d4f7d27cc46e9769a07d12285.tar.gz |
Scope Cycle Analytics queries to a project
Diffstat (limited to 'spec/models/cycle_analytics')
-rw-r--r-- | spec/models/cycle_analytics/issue_spec.rb | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/spec/models/cycle_analytics/issue_spec.rb b/spec/models/cycle_analytics/issue_spec.rb index ba66c99631c..6fdce020642 100644 --- a/spec/models/cycle_analytics/issue_spec.rb +++ b/spec/models/cycle_analytics/issue_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe 'CycleAnalytics#issue', models: true do let(:project) { create(:project) } - subject { CycleAnalytics.new } + subject { CycleAnalytics.new(project) } context "when calculating the median of times between: start: issue created_at @@ -26,6 +26,16 @@ 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 @@ -47,14 +57,9 @@ describe 'CycleAnalytics#issue', models: true do it "does not make a calculation for regular labels" do 5.times do - start_time = Time.now - end_time = rand(1..10).days.from_now - regular_label = create(:label) - issue = Timecop.freeze(start_time) { create(:issue, project: project) } - Timecop.freeze(end_time) { issue.update(label_ids: [regular_label.id]) } - - [start_time, end_time] + issue = create(:issue, project: project) + issue.update(label_ids: [regular_label.id]) end expect(subject.issue).to be_nil |