From 859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Thu, 18 Feb 2021 10:34:06 +0000 Subject: Add latest changes from gitlab-org/gitlab@13-9-stable-ee --- .../gitlab/cycle_analytics/stage_summary_spec.rb | 34 ++++++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-) (limited to 'spec/lib/gitlab/cycle_analytics/stage_summary_spec.rb') diff --git a/spec/lib/gitlab/cycle_analytics/stage_summary_spec.rb b/spec/lib/gitlab/cycle_analytics/stage_summary_spec.rb index 21503dc1501..76578340f7b 100644 --- a/spec/lib/gitlab/cycle_analytics/stage_summary_spec.rb +++ b/spec/lib/gitlab/cycle_analytics/stage_summary_spec.rb @@ -218,7 +218,7 @@ RSpec.describe Gitlab::CycleAnalytics::StageSummary do context 'when `to` is given' do before do - Timecop.freeze(5.days.from_now) { create(:deployment, :success, project: project) } + Timecop.freeze(5.days.from_now) { create(:deployment, :success, project: project, finished_at: Time.zone.now) } end it 'finds records created between `from` and `to` range' do @@ -230,12 +230,34 @@ RSpec.describe Gitlab::CycleAnalytics::StageSummary do end context 'when `from` and `to` are within a day' do - it 'returns the number of deployments made on that day' do - freeze_time do - create(:deployment, :success, project: project) - options[:from] = options[:to] = Time.now + context 'when query_deploymenys_via_finished_at_in_vsa feature flag is off' do + before do + stub_feature_flags(query_deploymenys_via_finished_at_in_vsa: false) + end + + it 'returns the number of deployments made on that day' do + freeze_time do + create(:deployment, :success, project: project) + options[:from] = options[:to] = Time.zone.now + + expect(subject).to eq('1') + end + end + end + + context 'when query_deploymenys_via_finished_at_in_vsa feature flag is off' do + before do + stub_feature_flags(query_deploymenys_via_finished_at_in_vsa: true) + end + + it 'returns the number of deployments made on that day' do + freeze_time do + create(:deployment, :success, project: project, finished_at: Time.zone.now) + options[:from] = Time.zone.now.at_beginning_of_day + options[:to] = Time.zone.now.at_end_of_day - expect(subject).to eq('1') + expect(subject).to eq('1') + end end end end -- cgit v1.2.1