From 43c95555ca98f444858cb84df3f12a8f39d653ad Mon Sep 17 00:00:00 2001 From: Jon Roberts Date: Thu, 5 Dec 2024 14:40:16 -0500 Subject: [PATCH] rubocop-rails to standard-rails reverts previous rubocop-rails fixes before 'new' fixes --- .rubocop.yml | 1 - .standard.yml | 3 + .standard_todo.yml | 89 ++++--------------- app/controllers/api/v1/base_controller.rb | 2 +- .../api/v1/users/sessions_controller.rb | 4 +- app/controllers/casa_admins_controller.rb | 2 +- app/controllers/users/passwords_controller.rb | 4 +- app/lib/importers/file_importer.rb | 2 +- app/models/all_casa_admin.rb | 2 +- app/models/casa_org.rb | 8 +- app/models/case_contact.rb | 10 ++- app/models/user.rb | 9 +- app/notifications/base_notifier.rb | 12 ++- db/seeds/db_populator.rb | 4 +- lib/tasks/no_contact_made_reminder.rb | 2 +- .../send_case_contact_types_reminder.rake | 2 +- lib/tasks/send_no_contact_made_reminder.rake | 2 +- .../case_contact_metadata_callback_spec.rb | 1 - spec/config/initializers/rack_attack_spec.rb | 1 - spec/helpers/notifications_helper_spec.rb | 2 - spec/lib/importers/case_importer_spec.rb | 4 - .../tasks/case_contact_types_reminder_spec.rb | 2 +- .../tasks/no_contact_made_reminder_spec.rb | 2 +- .../tasks/supervisor_weekly_digest_spec.rb | 4 - spec/mailers/supervisor_mailer_spec.rb | 6 +- spec/models/casa_case_spec.rb | 12 +-- spec/models/casa_org_spec.rb | 2 +- spec/models/case_contact_report_spec.rb | 4 +- spec/models/case_contact_spec.rb | 4 +- spec/models/case_court_report_context_spec.rb | 52 ++++++----- spec/models/court_date_spec.rb | 4 +- spec/models/volunteer_spec.rb | 6 +- spec/requests/banners_spec.rb | 2 - spec/requests/case_contact_reports_spec.rb | 2 - spec/requests/case_court_reports_spec.rb | 2 - spec/requests/court_dates_spec.rb | 2 - spec/requests/health_spec.rb | 8 -- spec/requests/imports_spec.rb | 4 - spec/requests/notifications_spec.rb | 2 - .../case_contacts_contact_dates_spec.rb | 2 - ...e_contact_started_metadata_service_spec.rb | 1 - ...ipation_checklist_reminder_service_spec.rb | 1 - ...olunteer_birthday_reminder_service_spec.rb | 3 - .../shows_court_dates_links.rb | 2 - spec/system/casa_cases/edit_spec.rb | 2 - spec/system/casa_cases/show_spec.rb | 2 - spec/system/case_contacts/index_spec.rb | 2 +- spec/system/court_dates/edit_spec.rb | 2 - spec/system/court_dates/new_spec.rb | 2 - spec/system/court_dates/view_spec.rb | 2 - spec/system/placements/destroy_spec.rb | 2 - spec/system/placements/edit_spec.rb | 2 - spec/system/placements/index_spec.rb | 2 - spec/system/placements/new_spec.rb | 2 - .../reimbursements/index.html.erb_spec.rb | 2 +- .../weekly_digest.html.erb_spec.rb | 4 +- 56 files changed, 100 insertions(+), 221 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index dedabbdd85..ec60988a62 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,7 +1,6 @@ require: - rubocop-capybara - rubocop-factory_bot - - rubocop-rails - rubocop-rspec - rubocop-rspec_rails diff --git a/.standard.yml b/.standard.yml index 883f2f410f..e8ecafc68e 100644 --- a/.standard.yml +++ b/.standard.yml @@ -1,6 +1,9 @@ extend_config: - .rubocop.yml +plugins: + - standard-rails + ignore: - 'storage/**/*' - 'db/migrate/2020*.rb' diff --git a/.standard_todo.yml b/.standard_todo.yml index eeeedb56bb..3e9f860bbd 100644 --- a/.standard_todo.yml +++ b/.standard_todo.yml @@ -2,23 +2,15 @@ # Remove from this list as you refactor files. --- ignore: -- app/callbacks/case_contact_metadata_callback.rb: - - Rails/SkipsModelValidations -- app/components/modal/body_component.rb: - - Rails/OutputSafety - app/controllers/all_casa_admins/sessions_controller.rb: - Rails/LexicallyScopedActionFilter - app/controllers/api/v1/base_controller.rb: - Rails/LexicallyScopedActionFilter - app/controllers/casa_cases_controller.rb: - Rails/TimeZone - - Rails/DynamicFindBy -- app/controllers/case_assignments_controller.rb: - - Rails/SkipsModelValidations - app/controllers/case_contacts_controller.rb: - Rails/LexicallyScopedActionFilter - app/controllers/checklist_items_controller.rb: - - Rails/SkipsModelValidations - Rails/TimeZone - app/controllers/court_dates_controller.rb: - Rails/TimeZone @@ -26,27 +18,18 @@ ignore: - Rails/LexicallyScopedActionFilter - app/controllers/reimbursements_controller.rb: - Rails/TimeZone - - Rails/SkipsModelValidations - app/controllers/users/sessions_controller.rb: - Rails/LexicallyScopedActionFilter +- app/datatables/volunteer_datatable.rb: + - Rails/CompactBlank - app/decorators/casa_case_decorator.rb: - Rails/Date - app/decorators/case_assignment_decorator.rb: - Rails/Date -- app/helpers/all_casa_admins/casa_orgs_helper.rb: - - Rails/HelperInstanceVariable - app/helpers/banner_helper.rb: - - Rails/HelperInstanceVariable - Rails/TimeZone -- app/helpers/contact_types_helper.rb: - - Rails/HelperInstanceVariable - app/helpers/phone_number_helper.rb: - Rails/Blank -- app/helpers/sidebar_helper.rb: - - Rails/OutputSafety -- app/helpers/ui_helper.rb: - - Rails/HelperInstanceVariable - - Rails/OutputSafety - app/mailers/fund_request_mailer.rb: - Rails/Date - app/mailers/learning_hours_mailer.rb: @@ -54,21 +37,19 @@ ignore: - app/mailers/supervisor_mailer.rb: - Rails/Date - app/models/casa_case.rb: - - Rails/HasManyOrHasOneDependent - - Rails/InverseOf + - Rails/IgnoredColumnsAssignment - Rails/Date + - Rails/PluckInWhere - app/models/casa_case_contact_type.rb: - Rails/UniqueValidationWithoutIndex - app/models/casa_case_emancipation_category.rb: - Rails/UniqueValidationWithoutIndex - app/models/casa_org.rb: - Rails/UniqueValidationWithoutIndex - - Rails/HasManyOrHasOneDependent - app/models/case_assignment.rb: - Rails/UniqueValidationWithoutIndex + - Rails/RedundantPresenceValidationOnBelongsTo - app/models/case_contact.rb: - - Rails/HasManyOrHasOneDependent - - Rails/InverseOf - Rails/FindEach - app/models/case_contact_contact_type.rb: - Rails/UniqueValidationWithoutIndex @@ -76,25 +57,15 @@ ignore: - Rails/UniqueValidationWithoutIndex - app/models/concerns/CasaCase/validations.rb: - Rails/TimeZone -- app/models/contact_topic.rb: - - Rails/HasManyOrHasOneDependent - app/models/contact_type.rb: - - Rails/HasManyOrHasOneDependent - Rails/UniqueValidationWithoutIndex - app/models/contact_type_group.rb: - - Rails/HasManyOrHasOneDependent - Rails/UniqueValidationWithoutIndex -- app/models/court_date.rb: - - Rails/HasManyOrHasOneDependent -- app/models/emancipation_category.rb: - - Rails/HasManyOrHasOneDependent - app/models/hearing_type.rb: - - Rails/HasManyOrHasOneDependent - Rails/UniqueValidationWithoutIndex - app/models/judge.rb: - Rails/UniqueValidationWithoutIndex - app/models/language.rb: - - Rails/HasManyOrHasOneDependent - Rails/UniqueValidationWithoutIndex - app/models/learning_hour.rb: - Rails/Date @@ -102,48 +73,35 @@ ignore: - Rails/UniqueValidationWithoutIndex - app/models/learning_hour_type.rb: - Rails/UniqueValidationWithoutIndex -- app/models/sms_notification_event.rb: - - Rails/HasManyOrHasOneDependent -- app/models/supervisor.rb: - - Rails/HasManyOrHasOneDependent - - Rails/InverseOf - - Rails/SkipsModelValidations +- app/models/mileage_rate.rb: + - Rails/IgnoredColumnsAssignment - app/models/supervisor_volunteer.rb: - Rails/UniqueValidationWithoutIndex - app/models/user.rb: - - Rails/InverseOf - - Rails/HasManyOrHasOneDependent - Rails/Date - app/models/volunteer.rb: - - Rails/SkipsModelValidations -- app/services/backfill_followupable_service.rb: - - Rails/SkipsModelValidations + - Rails/WhereEquals +- app/services/casa_case_change_service.rb: + - Rails/Pluck - app/services/fdf_inputs_service.rb: - Rails/Blank + - Rails/RootPathnameMethods - app/validators/user_validator.rb: - Rails/Blank - config/application.rb: - Style/RedundantInterpolation -- db/migrate/20240415160842_add_followupable_to_followups.rb: - - Rails/BulkChangeTable - db/seeds/db_populator.rb: - Rails/TimeZone - Rails/FindEach - Rails/Date - - Rails/SkipsModelValidations -- db/seeds/emancipation_options_prune.rb: - - Rails/SkipsModelValidations - lib/mailers/debug_preview_mailer.rb: - Rails/ApplicationMailer - lib/mailers/previews/devise_mailer_preview.rb: - - Rails/SkipsModelValidations - Rails/Date - lib/mailers/previews/fund_request_mailer_preview.rb: - Rails/Date - lib/mailers/previews/volunteer_mailer_preview.rb: - Rails/Date -- lib/tasks/auto_annotate_models.rake: - - Rails/RakeEnvironment - lib/tasks/case_contact_types_reminder.rb: - Rails/ActiveRecordAliases - lib/tasks/data_post_processors/contact_topic_populator.rb: @@ -153,7 +111,6 @@ ignore: - lib/tasks/deployment/20240604121427_migrate_notifications.rake: - Rails/ApplicationRecord - lib/tasks/deployment/99991023145114_store_deploy_time.rake: - - Rails/SkipsModelValidations - Rails/TimeZone - lib/tasks/no_contact_made_reminder.rb: - Rails/ActiveRecordAliases @@ -255,6 +212,7 @@ ignore: - RSpec/MultipleMemoizedHelpers - RSpec/NestedGroups - RSpec/NamedSubject + - Rails/Pluck - spec/datatables/volunteer_datatable_spec.rb: - RSpec/MultipleMemoizedHelpers - RSpec/SubjectDeclaration @@ -264,9 +222,9 @@ ignore: - RSpec/ExpectInLet - RSpec/NoExpectationExample - RSpec/IndexedLet + - Rails/Pluck - RSpec/NamedSubject - RSpec/MultipleExpectations - - Rails/SkipsModelValidations - spec/decorators/android_app_association_decorator_spec.rb: - RSpec/EmptyExampleGroup - spec/decorators/casa_case_decorator_spec.rb: @@ -278,7 +236,6 @@ ignore: - RSpec/MessageSpies - RSpec/VerifiedDoubles - spec/decorators/case_contact_decorator_spec.rb: - - Rails/SkipsModelValidations - RSpec/NestedGroups - spec/decorators/case_contacts/form_decorator_spec.rb: - RSpec/EmptyExampleGroup @@ -288,20 +245,15 @@ ignore: - RSpec/MultipleMemoizedHelpers - RSpec/IndexedLet - RSpec/NamedSubject -- spec/decorators/other_duty_decorator_spec.rb: - - Rails/SkipsModelValidations - spec/decorators/patch_note_decorator_spec.rb: - RSpec/EmptyExampleGroup - spec/decorators/placement_decorator_spec.rb: - RSpec/SpecFilePathFormat - - Rails/SkipsModelValidations - spec/decorators/user_decorator_spec.rb: - RSpec/RepeatedDescription - Rails/TimeZone - spec/decorators/volunteer_decorator_spec.rb: - RSpec/MultipleExpectations -- spec/factories/case_contacts.rb: - - Rails/SkipsModelValidations - spec/factories/healths.rb: - Rails/TimeZone - spec/factories/login_activities.rb: @@ -316,7 +268,6 @@ ignore: - RSpec/ExampleLength - RSpec/VerifiedDoubles - RSpec/BeEq - - Rails/SkipsModelValidations - spec/helpers/case_contacts_helper_spec.rb: - RSpec/InstanceVariable - RSpec/BeEq @@ -335,7 +286,6 @@ ignore: - spec/helpers/notifications_helper_spec.rb: - RSpec/ContextWording - Rails/TimeZone - - Rails/SkipsModelValidations - RSpec/MultipleMemoizedHelpers - RSpec/MultipleExpectations - RSpec/ExampleLength @@ -377,7 +327,6 @@ ignore: - RSpec/ContextWording - RSpec/MultipleExpectations - RSpec/DescribedClass - - Rails/SkipsModelValidations - RSpec/ExampleLength - spec/lib/tasks/data_post_processors/case_contact_populator_spec.rb: - RSpec/MultipleExpectations @@ -440,7 +389,6 @@ ignore: - RSpec/ExampleLength - RSpec/NamedSubject - spec/models/banner_spec.rb: - - Rails/SkipsModelValidations - RSpec/MultipleExpectations - RSpec/ExampleLength - spec/models/casa_admin_spec.rb: @@ -472,6 +420,7 @@ ignore: - RSpec/MessageChain - RSpec/ContextWording - Style/RedundantInterpolation + - Rails/Pluck - Rails/Date - RSpec/LetSetup - RSpec/MultipleExpectations @@ -520,7 +469,6 @@ ignore: - RSpec/MultipleMemoizedHelpers - RSpec/DescribedClass - RSpec/NamedSubject - - Rails/SkipsModelValidations - RSpec/RepeatedDescription - spec/models/case_group_spec.rb: - RSpec/ExampleLength @@ -531,6 +479,7 @@ ignore: - RSpec/DescribedClass - RSpec/NestedGroups - RSpec/ContextWording + - Rails/Pluck - spec/models/contact_type_group_spec.rb: - RSpec/IndexedLet - RSpec/MultipleExpectations @@ -642,7 +591,6 @@ ignore: - RSpec/MessageSpies - RSpec/BeEq - RSpec/ExampleLength - - Rails/SkipsModelValidations - RSpec/NestedGroups - RSpec/DescribedClass - RSpec/ContextWording @@ -717,7 +665,6 @@ ignore: - spec/policies/hearing_type_policy_spec.rb: - RSpec/NamedSubject - RSpec/ExampleLength - - Rails/SkipsModelValidations - spec/policies/import_policy_spec.rb: - RSpec/NamedSubject - spec/policies/judge_policy_spec.rb: @@ -771,6 +718,7 @@ ignore: - spec/requests/all_casa_admins/casa_orgs_spec.rb: - RSpec/MessageSpies - RSpec/MultipleExpectations + - Rails/Pluck - spec/requests/all_casa_admins/patch_notes_spec.rb: - RSpec/MultipleExpectations - RSpec/MultipleMemoizedHelpers @@ -793,7 +741,6 @@ ignore: - RSpec/ExampleLength - RSpec/MultipleExpectations - RSpec/LetSetup - - Rails/SkipsModelValidations - RSpec/MultipleMemoizedHelpers - RSpec/NestedGroups - spec/requests/bulk_court_dates_spec.rb: @@ -958,7 +905,6 @@ ignore: - RSpec/NestedGroups - spec/requests/notifications_spec.rb: - RSpec/NestedGroups - - Rails/SkipsModelValidations - Rails/Date - RSpec/MultipleMemoizedHelpers - RSpec/IndexedLet @@ -1369,7 +1315,6 @@ ignore: - RSpec/NestedGroups - RSpec/ExampleLength - RSpec/IndexedLet - - Rails/OutputSafety - RSpec/VoidExpect - spec/system/supervisors/new_spec.rb: - RSpec/ExampleLength @@ -1495,7 +1440,6 @@ ignore: - spec/views/notifications/index.html.erb_spec.rb: - RSpec/MultipleMemoizedHelpers - RSpec/IndexedLet - - Rails/SkipsModelValidations - RSpec/ExampleLength - RSpec/MultipleExpectations - RSpec/BeEql @@ -1526,6 +1470,7 @@ ignore: - RSpec/EmptyExampleGroup - RSpec/ContextWording - spec/views/templates/email_templates_spec.rb: + - Rails/RootPathnameMethods - RSpec/MultipleDescribes - spec/views/volunteers/edit.html.erb_spec.rb: - RSpec/ExampleLength diff --git a/app/controllers/api/v1/base_controller.rb b/app/controllers/api/v1/base_controller.rb index b6741f3d6f..bba3dcd72d 100644 --- a/app/controllers/api/v1/base_controller.rb +++ b/app/controllers/api/v1/base_controller.rb @@ -8,7 +8,7 @@ def authenticate_user! if user && token && ActiveSupport::SecurityUtils.secure_compare(user.token, token) @current_user = user else - render json: {message: "Wrong password or email"}, status: :unauthorized + render json: {message: "Wrong password or email"}, status: 401 end end diff --git a/app/controllers/api/v1/users/sessions_controller.rb b/app/controllers/api/v1/users/sessions_controller.rb index e8a0e2f763..98635860bf 100644 --- a/app/controllers/api/v1/users/sessions_controller.rb +++ b/app/controllers/api/v1/users/sessions_controller.rb @@ -2,9 +2,9 @@ class Api::V1::Users::SessionsController < Api::V1::BaseController def create load_resource if @user - render json: Api::V1::SessionBlueprint.render(@user), status: :created + render json: Api::V1::SessionBlueprint.render(@user), status: 201 else - render json: {message: "Wrong password or email"}, status: :unauthorized + render json: {message: "Wrong password or email"}, status: 401 end end diff --git a/app/controllers/casa_admins_controller.rb b/app/controllers/casa_admins_controller.rb index 3ef6374759..39fa8acf89 100644 --- a/app/controllers/casa_admins_controller.rb +++ b/app/controllers/casa_admins_controller.rb @@ -45,7 +45,7 @@ def create begin casa_admin = service.create! - if casa_admin.phone_number.present? + if !casa_admin.phone_number.blank? raw_token = casa_admin.raw_invitation_token base_domain = request.base_url + "/users/edit" invitation_url = Rails.application.routes.url_helpers.accept_user_invitation_url(invitation_token: raw_token, host: request.base_url) diff --git a/app/controllers/users/passwords_controller.rb b/app/controllers/users/passwords_controller.rb index c5bda12092..69fd45c5ba 100644 --- a/app/controllers/users/passwords_controller.rb +++ b/app/controllers/users/passwords_controller.rb @@ -61,11 +61,11 @@ def valid_params?(email, phone_number) end def email? - @email.present? + !@email.blank? end def phone_number? - @phone_number.present? + !@phone_number.blank? end def empty_fields_error diff --git a/app/lib/importers/file_importer.rb b/app/lib/importers/file_importer.rb index a94dcff602..8bbe707057 100644 --- a/app/lib/importers/file_importer.rb +++ b/app/lib/importers/file_importer.rb @@ -73,7 +73,7 @@ def export_failed_imports end def failed? - failed_imports.present? + !failed_imports.blank? end def message diff --git a/app/models/all_casa_admin.rb b/app/models/all_casa_admin.rb index 0be6e7f9fb..8d65effc2a 100644 --- a/app/models/all_casa_admin.rb +++ b/app/models/all_casa_admin.rb @@ -4,7 +4,7 @@ class AllCasaAdmin < ApplicationRecord # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable - devise :database_authenticatable, :invitable, :recoverable, :validatable, :timeoutable, invite_for: 1.week + devise :database_authenticatable, :invitable, :recoverable, :validatable, :timeoutable, invite_for: 1.weeks def casa_admin? false diff --git a/app/models/casa_org.rb b/app/models/casa_org.rb index a9eeb0d092..5c98594cda 100644 --- a/app/models/casa_org.rb +++ b/app/models/casa_org.rb @@ -2,13 +2,13 @@ class CasaOrg < ApplicationRecord prepend ActiveSupport::ToJsonWithActiveSupportEncoder # NOTE: location of the default report template CASA_DEFAULT_COURT_REPORT = File.new(Rails.root.join("app/documents/templates/default_report_template.docx"), "r") - CASA_DEFAULT_LOGO = Rails.root.join("public/logo.jpeg") + CASA_DEFAULT_LOGO = Rails.public_path.join("logo.jpeg") scope :with_logo, -> { joins(:logo_attachment) } + before_save :normalize_phone_number before_create :set_slug before_update :sanitize_svg - before_save :normalize_phone_number validates :name, presence: true, uniqueness: true validates_with CasaOrgValidator @@ -57,7 +57,9 @@ def followups Followup.in_organization(self) end - delegate :count, to: :case_contacts, prefix: true + def case_contacts_count + case_contacts.count + end def org_logo if logo.attached? diff --git a/app/models/case_contact.rb b/app/models/case_contact.rb index 17585ab95a..fd270be55d 100644 --- a/app/models/case_contact.rb +++ b/app/models/case_contact.rb @@ -233,7 +233,9 @@ def volunteer_address_is_valid end end - delegate :id, to: :supervisor, prefix: true + def supervisor_id + supervisor.id + end def has_casa_case_transitioned casa_case.in_transition_age? @@ -256,7 +258,7 @@ def should_send_reimbursement_email? end def supervisor_active? - supervisor.present? && supervisor.active? + !supervisor.blank? && supervisor.active? end def address_field_disabled? @@ -277,8 +279,8 @@ def self.options_for_sorted_by def self.case_hash_from_cases(cases) casa_case_ids = cases.map(&:draft_case_ids).flatten.uniq.sort - casa_case_ids.index_with do |casa_case_id| - cases.select { |c| c.casa_case_id == casa_case_id || c.draft_case_ids.include?(casa_case_id) } + casa_case_ids.each_with_object({}) do |casa_case_id, hash| + hash[casa_case_id] = cases.select { |c| c.casa_case_id == casa_case_id || c.draft_case_ids.include?(casa_case_id) } end end diff --git a/app/models/user.rb b/app/models/user.rb index 9bf8e5a908..17df640aba 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -6,9 +6,10 @@ class User < ApplicationRecord include ByOrganizationScope include DateHelper - before_update :record_previous_email - after_create :skip_email_confirmation_upon_creation before_save :normalize_phone_number + after_create :skip_email_confirmation_upon_creation + after_create :create_preference_set + before_update :record_previous_email has_secure_token :token, length: 36 validates_with UserValidator @@ -47,8 +48,6 @@ class User < ApplicationRecord accepts_nested_attributes_for :user_sms_notification_events, :address, allow_destroy: true - after_create :create_preference_set - scope :active, -> { where(active: true) } scope :inactive, -> { where(active: false) } @@ -122,7 +121,7 @@ def no_attempt_for_two_weeks if volunteer.supervisor.active? && volunteer.case_assignments.any? { |assignment| assignment.active? } && (volunteer.case_contacts.none? || - volunteer.case_contacts.maximum(:created_at) < (Time.zone.now - 14.days)) + volunteer.case_contacts.maximum(:created_at) < (14.days.ago)) no_attempt_count += 1 end diff --git a/app/notifications/base_notifier.rb b/app/notifications/base_notifier.rb index b22dd908d4..c08e0481d7 100644 --- a/app/notifications/base_notifier.rb +++ b/app/notifications/base_notifier.rb @@ -13,11 +13,17 @@ def url end # Utility methods - delegate :read?, to: :record + def read? + record.read? + end - delegate :created_at, to: :record + def created_at + record.created_at + end - delegate :updated_at, to: :record + def updated_at + record.updated_at + end def created_by created_by_name diff --git a/db/seeds/db_populator.rb b/db/seeds/db_populator.rb index 3a57efb2dd..a5080cd4a7 100644 --- a/db/seeds/db_populator.rb +++ b/db/seeds/db_populator.rb @@ -140,7 +140,7 @@ def create_cases(casa_org, options) court_report_submitted = index.even? new_casa_case = CasaCase.find_by(case_number: case_number) - birth_month_year_youth = @case_fourteen_years_old ? ((Date.today - 18.years)..(Date.today - CasaCase::TRANSITION_AGE.year)).to_a.sample : ((Date.today - 18.years)..(Date.today - 1.year)).to_a.sample + birth_month_year_youth = @case_fourteen_years_old ? ((Date.today - 18.year)..(Date.today - CasaCase::TRANSITION_AGE.year)).to_a.sample : ((Date.today - 18.year)..(Date.today - 1.year)).to_a.sample new_casa_case ||= CasaCase.find_or_create_by!( casa_org_id: casa_org.id, case_number: case_number, @@ -209,7 +209,7 @@ def create_cases(casa_org, options) volunteer1 = Volunteer.find_by(email: "volunteer1@example.com") if volunteer1.casa_cases.where(birth_month_year_youth: ..CasaCase::TRANSITION_AGE.years.ago).blank? rand(1..3).times do - birth_month_year_youth = ((Date.today - 18.years)..(Date.today - CasaCase::TRANSITION_AGE.year)).to_a.sample + birth_month_year_youth = ((Date.today - 18.year)..(Date.today - CasaCase::TRANSITION_AGE.year)).to_a.sample new_casa_case = volunteer1.casa_cases.find_or_create_by!( casa_org_id: volunteer1.casa_org.id, case_number: generate_case_number, diff --git a/lib/tasks/no_contact_made_reminder.rb b/lib/tasks/no_contact_made_reminder.rb index abe65307b6..eab4ef0dea 100644 --- a/lib/tasks/no_contact_made_reminder.rb +++ b/lib/tasks/no_contact_made_reminder.rb @@ -44,7 +44,7 @@ def valid_past_reminders(volunteer) return false end - if reminder&.no_contact_made && reminder.no_contact_made >= 1.month.ago + if reminder&.no_contact_made && reminder.no_contact_made >= 1.months.ago return false end diff --git a/lib/tasks/send_case_contact_types_reminder.rake b/lib/tasks/send_case_contact_types_reminder.rake index 0d8287bdd8..a8640498a2 100644 --- a/lib/tasks/send_case_contact_types_reminder.rake +++ b/lib/tasks/send_case_contact_types_reminder.rake @@ -1,7 +1,7 @@ desc "Send an SMS to volunteers reminding them to connect with the contact types they have not connected with in the past 60 or more days" require_relative "case_contact_types_reminder" task send_case_contact_types_reminder: :environment do - every 1.week do + every 1.weeks do CaseContactTypesReminder.new.send! end end diff --git a/lib/tasks/send_no_contact_made_reminder.rake b/lib/tasks/send_no_contact_made_reminder.rake index 982a65a286..ff1e6ac68d 100644 --- a/lib/tasks/send_no_contact_made_reminder.rake +++ b/lib/tasks/send_no_contact_made_reminder.rake @@ -1,7 +1,7 @@ desc "Send an SMS to volunteers reminding them to make contact if two weeks have passed since they logged a case contact but contact was not made" require_relative "case_contact_types_reminder" task send_case_contact_types_reminder: :environment do - every 1.day do + every 1.days do CaseContactTypesReminder.new.send! end end diff --git a/spec/callbacks/case_contact_metadata_callback_spec.rb b/spec/callbacks/case_contact_metadata_callback_spec.rb index 0b116b2e93..78a6f4e158 100644 --- a/spec/callbacks/case_contact_metadata_callback_spec.rb +++ b/spec/callbacks/case_contact_metadata_callback_spec.rb @@ -8,7 +8,6 @@ let(:parsed_present) { present.as_json } before { travel_to present } - after { travel_back } # NOTE: as you might notice these tests are omitting quite a few cases # ex: notes => details, expenses => notes. I don't think it is worth dealing diff --git a/spec/config/initializers/rack_attack_spec.rb b/spec/config/initializers/rack_attack_spec.rb index 84cfa25c9d..e5f01e104b 100644 --- a/spec/config/initializers/rack_attack_spec.rb +++ b/spec/config/initializers/rack_attack_spec.rb @@ -20,7 +20,6 @@ end after do - travel_back ActionController::Base.perform_caching = false end diff --git a/spec/helpers/notifications_helper_spec.rb b/spec/helpers/notifications_helper_spec.rb index 14ce45b0bb..2a54d8e7a2 100644 --- a/spec/helpers/notifications_helper_spec.rb +++ b/spec/helpers/notifications_helper_spec.rb @@ -21,8 +21,6 @@ notification_created_before_deploy_b.update_attribute(:created_at, 3.days.ago) end - after { travel_back } - describe "#notifications_after_and_including_deploy" do let(:notifications_after_and_including_deploy) { helper.notifications_after_and_including_deploy(Noticed::Notification.all) } diff --git a/spec/lib/importers/case_importer_spec.rb b/spec/lib/importers/case_importer_spec.rb index 883f965eff..0164ebd638 100644 --- a/spec/lib/importers/case_importer_spec.rb +++ b/spec/lib/importers/case_importer_spec.rb @@ -16,10 +16,6 @@ travel_to Date.parse("Sept 15 2022") end - after do - travel_back - end - describe "#import_cases" do it "imports cases and associates volunteers with them" do expect { case_importer.import_cases }.to change(CasaCase, :count).by(3) diff --git a/spec/lib/tasks/case_contact_types_reminder_spec.rb b/spec/lib/tasks/case_contact_types_reminder_spec.rb index 3b97795ad2..056dd37a54 100644 --- a/spec/lib/tasks/case_contact_types_reminder_spec.rb +++ b/spec/lib/tasks/case_contact_types_reminder_spec.rb @@ -49,7 +49,7 @@ context "volunteer with contacted contact types within last 60 days, sms notifications on, and no reminder in last quarter" do it "does not send sms reminder" do - CaseContact.update_all(occurred_at: 1.month.ago) + CaseContact.update_all(occurred_at: 1.months.ago) responses = CaseContactTypesReminder.new.send! expect(responses.count).to match 0 end diff --git a/spec/lib/tasks/no_contact_made_reminder_spec.rb b/spec/lib/tasks/no_contact_made_reminder_spec.rb index def0164117..7024b11eb4 100644 --- a/spec/lib/tasks/no_contact_made_reminder_spec.rb +++ b/spec/lib/tasks/no_contact_made_reminder_spec.rb @@ -101,7 +101,7 @@ end context "volunteer with no contact made reminder sent within last 30 days" do - let(:no_contact_made_reminder) { create(:user_reminder_time, no_contact_made: 1.week.ago) } + let(:no_contact_made_reminder) { create(:user_reminder_time, no_contact_made: 1.weeks.ago) } it "sends not sms reminder" do CaseContact.destroy_all diff --git a/spec/lib/tasks/supervisor_weekly_digest_spec.rb b/spec/lib/tasks/supervisor_weekly_digest_spec.rb index 0ab82c967e..f23e530dda 100644 --- a/spec/lib/tasks/supervisor_weekly_digest_spec.rb +++ b/spec/lib/tasks/supervisor_weekly_digest_spec.rb @@ -13,8 +13,6 @@ create(:supervisor, active: false) end - after { travel_back } - it "only sends to active supervisor" do expect { subject }.to change { ActionMailer::Base.deliveries.count }.by(1) expect(ActionMailer::Base.deliveries.last.subject).to eq("Weekly summary of volunteers' activities for the week of 2021-09-20") @@ -28,8 +26,6 @@ create(:supervisor, active: true) end - after { travel_back } - it "does not send email" do expect { subject }.not_to change { ActionMailer::Base.deliveries.count } end diff --git a/spec/mailers/supervisor_mailer_spec.rb b/spec/mailers/supervisor_mailer_spec.rb index 4b4f2eb430..19bf58d520 100644 --- a/spec/mailers/supervisor_mailer_spec.rb +++ b/spec/mailers/supervisor_mailer_spec.rb @@ -21,7 +21,7 @@ end it "shows the latest case contact that occurred in the week" do - most_recent_contact = create(:case_contact, casa_case: casa_case, occurred_at: Date.today - 1.day, notes: "AAAAAAAAAAAAAAAAAAAAAAAA") + most_recent_contact = create(:case_contact, casa_case: casa_case, occurred_at: Date.today - 1.days, notes: "AAAAAAAAAAAAAAAAAAAAAAAA") other_contact = build(:case_contact, casa_case: casa_case, occurred_at: Date.today - 3.days, notes: "BBBBBBBBBBBBBBBBBBBB") expect(mail.body.encoded).to match("Notes: #{most_recent_contact.notes}") @@ -45,13 +45,13 @@ end it "does not show a case contact that occurred past the unassignment date in the week" do - contact_past_unassignment = build_stubbed(:case_contact, casa_case: casa_case, occurred_at: Date.today - 1.day, notes: "AAAAAAAAAAAAAAAAAAAAAAAA") + contact_past_unassignment = build_stubbed(:case_contact, casa_case: casa_case, occurred_at: Date.today - 1.days, notes: "AAAAAAAAAAAAAAAAAAAAAAAA") expect(mail.body.encoded).not_to match("Notes: #{contact_past_unassignment.notes}") end it "shows the latest case contact that occurred in the week before the unassignment date" do - contact_past_unassignment = create(:case_contact, casa_case: casa_case, occurred_at: Date.today - 1.day, notes: "AAAAAAAAAAAAAAAAAAAAAAAA") + contact_past_unassignment = create(:case_contact, casa_case: casa_case, occurred_at: Date.today - 1.days, notes: "AAAAAAAAAAAAAAAAAAAAAAAA") most_recent_contact_before_unassignment = create(:case_contact, casa_case: casa_case, occurred_at: Date.today - 3.days, notes: "BBBBBBBBBBBBBBBBBB") older_contact = build_stubbed(:case_contact, casa_case: casa_case, occurred_at: Date.today - 4.days, notes: "CCCCCCCCCCCCCCCCCCCC") diff --git a/spec/models/casa_case_spec.rb b/spec/models/casa_case_spec.rb index 8afa14e9c1..de129bfaca 100644 --- a/spec/models/casa_case_spec.rb +++ b/spec/models/casa_case_spec.rb @@ -84,14 +84,14 @@ subject { described_class.due_date_passed } context "when casa_case is present" do - let!(:court_date) { create(:court_date, date: Time.current - 3.days) } + let!(:court_date) { create(:court_date, date: 3.days.ago) } let(:casa_case) { court_date.casa_case } it { is_expected.to include(casa_case) } end context "when casa_case is not present" do - let!(:court_date) { create(:court_date, date: Time.current + 3.days) } + let!(:court_date) { create(:court_date, date: 3.days.from_now) } let(:casa_case) { court_date.casa_case } it { is_expected.not_to include(casa_case) } @@ -301,10 +301,6 @@ travel_to submitted_time end - after do - travel_back - end - context "when the case is already submitted" do let(:casa_case) { build(:casa_case, court_report_status: :submitted, court_report_submitted_at: submitted_time) } @@ -312,8 +308,6 @@ travel_to the_future end - after { travel_back } - context "when the status is completed" do let(:court_report_status) { :completed } @@ -373,8 +367,6 @@ travel_to Date.new(2021, 1, 1) end - after { travel_back } - context "with a past court date" do it "returns the latest past court date as a formatted string" do most_recent_past_court_date = create(:court_date, date: 3.months.ago) diff --git a/spec/models/casa_org_spec.rb b/spec/models/casa_org_spec.rb index 1d5de1428d..2ff6357ab8 100644 --- a/spec/models/casa_org_spec.rb +++ b/spec/models/casa_org_spec.rb @@ -78,7 +78,7 @@ aggregate_failures do subject = build(:casa_org, twilio_enabled: false) - expect(subject.org_logo).to eq(Pathname.new("#{Rails.root.join("public/logo.jpeg")}")) + expect(subject.org_logo).to eq(Pathname.new("#{Rails.public_path.join("logo.jpeg")}")) subject.logo.attach( io: File.open(file_fixture("company_logo.png")), diff --git a/spec/models/case_contact_report_spec.rb b/spec/models/case_contact_report_spec.rb index cefc216fd9..6b501fde62 100644 --- a/spec/models/case_contact_report_spec.rb +++ b/spec/models/case_contact_report_spec.rb @@ -70,8 +70,8 @@ it "returns only headers if result is empty" do report = CaseContactReport.new( { - "start_date" => 1.day.ago, - "end_date" => 1.day.ago, + "start_date" => 1.days.ago, + "end_date" => 1.days.ago, "contact_made" => true, "has_transitioned" => true, "want_driving_reimbursement" => true, diff --git a/spec/models/case_contact_spec.rb b/spec/models/case_contact_spec.rb index 77874fc04a..2f9e6118bc 100644 --- a/spec/models/case_contact_spec.rb +++ b/spec/models/case_contact_spec.rb @@ -76,12 +76,12 @@ it "can be updated even if it is old" do case_contact = build_stubbed(:case_contact) - case_contact.occurred_at = Time.zone.now - 1.year + case_contact.occurred_at = 1.year.ago expect(case_contact).to be_valid end it "can be updated for 30 days after end of quarter" do - expect(build_stubbed(:case_contact, occurred_at: Time.zone.now - 4.months + 1.day)).to be_valid + expect(build_stubbed(:case_contact, occurred_at: 4.months.ago + 1.day)).to be_valid end end diff --git a/spec/models/case_court_report_context_spec.rb b/spec/models/case_court_report_context_spec.rb index cdd4c6adab..ee90369bc7 100644 --- a/spec/models/case_court_report_context_spec.rb +++ b/spec/models/case_court_report_context_spec.rb @@ -14,8 +14,6 @@ travel_to Date.new(2021, 1, 1) end - after { travel_back } - describe "#context" do it "has the right shape" do date = 1.day.ago @@ -96,7 +94,7 @@ describe "#latest_hearing_date" do context "when casa_case has court_dates" do - let(:court_date) { build(:court_date, date: 2.days.ago) } + let(:court_date) { build(:court_date, date: 2.day.ago) } let(:casa_case) { create(:casa_case, court_dates: [court_date]) } let(:instance) { build(:case_court_report_context, casa_case: casa_case) } @@ -135,22 +133,22 @@ describe "#calculate_date_range" do context "when @time_zone is set" do it "converts to provided timezone" do - context = build_context(start_date: 10.days.ago, end_date: 2.days.ago, court_date: nil, time_zone: A_TIMEZONE) + context = build_context(start_date: 10.day.ago, end_date: 2.day.ago, court_date: nil, time_zone: A_TIMEZONE) expect(context.date_range).to eq(zone_days_ago(10)..zone_days_ago(2)) end it "uses current time if end_date not provided" do - context = build_context(start_date: 10.days.ago, end_date: nil, court_date: nil, time_zone: A_TIMEZONE) + context = build_context(start_date: 10.day.ago, end_date: nil, court_date: nil, time_zone: A_TIMEZONE) expect(context.date_range).to eq(zone_days_ago(10)..nil) end it "uses court date if available if no start_date" do - context = build_context(start_date: nil, end_date: 2.days.ago, court_date: 6.days.ago, time_zone: A_TIMEZONE) + context = build_context(start_date: nil, end_date: 2.day.ago, court_date: 6.day.ago, time_zone: A_TIMEZONE) expect(context.date_range).to eq(zone_days_ago(6)..zone_days_ago(2)) end it "uses nil(includes everything) if no court date or start_date" do - context = build_context(start_date: nil, end_date: 2.days.ago, court_date: nil, time_zone: A_TIMEZONE) + context = build_context(start_date: nil, end_date: 2.day.ago, court_date: nil, time_zone: A_TIMEZONE) expect(context.date_range).to eq(nil..zone_days_ago(2)) end @@ -158,22 +156,22 @@ context "when @time_zone is not set" do it "uses server time zone" do - context = build_context(start_date: 10.days.ago, end_date: 2.days.ago, court_date: nil, time_zone: nil) + context = build_context(start_date: 10.day.ago, end_date: 2.day.ago, court_date: nil, time_zone: nil) expect(context.date_range).to eq(days_ago(10)..days_ago(2)) end it "uses nil if end_date not provided" do - context = build_context(start_date: 10.days.ago, end_date: nil, court_date: nil, time_zone: nil) + context = build_context(start_date: 10.day.ago, end_date: nil, court_date: nil, time_zone: nil) expect(context.date_range).to eq(days_ago(10)..nil) end it "uses court date if available if no start_date" do - context = build_context(start_date: nil, end_date: 2.days.ago, court_date: 6.days.ago, time_zone: nil) + context = build_context(start_date: nil, end_date: 2.day.ago, court_date: 6.day.ago, time_zone: nil) expect(context.date_range).to eq(days_ago(6)..days_ago(2)) end it "uses nil if no court date or start_date" do - context = build_context(start_date: nil, end_date: 2.days.ago, court_date: nil, time_zone: nil) + context = build_context(start_date: nil, end_date: 2.day.ago, court_date: nil, time_zone: nil) expect(context.date_range).to eq(nil..days_ago(2)) end @@ -203,11 +201,11 @@ contact_one = create(:case_contact, casa_case: casa_case, medium_type: "in-person", occurred_at: 1.day.ago) create_list(:contact_topic_answer, 2, case_contact: contact_one, contact_topic: topics[0], value: "Not included") - contact_two = create(:case_contact, casa_case: casa_case, medium_type: "in-person", occurred_at: 50.days.ago) + contact_two = create(:case_contact, casa_case: casa_case, medium_type: "in-person", occurred_at: 50.day.ago) create_list(:contact_topic_answer, 2, case_contact: contact_two, contact_topic: topics[0], value: "Not included") other_case = create(:casa_case, casa_org: org) - contact_three = create(:case_contact, casa_case: other_case, medium_type: "in-person", occurred_at: 50.days.ago) + contact_three = create(:case_contact, casa_case: other_case, medium_type: "in-person", occurred_at: 50.day.ago) create_list(:contact_topic_answer, 2, case_contact: contact_three, contact_topic: topics[0], value: "Not included") end @@ -242,7 +240,7 @@ ]} } - court_report_context = build(:case_court_report_context, start_date: 45.days.ago.to_s, end_date: 5.days.ago.to_s, casa_case: casa_case) + court_report_context = build(:case_court_report_context, start_date: 45.day.ago.to_s, end_date: 5.day.ago.to_s, casa_case: casa_case) expect(court_report_context.court_topics).to eq(expected_topics) end @@ -250,7 +248,7 @@ context "when there are no contact topics" do it "returns an empty hash" do - court_report_context = build(:case_court_report_context, start_date: 45.days.ago.to_s, end_date: 5.days.ago.to_s, casa_case: casa_case) + court_report_context = build(:case_court_report_context, start_date: 45.day.ago.to_s, end_date: 5.day.ago.to_s, casa_case: casa_case) expect(court_report_context.court_topics).to eq({}) end end @@ -259,11 +257,11 @@ describe "#filtered_interviewees" do it "filters based on date range" do casa_case = create(:casa_case) - court_report_context = build(:case_court_report_context, start_date: 5.days.ago.to_s, end_date: 5.days.ago.to_s, casa_case: casa_case) + court_report_context = build(:case_court_report_context, start_date: 5.day.ago.to_s, end_date: 5.day.ago.to_s, casa_case: casa_case) - create_list(:case_contact, 3, occurred_at: 10.days.ago, casa_case: casa_case) + create_list(:case_contact, 3, occurred_at: 10.day.ago, casa_case: casa_case) create_list(:case_contact, 3, occurred_at: 1.day.ago, casa_case: casa_case) - included_interviewee = create(:case_contact, occurred_at: 5.days.ago, casa_case: casa_case) + included_interviewee = create(:case_contact, occurred_at: 5.day.ago, casa_case: casa_case) result = court_report_context.filtered_interviewees.map(&:case_contact) @@ -272,11 +270,11 @@ it "filters if start of date range is nil" do casa_case = create(:casa_case) - court_report_context = build(:case_court_report_context, start_date: nil, end_date: 5.days.ago.to_s, casa_case: casa_case) + court_report_context = build(:case_court_report_context, start_date: nil, end_date: 5.day.ago.to_s, casa_case: casa_case) create_list(:case_contact, 3, occurred_at: 1.day.ago, casa_case: casa_case) - interviewees = create_list(:case_contact, 3, occurred_at: 10.days.ago, casa_case: casa_case) - interviewees.append(create(:case_contact, occurred_at: 5.days.ago, casa_case: casa_case)) + interviewees = create_list(:case_contact, 3, occurred_at: 10.day.ago, casa_case: casa_case) + interviewees.append(create(:case_contact, occurred_at: 5.day.ago, casa_case: casa_case)) result = court_report_context.filtered_interviewees.map(&:case_contact) @@ -285,11 +283,11 @@ it "filters if end of date range is nil" do casa_case = create(:casa_case) - court_report_context = build(:case_court_report_context, start_date: 5.days.ago.to_s, end_date: nil, casa_case: casa_case) + court_report_context = build(:case_court_report_context, start_date: 5.day.ago.to_s, end_date: nil, casa_case: casa_case) - create_list(:case_contact, 3, occurred_at: 10.days.ago, casa_case: casa_case) + create_list(:case_contact, 3, occurred_at: 10.day.ago, casa_case: casa_case) interviewees = create_list(:case_contact, 3, occurred_at: 1.day.ago, casa_case: casa_case) - interviewees.append(create(:case_contact, occurred_at: 5.days.ago, casa_case: casa_case)) + interviewees.append(create(:case_contact, occurred_at: 5.day.ago, casa_case: casa_case)) result = court_report_context.filtered_interviewees.map(&:case_contact) @@ -300,9 +298,9 @@ casa_case = create(:casa_case) court_report_context = build(:case_court_report_context, start_date: nil, end_date: nil, casa_case: casa_case) - create_list(:case_contact, 3, occurred_at: 10.days.ago, casa_case: casa_case) + create_list(:case_contact, 3, occurred_at: 10.day.ago, casa_case: casa_case) create_list(:case_contact, 3, occurred_at: 1.day.ago, casa_case: casa_case) - create(:case_contact, occurred_at: 5.days.ago, casa_case: casa_case) + create(:case_contact, occurred_at: 5.day.ago, casa_case: casa_case) result = court_report_context.filtered_interviewees.map(&:case_contact) @@ -311,7 +309,7 @@ it "returns an empty array if there are no interviewees" do casa_case = create(:casa_case) - court_report_context = build(:case_court_report_context, start_date: 5.days.ago.to_s, end_date: nil, casa_case: casa_case) + court_report_context = build(:case_court_report_context, start_date: 5.day.ago.to_s, end_date: nil, casa_case: casa_case) result = court_report_context.filtered_interviewees.map(&:case_contact) diff --git a/spec/models/court_date_spec.rb b/spec/models/court_date_spec.rb index 427065be58..0bb4480901 100644 --- a/spec/models/court_date_spec.rb +++ b/spec/models/court_date_spec.rb @@ -11,8 +11,6 @@ let(:path_to_template) { Rails.root.join("app/documents/templates/default_report_template.docx").to_s } let(:path_to_report) { Rails.root.join("tmp/test_report.docx").to_s } - after { travel_back } - before do travel_to Date.new(2021, 1, 1) end @@ -61,7 +59,7 @@ it "orders the casa cases by updated at date" do very_old_pcd = create(:court_date, date: 10.days.ago) - old_pcd = create(:court_date, date: 5.days.ago) + old_pcd = create(:court_date, date: 5.day.ago) recent_pcd = create(:court_date, date: 1.day.ago) ordered_pcds = described_class.ordered_ascending diff --git a/spec/models/volunteer_spec.rb b/spec/models/volunteer_spec.rb index 3fddfcf96f..1ae44f20e5 100644 --- a/spec/models/volunteer_spec.rb +++ b/spec/models/volunteer_spec.rb @@ -320,10 +320,6 @@ travel_to Date.new(2022, 10, 1) end - after do - travel_back - end - context "there are volunteers whose birthdays are not next month" do let!(:volunteer1) { create(:volunteer, date_of_birth: Date.new(1990, 9, 1)) } let!(:volunteer2) { create(:volunteer, date_of_birth: Date.new(1998, 10, 15)) } @@ -405,7 +401,7 @@ [ create(:learning_hour, user: volunteer, duration_hours: 1, duration_minutes: 30, learning_hour_type: learning_hour_type), create(:learning_hour, user: volunteer, duration_hours: 3, duration_minutes: 45, learning_hour_type: learning_hour_type), - create(:learning_hour, user: volunteer, duration_hours: 1, duration_minutes: 30, occurred_at: 2.years.ago, learning_hour_type: learning_hour_type) + create(:learning_hour, user: volunteer, duration_hours: 1, duration_minutes: 30, occurred_at: 2.year.ago, learning_hour_type: learning_hour_type) ] end diff --git a/spec/requests/banners_spec.rb b/spec/requests/banners_spec.rb index 20b0db4609..7ed673bdb2 100644 --- a/spec/requests/banners_spec.rb +++ b/spec/requests/banners_spec.rb @@ -87,7 +87,6 @@ context "when client timezone is ahead of UTC" do before { travel_to Time.new(2024, 6, 1, 11, 0, 0, "+03:00") } # 08:00 UTC - after { travel_back } context "when submitted time is behind client but ahead of UTC" do let(:expires_at) { Time.new(2024, 6, 1, 9, 0, 0, "UTC") } # 12:00 +03:00 @@ -113,7 +112,6 @@ context "when client timezone is behind UTC" do before { travel_to Time.new(2024, 6, 1, 11, 0, 0, "-04:00") } # 15:00 UTC - after { travel_back } context "when submitted time is ahead of client and ahead of UTC" do let(:expires_at) { Time.new(2024, 6, 1, 16, 0, 0, "UTC") } # 12:00 -04:00 diff --git a/spec/requests/case_contact_reports_spec.rb b/spec/requests/case_contact_reports_spec.rb index cf7dbb3ae8..756801f582 100644 --- a/spec/requests/case_contact_reports_spec.rb +++ b/spec/requests/case_contact_reports_spec.rb @@ -8,8 +8,6 @@ sign_in user end - after { travel_back } - describe "GET /case_contact_reports" do context "as volunteer" do let(:user) { build(:volunteer) } diff --git a/spec/requests/case_court_reports_spec.rb b/spec/requests/case_court_reports_spec.rb index 635ecbf382..538f341952 100644 --- a/spec/requests/case_court_reports_spec.rb +++ b/spec/requests/case_court_reports_spec.rb @@ -177,8 +177,6 @@ travel_to server_time end - after { travel_back } - it "is different than server" do get request.parsed_body["link"] followed_link_response = response diff --git a/spec/requests/court_dates_spec.rb b/spec/requests/court_dates_spec.rb index 68beae01cd..eb3cd574c2 100644 --- a/spec/requests/court_dates_spec.rb +++ b/spec/requests/court_dates_spec.rb @@ -35,8 +35,6 @@ sign_in admin end - after { travel_back } - describe "GET /show" do subject(:show) { get casa_case_court_date_path(casa_case, court_date) } diff --git a/spec/requests/health_spec.rb b/spec/requests/health_spec.rb index 925c01b2fb..7c383780a7 100644 --- a/spec/requests/health_spec.rb +++ b/spec/requests/health_spec.rb @@ -59,10 +59,6 @@ def setup create(:contact_topic_answer, case_contact: CaseContact.last) end - after do - travel_back - end - it "returns case contacts creation times in the last year" do travel_to Time.zone.local(2024, 5, 2) setup @@ -119,10 +115,6 @@ def setup create(:login_activity, user: casa_admin, created_at: 9.months.ago, success: true) end - after do - travel_back - end - it "returns monthly unique users data for volunteers, supervisors, and admins in the last year" do travel_to Time.zone.local(2024, 5, 2) setup diff --git a/spec/requests/imports_spec.rb b/spec/requests/imports_spec.rb index c07d5e66ca..9932f675f5 100644 --- a/spec/requests/imports_spec.rb +++ b/spec/requests/imports_spec.rb @@ -14,10 +14,6 @@ travel_to Date.parse("Sept 15 2022") end - after do - travel_back - end - describe "GET /index" do it "renders an unsuccessful response when the user is not an admin" do sign_in create(:volunteer) diff --git a/spec/requests/notifications_spec.rb b/spec/requests/notifications_spec.rb index 471f4fd8c3..f0037705ad 100644 --- a/spec/requests/notifications_spec.rb +++ b/spec/requests/notifications_spec.rb @@ -5,8 +5,6 @@ travel_to Date.new(2021, 1, 1) end - after { travel_back } - describe "GET /index" do context "when there are no patch notes" do context "when logged in as an admin" do diff --git a/spec/services/case_contacts_contact_dates_spec.rb b/spec/services/case_contacts_contact_dates_spec.rb index f077d0dd39..2b970667dc 100644 --- a/spec/services/case_contacts_contact_dates_spec.rb +++ b/spec/services/case_contacts_contact_dates_spec.rb @@ -5,8 +5,6 @@ travel_to Date.new(2021, 6, 1) end - after { travel_back } - describe "#contact_dates_details" do subject { described_class.new(interviewees).contact_dates_details } diff --git a/spec/services/deployment/backfill_case_contact_started_metadata_service_spec.rb b/spec/services/deployment/backfill_case_contact_started_metadata_service_spec.rb index 776e438eb1..de4d2de6a2 100644 --- a/spec/services/deployment/backfill_case_contact_started_metadata_service_spec.rb +++ b/spec/services/deployment/backfill_case_contact_started_metadata_service_spec.rb @@ -8,7 +8,6 @@ let(:parsed_present) { present.as_json } before { travel_to present } - after { travel_back } context "when a case contact has status metadata" do let(:case_contact) { create(:case_contact) } diff --git a/spec/services/emancipation_checklist_reminder_service_spec.rb b/spec/services/emancipation_checklist_reminder_service_spec.rb index 84d303f034..87c1af709d 100644 --- a/spec/services/emancipation_checklist_reminder_service_spec.rb +++ b/spec/services/emancipation_checklist_reminder_service_spec.rb @@ -10,7 +10,6 @@ end after do - travel_back clear_enqueued_jobs end diff --git a/spec/services/volunteer_birthday_reminder_service_spec.rb b/spec/services/volunteer_birthday_reminder_service_spec.rb index cb6290d906..33a095ff48 100644 --- a/spec/services/volunteer_birthday_reminder_service_spec.rb +++ b/spec/services/volunteer_birthday_reminder_service_spec.rb @@ -15,7 +15,6 @@ end after do - travel_back clear_enqueued_jobs end @@ -72,7 +71,6 @@ context "when today is the 15th" do before { travel_to(this_month_15th) } - after { travel_back } let!(:volunteer) do create(:volunteer, :with_assigned_supervisor, date_of_birth: next_month) @@ -85,7 +83,6 @@ context "when today is not the 15th" do before { travel_to(this_month_15th + 2.days) } - after { travel_back } it "skips the rake task" do expect { send_reminders }.not_to change { Noticed::Notification.count } diff --git a/spec/support/shared_examples/shows_court_dates_links.rb b/spec/support/shared_examples/shows_court_dates_links.rb index fe14dd9ccc..2e66489f3f 100644 --- a/spec/support/shared_examples/shows_court_dates_links.rb +++ b/spec/support/shared_examples/shows_court_dates_links.rb @@ -7,8 +7,6 @@ _court_date_with_details = create(:court_date, :with_court_details, casa_case: casa_case, hearing_type: hearing_type) end - after { travel_back } - it "shows court orders" do visit edit_casa_case_path(casa_case) expect(page).to have_link("December 23, 2019") diff --git a/spec/system/casa_cases/edit_spec.rb b/spec/system/casa_cases/edit_spec.rb index 29fc885621..3cf34f3638 100644 --- a/spec/system/casa_cases/edit_spec.rb +++ b/spec/system/casa_cases/edit_spec.rb @@ -288,8 +288,6 @@ def sign_in_and_assign_volunteer travel_to Time.zone.local(2020, 8, 29, 4, 5, 6) end - after { travel_back } - context "when a volunteer is assigned to a case" do it "marks the volunteer as assigned and shows the start date of the assignment", :js do sign_in_and_assign_volunteer diff --git a/spec/system/casa_cases/show_spec.rb b/spec/system/casa_cases/show_spec.rb index 9f536cf2dd..4dadfcdbd4 100644 --- a/spec/system/casa_cases/show_spec.rb +++ b/spec/system/casa_cases/show_spec.rb @@ -51,8 +51,6 @@ visit casa_case_path(casa_case.id) end - after { travel_back } - context "when first arriving to 'Generate Court Report' page" do it "generation modal hidden" do expect(page).to have_selector "#btnGenerateReport", text: "Generate Report", visible: false diff --git a/spec/system/case_contacts/index_spec.rb b/spec/system/case_contacts/index_spec.rb index 62a4544a97..3c83c815a9 100644 --- a/spec/system/case_contacts/index_spec.rb +++ b/spec/system/case_contacts/index_spec.rb @@ -17,7 +17,7 @@ let(:case_contacts) do [ create(:case_contact, creator: volunteer, casa_case: casa_case, occurred_at: 2.days.ago), - create(:case_contact, creator: volunteer, casa_case: casa_case, occurred_at: 1.day.ago), + create(:case_contact, creator: volunteer, casa_case: casa_case, occurred_at: 1.days.ago), create(:case_contact, creator: volunteer, casa_case: casa_case, occurred_at: Time.zone.now, contact_types: [create(:contact_type, name: "Most Recent Case Contact")]), create(:case_contact, :started_status, creator: volunteer, casa_case: casa_case, occurred_at: 3.days.ago, diff --git a/spec/system/court_dates/edit_spec.rb b/spec/system/court_dates/edit_spec.rb index a6b8474646..c9124870e2 100644 --- a/spec/system/court_dates/edit_spec.rb +++ b/spec/system/court_dates/edit_spec.rb @@ -17,8 +17,6 @@ travel_to now end - after { travel_back } - context "as an admin" do before do sign_in admin diff --git a/spec/system/court_dates/new_spec.rb b/spec/system/court_dates/new_spec.rb index 116610a8fa..816edf6a34 100644 --- a/spec/system/court_dates/new_spec.rb +++ b/spec/system/court_dates/new_spec.rb @@ -19,8 +19,6 @@ click_link("Add a court date") end - after { travel_back } - context "when all fields are filled" do it "is successful", :js do expect(page).to have_content(casa_case.case_number) diff --git a/spec/system/court_dates/view_spec.rb b/spec/system/court_dates/view_spec.rb index 5c59d8dccb..cb258b0d96 100644 --- a/spec/system/court_dates/view_spec.rb +++ b/spec/system/court_dates/view_spec.rb @@ -15,8 +15,6 @@ travel_to now end - after { travel_back } - context "as a volunteer" do it "can download a report which focuses on the court date", :js do volunteer.casa_cases = [casa_case] diff --git a/spec/system/placements/destroy_spec.rb b/spec/system/placements/destroy_spec.rb index ad1f947312..5ff11fa5b2 100644 --- a/spec/system/placements/destroy_spec.rb +++ b/spec/system/placements/destroy_spec.rb @@ -15,8 +15,6 @@ click_on "Delete" end - after { travel_back } - it "does not delete on modal close" do expect(page).to have_text("Delete Placement?") click_on "Close" diff --git a/spec/system/placements/edit_spec.rb b/spec/system/placements/edit_spec.rb index 1a9819a591..be7ca17d55 100644 --- a/spec/system/placements/edit_spec.rb +++ b/spec/system/placements/edit_spec.rb @@ -17,8 +17,6 @@ click_link("Edit") end - after { travel_back } - it "updates placement with valid form data", :js do expect(page).to have_content("123") diff --git a/spec/system/placements/index_spec.rb b/spec/system/placements/index_spec.rb index c967a8e9c7..007296f39a 100644 --- a/spec/system/placements/index_spec.rb +++ b/spec/system/placements/index_spec.rb @@ -22,8 +22,6 @@ visit casa_case_placements_path(casa_case, placements) end - after { travel_back } - it "displays all placements for org" do expect(page).to have_text("Reunification") expect(page).to have_text("August 15, 2024 - Present") diff --git a/spec/system/placements/new_spec.rb b/spec/system/placements/new_spec.rb index 6d95c79616..623b58d796 100644 --- a/spec/system/placements/new_spec.rb +++ b/spec/system/placements/new_spec.rb @@ -17,8 +17,6 @@ click_link("New Placement") end - after { travel_back } - it "creates placement with valid form data", :js do expect(page).to have_content("123") diff --git a/spec/views/reimbursements/index.html.erb_spec.rb b/spec/views/reimbursements/index.html.erb_spec.rb index 15745b1994..6812b5ae42 100644 --- a/spec/views/reimbursements/index.html.erb_spec.rb +++ b/spec/views/reimbursements/index.html.erb_spec.rb @@ -11,7 +11,7 @@ supervisor = create :supervisor volunteer = create :volunteer, supervisor: supervisor - case_contact = create :case_contact, :wants_reimbursement, creator: volunteer, contact_made: true, occurred_at: Time.current - 6.days + case_contact = create :case_contact, :wants_reimbursement, creator: volunteer, contact_made: true, occurred_at: 6.days.ago assign :reimbursements, [case_contact] assign :grouped_reimbursements, [] assign :volunteers_for_filter, [] diff --git a/spec/views/supervisor_mailer/weekly_digest.html.erb_spec.rb b/spec/views/supervisor_mailer/weekly_digest.html.erb_spec.rb index c1484fb2fe..1ec599ab25 100644 --- a/spec/views/supervisor_mailer/weekly_digest.html.erb_spec.rb +++ b/spec/views/supervisor_mailer/weekly_digest.html.erb_spec.rb @@ -19,8 +19,8 @@ inactive_volunteer.update active: false supervisor.volunteers_ever_assigned << inactive_volunteer volunteer.casa_cases << casa_case - create_list :case_contact, 2, creator: volunteer, casa_case: casa_case, contact_made: false, occurred_at: Time.current - 6.days - @case_contact = create :case_contact, creator: volunteer, casa_case: casa_case, contact_made: true, occurred_at: Time.current - 6.days, contact_topic_answers: [contact_topic_answer_1, contact_topic_answer_2] + create_list :case_contact, 2, creator: volunteer, casa_case: casa_case, contact_made: false, occurred_at: 6.days.ago + @case_contact = create :case_contact, creator: volunteer, casa_case: casa_case, contact_made: true, occurred_at: 6.days.ago, contact_topic_answers: [contact_topic_answer_1, contact_topic_answer_2] assign :supervisor, supervisor assign :inactive_volunteers, [] sign_in supervisor