diff --git a/Gemfile b/Gemfile index d7f1db035..91ed6c8a8 100644 --- a/Gemfile +++ b/Gemfile @@ -103,10 +103,6 @@ group :development do gem "rubocop-rails", require: false end -group :test, :staging do - gem "timecop", "~> 0.9.4" -end - group :test do gem "axe-core-rspec" gem "capybara", require: false @@ -115,6 +111,7 @@ group :test do gem "rspec-rails", require: false gem "selenium-webdriver", require: false gem "simplecov", require: false + gem "timecop", "~> 0.9.4" gem "webmock", require: false end diff --git a/app/helpers/timecop_helper.rb b/app/helpers/timecop_helper.rb deleted file mode 100644 index 2780cc918..000000000 --- a/app/helpers/timecop_helper.rb +++ /dev/null @@ -1,9 +0,0 @@ -module TimecopHelper - def without_timecop(&block) - if defined?(Timecop) - Timecop.return(&block) - else - yield - end - end -end diff --git a/app/mailers/devise_notify_mailer.rb b/app/mailers/devise_notify_mailer.rb index d023ca843..4065e3aa9 100644 --- a/app/mailers/devise_notify_mailer.rb +++ b/app/mailers/devise_notify_mailer.rb @@ -1,5 +1,4 @@ class DeviseNotifyMailer < Devise::Mailer - include TimecopHelper require "notifications/client" def notify_client @@ -9,13 +8,11 @@ class DeviseNotifyMailer < Devise::Mailer def send_email(email_address, template_id, personalisation) return true if intercept_send?(email_address) - without_timecop do - notify_client.send_email( - email_address:, - template_id:, - personalisation:, - ) - end + notify_client.send_email( + email_address:, + template_id:, + personalisation:, + ) rescue Notifications::Client::BadRequestError => e Sentry.capture_exception(e) diff --git a/app/mailers/notify_mailer.rb b/app/mailers/notify_mailer.rb index 93187a749..21a6e0270 100644 --- a/app/mailers/notify_mailer.rb +++ b/app/mailers/notify_mailer.rb @@ -1,5 +1,4 @@ class NotifyMailer < ApplicationMailer - include TimecopHelper require "notifications/client" def notify_client @@ -9,13 +8,11 @@ class NotifyMailer < ApplicationMailer def send_email(email, template_id, personalisation) return true if intercept_send?(email) - without_timecop do - notify_client.send_email( - email_address: email, - template_id:, - personalisation:, - ) - end + notify_client.send_email( + email_address: email, + template_id:, + personalisation:, + ) end def personalisation(record, token, url, username: false) diff --git a/app/services/storage/s3_service.rb b/app/services/storage/s3_service.rb index c94a418b7..a6eef7d49 100644 --- a/app/services/storage/s3_service.rb +++ b/app/services/storage/s3_service.rb @@ -1,7 +1,5 @@ module Storage class S3Service < StorageService - include TimecopHelper - attr_reader :configuration def initialize(config_service, instance_name) @@ -13,79 +11,61 @@ module Storage end def list_files(folder) - without_timecop do - @client.list_objects_v2(bucket: @configuration.bucket_name, prefix: folder) - .flat_map { |response| response.contents.map(&:key) } - end + @client.list_objects_v2(bucket: @configuration.bucket_name, prefix: folder) + .flat_map { |response| response.contents.map(&:key) } end def folder_present?(folder) - without_timecop do - response = @client.list_objects_v2(bucket: @configuration.bucket_name, prefix: folder, max_keys: 1) - response.key_count == 1 - end + response = @client.list_objects_v2(bucket: @configuration.bucket_name, prefix: folder, max_keys: 1) + response.key_count == 1 end def get_presigned_url(file_name, duration, response_content_disposition: nil) - without_timecop do - Aws::S3::Presigner - .new({ client: @client }) - .presigned_url(:get_object, bucket: @configuration.bucket_name, key: file_name, expires_in: duration, response_content_disposition:) - end + Aws::S3::Presigner + .new({ client: @client }) + .presigned_url(:get_object, bucket: @configuration.bucket_name, key: file_name, expires_in: duration, response_content_disposition:) end def get_file_io(file_name) - without_timecop do - @client.get_object(bucket: @configuration.bucket_name, key: file_name) - .body - end + @client.get_object(bucket: @configuration.bucket_name, key: file_name) + .body end def get_file(file_name) - without_timecop do - @client.get_object(bucket: @configuration.bucket_name, key: file_name) - .body.read - end + @client.get_object(bucket: @configuration.bucket_name, key: file_name) + .body.read end def write_file(file_name, data, content_type: nil) - without_timecop do - if content_type.nil? - @client.put_object( - body: data, - bucket: @configuration.bucket_name, - key: file_name, - ) - else - @client.put_object( - body: data, - bucket: @configuration.bucket_name, - key: file_name, - content_type:, - ) - end + if content_type.nil? + @client.put_object( + body: data, + bucket: @configuration.bucket_name, + key: file_name, + ) + else + @client.put_object( + body: data, + bucket: @configuration.bucket_name, + key: file_name, + content_type:, + ) end end def get_file_metadata(file_name) - without_timecop do - @client.head_object(bucket: @configuration.bucket_name, key: file_name) - end + @client.head_object(bucket: @configuration.bucket_name, key: file_name) end def file_exists?(file_name) - without_timecop do - @client.head_object(bucket: @configuration.bucket_name, key: file_name) - true - end + @client.head_object(bucket: @configuration.bucket_name, key: file_name) + true rescue Aws::S3::Errors::NotFound false end def delete_file(file_name) - without_timecop do - @client.delete_object(bucket: @configuration.bucket_name, key: file_name) - end + @client.delete_object(bucket: @configuration.bucket_name, key: file_name) end private diff --git a/config/initializers/timecop.rb b/config/initializers/timecop.rb deleted file mode 100644 index 6e1f6fdf7..000000000 --- a/config/initializers/timecop.rb +++ /dev/null @@ -1,4 +0,0 @@ -if Rails.env.staging? - require "timecop" - Timecop.travel(Time.zone.local(2026, 4, 1)) -end