Commit 58a8881c authored by Dylan Griffith's avatar Dylan Griffith

Merge branch '322092-time-dependent-test-failure-in-spec-services-namespaces' into 'master'

Resolve "Time-dependent test failure in spec/services/namespaces/in_product_marketing_emails_service_spec.rb"

See merge request gitlab-org/gitlab!57220
parents 55af84cd 2dec5efb
...@@ -110,7 +110,8 @@ module Namespaces ...@@ -110,7 +110,8 @@ module Namespaces
end end
def range def range
(interval + 1).days.ago.beginning_of_day..(interval + 1).days.ago.end_of_day date = (interval + 1).days.ago
date.beginning_of_day..date.end_of_day
end end
def incomplete_action def incomplete_action
......
...@@ -3,14 +3,12 @@ ...@@ -3,14 +3,12 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe Namespaces::InProductMarketingEmailsService, '#execute' do RSpec.describe Namespaces::InProductMarketingEmailsService, '#execute' do
subject(:execute_service) do subject(:execute_service) { described_class.new(track, interval).execute }
travel_to(frozen_time) { described_class.new(track, interval).execute }
end
let(:track) { :create } let(:track) { :create }
let(:interval) { 1 } let(:interval) { 1 }
let(:frozen_time) { Time.current } let(:frozen_time) { Time.zone.parse('23 Mar 2021 10:14:40 UTC') }
let(:previous_action_completed_at) { frozen_time - 2.days } let(:previous_action_completed_at) { frozen_time - 2.days }
let(:current_action_completed_at) { nil } let(:current_action_completed_at) { nil }
let(:experiment_enabled) { true } let(:experiment_enabled) { true }
...@@ -21,6 +19,7 @@ RSpec.describe Namespaces::InProductMarketingEmailsService, '#execute' do ...@@ -21,6 +19,7 @@ RSpec.describe Namespaces::InProductMarketingEmailsService, '#execute' do
let_it_be(:user) { create(:user, email_opted_in: true) } let_it_be(:user) { create(:user, email_opted_in: true) }
before do before do
travel_to(frozen_time)
create(:onboarding_progress, namespace: group, **actions_completed) create(:onboarding_progress, namespace: group, **actions_completed)
group.add_developer(user) group.add_developer(user)
stub_experiment_for_subject(in_product_marketing_emails: experiment_enabled) stub_experiment_for_subject(in_product_marketing_emails: experiment_enabled)
......
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