Browse Source

CLDC-4354: Return staging to real time post-testing (#3273)

* Revert "CLDC-4235, CLDC-4280: staging go-live testing prep (#3262)"

This reverts commit 21367a7e3e.

* CLDC-4280: continue to block future form use on staging
pull/3279/head
Nat Dean-Lewis 4 days ago committed by GitHub
parent
commit
04f3285bbf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 5
      Gemfile
  2. 9
      app/helpers/timecop_helper.rb
  3. 3
      app/mailers/devise_notify_mailer.rb
  4. 3
      app/mailers/notify_mailer.rb
  5. 20
      app/services/storage/s3_service.rb
  6. 4
      config/initializers/timecop.rb

5
Gemfile

@ -103,10 +103,6 @@ group :development do
gem "rubocop-rails", require: false gem "rubocop-rails", require: false
end end
group :test, :staging do
gem "timecop", "~> 0.9.4"
end
group :test do group :test do
gem "axe-core-rspec" gem "axe-core-rspec"
gem "capybara", require: false gem "capybara", require: false
@ -115,6 +111,7 @@ group :test do
gem "rspec-rails", require: false gem "rspec-rails", require: false
gem "selenium-webdriver", require: false gem "selenium-webdriver", require: false
gem "simplecov", require: false gem "simplecov", require: false
gem "timecop", "~> 0.9.4"
gem "webmock", require: false gem "webmock", require: false
end end

9
app/helpers/timecop_helper.rb

@ -1,9 +0,0 @@
module TimecopHelper
def without_timecop(&block)
if defined?(Timecop)
Timecop.return(&block)
else
yield
end
end
end

3
app/mailers/devise_notify_mailer.rb

@ -1,5 +1,4 @@
class DeviseNotifyMailer < Devise::Mailer class DeviseNotifyMailer < Devise::Mailer
include TimecopHelper
require "notifications/client" require "notifications/client"
def notify_client def notify_client
@ -9,13 +8,11 @@ class DeviseNotifyMailer < Devise::Mailer
def send_email(email_address, template_id, personalisation) def send_email(email_address, template_id, personalisation)
return true if intercept_send?(email_address) return true if intercept_send?(email_address)
without_timecop do
notify_client.send_email( notify_client.send_email(
email_address:, email_address:,
template_id:, template_id:,
personalisation:, personalisation:,
) )
end
rescue Notifications::Client::BadRequestError => e rescue Notifications::Client::BadRequestError => e
Sentry.capture_exception(e) Sentry.capture_exception(e)

3
app/mailers/notify_mailer.rb

@ -1,5 +1,4 @@
class NotifyMailer < ApplicationMailer class NotifyMailer < ApplicationMailer
include TimecopHelper
require "notifications/client" require "notifications/client"
def notify_client def notify_client
@ -9,14 +8,12 @@ class NotifyMailer < ApplicationMailer
def send_email(email, template_id, personalisation) def send_email(email, template_id, personalisation)
return true if intercept_send?(email) return true if intercept_send?(email)
without_timecop do
notify_client.send_email( notify_client.send_email(
email_address: email, email_address: email,
template_id:, template_id:,
personalisation:, personalisation:,
) )
end end
end
def personalisation(record, token, url, username: false) def personalisation(record, token, url, username: false)
{ {

20
app/services/storage/s3_service.rb

@ -1,7 +1,5 @@
module Storage module Storage
class S3Service < StorageService class S3Service < StorageService
include TimecopHelper
attr_reader :configuration attr_reader :configuration
def initialize(config_service, instance_name) def initialize(config_service, instance_name)
@ -13,43 +11,32 @@ module Storage
end end
def list_files(folder) def list_files(folder)
without_timecop do
@client.list_objects_v2(bucket: @configuration.bucket_name, prefix: folder) @client.list_objects_v2(bucket: @configuration.bucket_name, prefix: folder)
.flat_map { |response| response.contents.map(&:key) } .flat_map { |response| response.contents.map(&:key) }
end end
end
def folder_present?(folder) def folder_present?(folder)
without_timecop do
response = @client.list_objects_v2(bucket: @configuration.bucket_name, prefix: folder, max_keys: 1) response = @client.list_objects_v2(bucket: @configuration.bucket_name, prefix: folder, max_keys: 1)
response.key_count == 1 response.key_count == 1
end end
end
def get_presigned_url(file_name, duration, response_content_disposition: nil) def get_presigned_url(file_name, duration, response_content_disposition: nil)
without_timecop do
Aws::S3::Presigner Aws::S3::Presigner
.new({ client: @client }) .new({ client: @client })
.presigned_url(:get_object, bucket: @configuration.bucket_name, key: file_name, expires_in: duration, response_content_disposition:) .presigned_url(:get_object, bucket: @configuration.bucket_name, key: file_name, expires_in: duration, response_content_disposition:)
end end
end
def get_file_io(file_name) def get_file_io(file_name)
without_timecop do
@client.get_object(bucket: @configuration.bucket_name, key: file_name) @client.get_object(bucket: @configuration.bucket_name, key: file_name)
.body .body
end end
end
def get_file(file_name) def get_file(file_name)
without_timecop do
@client.get_object(bucket: @configuration.bucket_name, key: file_name) @client.get_object(bucket: @configuration.bucket_name, key: file_name)
.body.read .body.read
end end
end
def write_file(file_name, data, content_type: nil) def write_file(file_name, data, content_type: nil)
without_timecop do
if content_type.nil? if content_type.nil?
@client.put_object( @client.put_object(
body: data, body: data,
@ -65,28 +52,21 @@ module Storage
) )
end end
end end
end
def get_file_metadata(file_name) def get_file_metadata(file_name)
without_timecop do
@client.head_object(bucket: @configuration.bucket_name, key: file_name) @client.head_object(bucket: @configuration.bucket_name, key: file_name)
end end
end
def file_exists?(file_name) def file_exists?(file_name)
without_timecop do
@client.head_object(bucket: @configuration.bucket_name, key: file_name) @client.head_object(bucket: @configuration.bucket_name, key: file_name)
true true
end
rescue Aws::S3::Errors::NotFound rescue Aws::S3::Errors::NotFound
false false
end end
def delete_file(file_name) def delete_file(file_name)
without_timecop do
@client.delete_object(bucket: @configuration.bucket_name, key: file_name) @client.delete_object(bucket: @configuration.bucket_name, key: file_name)
end end
end
private private

4
config/initializers/timecop.rb

@ -1,4 +0,0 @@
if Rails.env.staging?
require "timecop"
Timecop.travel(Time.zone.local(2026, 4, 1))
end
Loading…
Cancel
Save