summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMałgorzata Ksionek <mksionek@gitlab.com>2019-07-16 12:28:08 +0200
committerMałgorzata Ksionek <mksionek@gitlab.com>2019-07-16 12:35:09 +0200
commite6c61c89527eb1a8f0f8affff5a76c81af656d8e (patch)
tree35e36af0452a25eae13fbc991d106cc871616aad
parent1dde18f39424f6eaebe1777d0bfa35c5805178cd (diff)
downloadgitlab-ce-e6c61c89527eb1a8f0f8affff5a76c81af656d8e.tar.gz
Add timecop remarks
-rw-r--r--spec/lib/gitlab/cycle_analytics/group_stage_summary_spec.rb84
1 files changed, 54 insertions, 30 deletions
diff --git a/spec/lib/gitlab/cycle_analytics/group_stage_summary_spec.rb b/spec/lib/gitlab/cycle_analytics/group_stage_summary_spec.rb
index 7e79c3f939c..6505fc714c4 100644
--- a/spec/lib/gitlab/cycle_analytics/group_stage_summary_spec.rb
+++ b/spec/lib/gitlab/cycle_analytics/group_stage_summary_spec.rb
@@ -11,56 +11,80 @@ describe Gitlab::CycleAnalytics::GroupStageSummary do
subject { described_class.new(group, from: Time.now, current_user: user).data }
describe "#new_issues" do
- it "finds the number of issues created after the 'from date'" do
- Timecop.freeze(5.days.ago) { create(:issue, project: project) }
- Timecop.freeze(5.days.ago) { create(:issue, project: project_2) }
- Timecop.freeze(5.days.from_now) { create(:issue, project: project) }
- Timecop.freeze(5.days.from_now) { create(:issue, project: project_2) }
+ context 'with from date' do
+ before do
+ Timecop.freeze(5.days.ago) { create(:issue, project: project) }
+ Timecop.freeze(5.days.ago) { create(:issue, project: project_2) }
+ Timecop.freeze(5.days.from_now) { create(:issue, project: project) }
+ Timecop.freeze(5.days.from_now) { create(:issue, project: project_2) }
+ end
- expect(subject.first[:value]).to eq(2)
+ it "finds the number of issues created after it" do
+ expect(subject.first[:value]).to eq(2)
+ end
end
- it "doesn't find issues from other projects" do
- Timecop.freeze(5.days.from_now) { create(:issue, project: create(:project, namespace: create(:group))) }
- Timecop.freeze(5.days.from_now) { create(:issue, project: project) }
- Timecop.freeze(5.days.from_now) { create(:issue, project: project_2) }
+ context 'with other projects' do
+ before do
+ Timecop.freeze(5.days.from_now) { create(:issue, project: create(:project, namespace: create(:group))) }
+ Timecop.freeze(5.days.from_now) { create(:issue, project: project) }
+ Timecop.freeze(5.days.from_now) { create(:issue, project: project_2) }
+ end
- expect(subject.first[:value]).to eq(2)
+ it "doesn't find issues from them" do
+ expect(subject.first[:value]).to eq(2)
+ end
end
- it "finds issues from subgroups" do
- Timecop.freeze(5.days.from_now) { create(:issue, project: create(:project, namespace: create(:group, parent: group))) }
- Timecop.freeze(5.days.from_now) { create(:issue, project: project) }
- Timecop.freeze(5.days.from_now) { create(:issue, project: project_2) }
+ context 'with subgroups' do
+ before do
+ Timecop.freeze(5.days.from_now) { create(:issue, project: create(:project, namespace: create(:group, parent: group))) }
+ Timecop.freeze(5.days.from_now) { create(:issue, project: project) }
+ Timecop.freeze(5.days.from_now) { create(:issue, project: project_2) }
+ end
- expect(subject.first[:value]).to eq(3)
+ it "finds issues from them" do
+ expect(subject.first[:value]).to eq(3)
+ end
end
end
describe "#deploys" do
- it "finds the number of deploys made created after the 'from date'" do
- Timecop.freeze(5.days.ago) { create(:deployment, :success, project: project) }
- Timecop.freeze(5.days.from_now) { create(:deployment, :success, project: project) }
- Timecop.freeze(5.days.ago) { create(:deployment, :success, project: project_2) }
- Timecop.freeze(5.days.from_now) { create(:deployment, :success, project: project_2) }
+ context 'with from date' do
+ before do
+ Timecop.freeze(5.days.ago) { create(:deployment, :success, project: project) }
+ Timecop.freeze(5.days.from_now) { create(:deployment, :success, project: project) }
+ Timecop.freeze(5.days.ago) { create(:deployment, :success, project: project_2) }
+ Timecop.freeze(5.days.from_now) { create(:deployment, :success, project: project_2) }
+ end
- expect(subject.second[:value]).to eq(2)
+ it "finds the number of deploys made created after it" do
+ expect(subject.second[:value]).to eq(2)
+ end
end
- it "doesn't find deploys from other projects" do
- Timecop.freeze(5.days.from_now) do
- create(:deployment, :success, project: create(:project, :repository, namespace: create(:group)))
+ context 'with other projects' do
+ before do
+ Timecop.freeze(5.days.from_now) do
+ create(:deployment, :success, project: create(:project, :repository, namespace: create(:group)))
+ end
end
- expect(subject.second[:value]).to eq(0)
+ it "doesn't find deploys from them" do
+ expect(subject.second[:value]).to eq(0)
+ end
end
- it "finds deploys from subgroups" do
- Timecop.freeze(5.days.from_now) do
- create(:deployment, :success, project: create(:project, :repository, namespace: create(:group, parent: group)))
+ context 'with subgroups' do
+ before do
+ Timecop.freeze(5.days.from_now) do
+ create(:deployment, :success, project: create(:project, :repository, namespace: create(:group, parent: group)))
+ end
end
- expect(subject.second[:value]).to eq(1)
+ it "finds deploys from them" do
+ expect(subject.second[:value]).to eq(1)
+ end
end
end
end