Commit e6c61c89 authored by Małgorzata Ksionek's avatar Małgorzata Ksionek

Add timecop remarks

parent 1dde18f3
...@@ -11,56 +11,80 @@ describe Gitlab::CycleAnalytics::GroupStageSummary do ...@@ -11,56 +11,80 @@ describe Gitlab::CycleAnalytics::GroupStageSummary do
subject { described_class.new(group, from: Time.now, current_user: user).data } subject { described_class.new(group, from: Time.now, current_user: user).data }
describe "#new_issues" do describe "#new_issues" do
it "finds the number of issues created after the 'from date'" do context 'with from date' do
Timecop.freeze(5.days.ago) { create(:issue, project: project) } before do
Timecop.freeze(5.days.ago) { create(:issue, project: project_2) } Timecop.freeze(5.days.ago) { create(:issue, project: project) }
Timecop.freeze(5.days.from_now) { create(:issue, project: project) } Timecop.freeze(5.days.ago) { create(:issue, project: project_2) }
Timecop.freeze(5.days.from_now) { 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 end
it "doesn't find issues from other projects" do context 'with other projects' do
Timecop.freeze(5.days.from_now) { create(:issue, project: create(:project, namespace: create(:group))) } before do
Timecop.freeze(5.days.from_now) { create(:issue, project: project) } Timecop.freeze(5.days.from_now) { create(:issue, project: create(:project, namespace: create(:group))) }
Timecop.freeze(5.days.from_now) { 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 "doesn't find issues from them" do
expect(subject.first[:value]).to eq(2)
end
end end
it "finds issues from subgroups" do context 'with subgroups' do
Timecop.freeze(5.days.from_now) { create(:issue, project: create(:project, namespace: create(:group, parent: group))) } before do
Timecop.freeze(5.days.from_now) { create(:issue, project: project) } 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_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(3) it "finds issues from them" do
expect(subject.first[:value]).to eq(3)
end
end end
end end
describe "#deploys" do describe "#deploys" do
it "finds the number of deploys made created after the 'from date'" do context 'with from date' do
Timecop.freeze(5.days.ago) { create(:deployment, :success, project: project) } before do
Timecop.freeze(5.days.from_now) { create(:deployment, :success, project: project) } Timecop.freeze(5.days.ago) { 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) }
Timecop.freeze(5.days.from_now) { create(:deployment, :success, project: project_2) } 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 end
it "doesn't find deploys from other projects" do context 'with other projects' do
Timecop.freeze(5.days.from_now) do before do
create(:deployment, :success, project: create(:project, :repository, namespace: create(:group))) Timecop.freeze(5.days.from_now) do
create(:deployment, :success, project: create(:project, :repository, namespace: create(:group)))
end
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 end
it "finds deploys from subgroups" do context 'with subgroups' do
Timecop.freeze(5.days.from_now) do before do
create(:deployment, :success, project: create(:project, :repository, namespace: create(:group, parent: group))) Timecop.freeze(5.days.from_now) do
create(:deployment, :success, project: create(:project, :repository, namespace: create(:group, parent: group)))
end
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 end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment