From b03ed67490b06d277dc923c2b95cf9c93736e262 Mon Sep 17 00:00:00 2001 From: Brock Wilcox Date: Sun, 22 Dec 2024 10:17:26 -0500 Subject: [PATCH 01/15] Rename cleanup_invalid_partner_profiles.rb to change execution order (#4885) This names it to be juuuuust before cleanup_partner_agency_types --- ...iles.rb => 20241122201254_cleanup_invalid_partner_profiles.rb} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename db/migrate/{20241204111437_cleanup_invalid_partner_profiles.rb => 20241122201254_cleanup_invalid_partner_profiles.rb} (100%) diff --git a/db/migrate/20241204111437_cleanup_invalid_partner_profiles.rb b/db/migrate/20241122201254_cleanup_invalid_partner_profiles.rb similarity index 100% rename from db/migrate/20241204111437_cleanup_invalid_partner_profiles.rb rename to db/migrate/20241122201254_cleanup_invalid_partner_profiles.rb From 113ecaed4a56d18ad2bd1123ae8694a49e2f52bc Mon Sep 17 00:00:00 2001 From: Efe Agare <39013780+EfeAgare@users.noreply.github.com> Date: Mon, 23 Dec 2024 15:19:22 +0100 Subject: [PATCH 02/15] Remove error from display in UI (#4786) * - remove error from display in UI * add comment * remove from ui * remove status error from spec * Commit changes on schema * revert schema changes --- app/models/partner.rb | 3 ++- app/views/partners/_statuses.html.erb | 3 +-- spec/models/partner_spec.rb | 2 -- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/app/models/partner.rb b/app/models/partner.rb index 858d01a67e..15979d9d02 100644 --- a/app/models/partner.rb +++ b/app/models/partner.rb @@ -27,7 +27,8 @@ class Partner < ApplicationRecord "application/vnd.openxmlformats-officedocument.wordprocessingml.document" ].freeze - enum :status, { uninvited: 0, invited: 1, awaiting_review: 2, approved: 3, error: 4, recertification_required: 5, deactivated: 6 } + # Status `4` (error) was removed for being obsolete but is intentionally skipped to preserve existing enum values. + enum status: { uninvited: 0, invited: 1, awaiting_review: 2, approved: 3, recertification_required: 5, deactivated: 6 } belongs_to :organization belongs_to :partner_group, optional: true diff --git a/app/views/partners/_statuses.html.erb b/app/views/partners/_statuses.html.erb index fcedc452c6..1f5f0432c0 100644 --- a/app/views/partners/_statuses.html.erb +++ b/app/views/partners/_statuses.html.erb @@ -2,8 +2,7 @@ "uninvited": 'ban', "invited": 'envelope', "awaiting_review": 'question-circle', - "approved": 'check-circle', - "error": 'exclamation-circle' + "approved": 'check-circle' }.with_indifferent_access current_filtered_status = params.dig(:filters, :by_status) %> diff --git a/spec/models/partner_spec.rb b/spec/models/partner_spec.rb index a3e0a06060..fe2856794d 100644 --- a/spec/models/partner_spec.rb +++ b/spec/models/partner_spec.rb @@ -131,7 +131,6 @@ expect(build(:partner, status: :invited)).not_to be_deletable expect(build(:partner, status: :awaiting_review)).not_to be_deletable expect(build(:partner, status: :approved)).not_to be_deletable - expect(build(:partner, status: :error)).not_to be_deletable expect(build(:partner, status: :recertification_required)).not_to be_deletable expect(build(:partner, status: :deactivated)).not_to be_deletable end @@ -191,7 +190,6 @@ it 'should return false', :aggregate_failures do expect(build(:partner, status: :uninvited)).not_to be_approvable expect(build(:partner, status: :approved)).not_to be_approvable - expect(build(:partner, status: :error)).not_to be_approvable expect(build(:partner, status: :recertification_required)).not_to be_approvable expect(build(:partner, status: :deactivated)).not_to be_approvable end From fc1e7b4f264d8871f1ee1948e389ebdc3fd6118c Mon Sep 17 00:00:00 2001 From: Gabe Parra <42552940+gabeparra01@users.noreply.github.com> Date: Mon, 23 Dec 2024 08:20:40 -0600 Subject: [PATCH 03/15] Resolves #4857 (#4872) * Calling reminder_email function from distribution_controller's create method * Only schedule reminder email if box is checked * Added specs for distribution reminder emails * Lint fixes * Updating existing distribution reminder email spec --------- Co-authored-by: Gabe --- app/controllers/distributions_controller.rb | 3 +- .../distributions_controller_spec.rb | 97 +++++++++++++++++++ spec/system/distribution_system_spec.rb | 2 +- 3 files changed, 100 insertions(+), 2 deletions(-) diff --git a/app/controllers/distributions_controller.rb b/app/controllers/distributions_controller.rb index 2e04de5cc6..2089d48b35 100644 --- a/app/controllers/distributions_controller.rb +++ b/app/controllers/distributions_controller.rb @@ -99,6 +99,7 @@ def create @distribution = result.distribution perform_inventory_check + schedule_reminder_email(result.distribution) if @distribution.reminder_email_enabled respond_to do |format| format.turbo_stream do @@ -196,7 +197,7 @@ def update if result.resend_notification? && @distribution.partner&.send_reminders send_notification(current_organization.id, @distribution.id, subject: "Your Distribution Has Changed", distribution_changes: result.distribution_content.changes) end - schedule_reminder_email(@distribution) + schedule_reminder_email(@distribution) if @distribution.reminder_email_enabled perform_inventory_check redirect_to @distribution, notice: "Distribution updated!" diff --git a/spec/controllers/distributions_controller_spec.rb b/spec/controllers/distributions_controller_spec.rb index d79775da2a..674e97acbd 100644 --- a/spec/controllers/distributions_controller_spec.rb +++ b/spec/controllers/distributions_controller_spec.rb @@ -1,8 +1,14 @@ RSpec.describe DistributionsController, type: :controller do + include ActiveJob::TestHelper + let(:organization) { create(:organization) } let(:user) { create(:user, organization: organization) } let(:partner) { create(:partner, organization: organization) } + after(:each) do + clear_enqueued_jobs + end + context "While signed in" do before do sign_in(user) @@ -220,6 +226,50 @@ expect(flash[:error]).to include("Sorry, we weren't able to save the distribution. \n Validation failed: Inventory Item 1's quantity needs to be at least 1") end end + + context "when distribution reminder email is enabled" do + let(:params) do + { + organization_name: organization.id, + distribution: { + partner_id: partner.id, + issued_at: Date.tomorrow, + storage_location_id: first_storage_location.id, + line_items_attributes: + { + "0": { item_id: first_storage_location.items.first.id, quantity: 10 } + }, + reminder_email_enabled: true + } + } + end + subject { post :create, params: params.merge(format: :turbo_stream) } + + context "when partner has enabled send_reminders" do + before(:each) do + partner.send_reminders = true + end + it "should schedule the reminder email" do + subject + expect(enqueued_jobs[2]["arguments"][1]).to eq("reminder_email") + end + + it "should not schedule a reminder for a date in the past" do + params[:distribution][:issued_at] = Date.yesterday + subject + expect(enqueued_jobs.size).to eq(2) + end + end + + context "when partner has disabled send_reminders" do + let(:partner) { create(:partner, organization: organization, send_reminders: false) } + + it "should not schedule an email reminder for a partner that disabled reminders" do + subject + expect(enqueued_jobs.size).to eq(1) + end + end + end end describe "PUT #update" do @@ -353,6 +403,53 @@ expect(flash[:alert]).to be_nil end end + + context "when distribution reminder email is enabled" do + let(:item1) { create(:item, name: "Item 1", organization: organization, on_hand_minimum_quantity: 0) } + let(:storage_location) { create(:storage_location, organization: organization) } + let(:distribution) { create(:distribution, :with_items, item: item1, storage_location: storage_location, organization: organization, reminder_email_enabled: false, partner: partner) } + let(:params) do + { + organization_name: organization.id, + id: distribution.id, + distribution: { + storage_location_id: distribution.storage_location.id, + issued_at: Date.tomorrow, + line_items_attributes: + { + "0": { item_id: item1.id, quantity: 1 } + }, + reminder_email_enabled: true + } + } + end + subject { put :update, params: params } + + context "when partner has enabled send_reminders" do + before(:each) do + partner.send_reminders = true + end + it "should schedule the reminder email" do + subject + expect(enqueued_jobs[1]["arguments"][1]).to eq("reminder_email") + end + + it "should not schedule a reminder for a date in the past" do + params[:distribution][:issued_at] = Date.yesterday + subject + expect(enqueued_jobs.size).to eq(1) + end + end + + context "when partner has disabled send_reminders" do + let(:partner) { create(:partner, organization: organization, send_reminders: false) } + + it "should not schedule an email reminder for a partner that disabled reminders" do + subject + expect(enqueued_jobs.size).to eq(1) + end + end + end end end end diff --git a/spec/system/distribution_system_spec.rb b/spec/system/distribution_system_spec.rb index 649149773c..c45a484fe8 100644 --- a/spec/system/distribution_system_spec.rb +++ b/spec/system/distribution_system_spec.rb @@ -338,7 +338,7 @@ end context "With an existing distribution" do - let!(:distribution) { create(:distribution, :with_items, agency_rep: "A Person", delivery_method: delivery_method, organization: user.organization) } + let!(:distribution) { create(:distribution, :with_items, agency_rep: "A Person", delivery_method: delivery_method, organization: user.organization, reminder_email_enabled: true) } let(:delivery_method) { "pick_up" } before do From 6e767dba5a1d245a971fa0424f53a10f04441040 Mon Sep 17 00:00:00 2001 From: Cory Streiff <90390502+coalest@users.noreply.github.com> Date: Mon, 23 Dec 2024 15:26:01 +0100 Subject: [PATCH 04/15] Update Rubocop config (#4878) --- .rubocop.yml | 34 ++++++------------- Gemfile | 4 ++- Gemfile.lock | 30 ++++++++-------- .../partners/dashboards_controller.rb | 4 +-- app/events/inventory_aggregate.rb | 2 +- app/models/adjustment.rb | 1 - app/models/audit.rb | 1 - app/models/barcode_item.rb | 2 +- app/models/concerns/issued_at.rb | 2 +- app/models/distribution.rb | 4 +-- app/models/donation_site.rb | 2 +- app/models/inventory_item.rb | 2 -- app/models/item.rb | 3 +- app/models/item_category.rb | 1 - app/models/line_item.rb | 1 - app/models/organization.rb | 6 ++-- app/models/partner.rb | 3 +- app/models/partner_group.rb | 1 - app/models/partners/profile.rb | 2 +- app/models/storage_location.rb | 2 +- app/models/transfer.rb | 1 - app/services/organization_update_service.rb | 4 +-- config/initializers/action_view.rb | 2 -- lib/seeds.rb | 2 +- spec/controllers/transfers_controller_spec.rb | 4 +-- spec/factories/users.rb | 2 +- spec/jobs/partner_mailer_job_spec.rb | 4 +-- spec/models/distribution_spec.rb | 18 +--------- spec/models/donation_spec.rb | 2 +- spec/models/item_category_spec.rb | 1 - spec/models/organization_spec.rb | 6 +--- spec/models/purchase_spec.rb | 2 +- spec/models/storage_location_spec.rb | 1 - spec/models/user_spec.rb | 6 ++-- spec/rails_helper.rb | 2 ++ spec/requests/organization_requests_spec.rb | 2 +- .../distributions_summary_requests_spec.rb | 2 +- .../reports/donations_summary_spec.rb | 2 +- .../manufacturer_donations_summary_spec.rb | 2 +- .../reports/product_drives_summary_spec.rb | 2 +- .../purchases_summary_requests_spec.rb | 2 +- spec/requests/transfers_requests_spec.rb | 4 +-- spec/services/distribution_reminder_spec.rb | 4 +-- ...tch_partners_to_remind_now_service_spec.rb | 1 - spec/services/sync_ndbn_members_spec.rb | 8 ++--- .../date_range_picker_shared_example.rb | 20 +++-------- spec/system/partner_system_spec.rb | 4 +-- spec/system/purchase_system_spec.rb | 4 --- spec/system/request_system_spec.rb | 2 -- 49 files changed, 81 insertions(+), 142 deletions(-) delete mode 100644 config/initializers/action_view.rb diff --git a/.rubocop.yml b/.rubocop.yml index 2c5e5d8d59..a903fd4678 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -4,6 +4,8 @@ inherit_mode: inherit_gem: standard: config/base.yml + standard-rails: config/base.yml + standard-performance: config/base.yml inherit_from: .rubocop_todo.yml @@ -12,15 +14,17 @@ require: - rubocop-rails - rubocop-performance - standard + - standard-rails + - standard-performance AllCops: - TargetRubyVersion: 3.1.2 Exclude: - "vendor/**/*" - "db/schema.rb" - "db/partners_schema.rb" - "db/seeds.rb" - "db/migrate/*" + - "db/partners_migrate/*" - "bin/*" - "lib/files/cucumber.rake" - "lib/tasks/*" @@ -29,26 +33,13 @@ AllCops: - "Rakefile" - "tmp/*" - "node_modules/**/*" - UseCache: false Rails: Enabled: true -Rails/Output: - Enabled: true -Rails/Date: - Enabled: true Rails/FilePath: Enabled: false -Rails/FindBy: - Enabled: true -Rails/FindEach: - Enabled: true Rails/PluralizationGrammar: Enabled: true -Rails/ScopeArgs: - Enabled: true -Rails/TimeZone: - Enabled: true Rails/UnknownEnv: Environments: - production @@ -62,32 +53,27 @@ Rails/AfterCommitOverride: Enabled: false Rails/FindById: Enabled: false -Rails/Inquiry: - Enabled: false Rails/MailerName: Enabled: false Rails/MatchRoute: Enabled: false -Rails/NegateInclude: - Enabled: false Rails/Pluck: Enabled: false Rails/PluckInWhere: Enabled: false -Rails/RenderInline: - Enabled: false Rails/RenderPlainText: Enabled: false Rails/ShortI18n: Enabled: false Rails/SquishedSQLHeredocs: Enabled: false -Rails/WhereExists: - Enabled: false -Rails/WhereNot: - Enabled: false Rails/HasAndBelongsToMany: Enabled: false +Rails/ThreeStateBooleanColumn: + Enabled: true +# FIXME: Fix our ENV variable access and remove the following config. +Rails/EnvironmentVariableAccess: + AllowReads: true Rails/BulkChangeTable: Exclude: diff --git a/Gemfile b/Gemfile index 448feffc19..a0f606065e 100644 --- a/Gemfile +++ b/Gemfile @@ -157,9 +157,11 @@ group :development, :test do gem "rubocop" # Rails add-on for static analysis. gem 'rubocop-performance' - gem "rubocop-rails", "~> 2.27.0" + gem "rubocop-rails", "~> 2.25.1" # Default rules for Rubocop. gem "standard", "~> 1.40" + gem "standard-rails" + gem "standard-performance" # Erb linter. gem "erb_lint" end diff --git a/Gemfile.lock b/Gemfile.lock index a3f35a131e..13ff12d032 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -445,7 +445,7 @@ GEM parser (3.3.6.0) ast (~> 2.4.1) racc - pdf-core (0.10.0) + pdf-core (0.9.0) pdf-reader (2.12.0) Ascii85 (~> 1.0) afm (~> 0.2.1) @@ -454,13 +454,11 @@ GEM ttfunk pg (1.5.7) popper_js (2.11.8) - prawn (2.5.0) - matrix (~> 0.4) - pdf-core (~> 0.10.0) - ttfunk (~> 1.8) - prawn-rails (1.5.0) + prawn (2.4.0) + pdf-core (~> 0.9.0) + ttfunk (~> 1.7) + prawn-rails (1.4.2) actionview (>= 3.1.0) - activesupport (>= 3.1.0) prawn prawn-table prawn-table (0.2.2) @@ -595,10 +593,10 @@ GEM rubocop-performance (1.23.0) rubocop (>= 1.48.1, < 2.0) rubocop-ast (>= 1.31.1, < 2.0) - rubocop-rails (2.27.0) + rubocop-rails (2.25.1) activesupport (>= 4.2.0) rack (>= 1.1) - rubocop (>= 1.52.0, < 2.0) + rubocop (>= 1.33.0, < 2.0) rubocop-ast (>= 1.31.1, < 2.0) ruby-graphviz (1.2.5) rexml @@ -664,6 +662,9 @@ GEM standard-performance (1.6.0) lint_roller (~> 1.1) rubocop-performance (~> 1.23.0) + standard-rails (1.1.0) + lint_roller (~> 1.0) + rubocop-rails (~> 2.25.0) stimulus-rails (1.3.4) railties (>= 6.0.0) stringio (3.1.2) @@ -673,10 +674,9 @@ GEM execjs (>= 0.3.0, < 3) thor (1.3.2) tilt (2.2.0) - timeout (0.4.2) - ttfunk (1.8.0) - bigdecimal (~> 3.1) - turbo-rails (2.0.11) + timeout (0.4.1) + ttfunk (1.7.0) + turbo-rails (2.0.10) actionpack (>= 6.0.0) railties (>= 6.0.0) tzinfo (2.0.6) @@ -792,13 +792,15 @@ DEPENDENCIES rspec-rails (~> 7.0.1) rubocop rubocop-performance - rubocop-rails (~> 2.27.0) + rubocop-rails (~> 2.25.1) sass-rails shoulda-matchers (~> 6.2) simple_form simplecov sprockets (~> 4.2.1) standard (~> 1.40) + standard-performance + standard-rails stimulus-rails strong_migrations (= 1.8.0) terser diff --git a/app/controllers/partners/dashboards_controller.rb b/app/controllers/partners/dashboards_controller.rb index bc623be0e5..18d175ef04 100644 --- a/app/controllers/partners/dashboards_controller.rb +++ b/app/controllers/partners/dashboards_controller.rb @@ -10,9 +10,9 @@ def show @partner = current_partner @partner_requests = @partner.requests.order(created_at: :desc).limit(10) @upcoming_distributions = @partner.distributions.order(issued_at: :desc) - .where('issued_at >= ?', Time.zone.today) + .where(issued_at: Time.zone.today..) @distributions = @partner.distributions.order(issued_at: :desc) - .where('issued_at < ?', Time.zone.today) + .where(issued_at: ...Time.zone.today) .limit(5) @parent_org = Organization.find(@partner.organization_id) diff --git a/app/events/inventory_aggregate.rb b/app/events/inventory_aggregate.rb index ef1fe6f5cb..5efd7c8bb1 100644 --- a/app/events/inventory_aggregate.rb +++ b/app/events/inventory_aggregate.rb @@ -24,7 +24,7 @@ def inventory_for(organization_id, event_time: nil, validate: false) end if event_time && (!last_snapshot || event_time > last_snapshot.event_time) - events = events.where("event_time <= ?", event_time) + events = events.where(event_time: ..event_time) end events = events.to_a diff --git a/app/models/adjustment.rb b/app/models/adjustment.rb index f52d2c3b72..0622f3e11b 100644 --- a/app/models/adjustment.rb +++ b/app/models/adjustment.rb @@ -28,7 +28,6 @@ class Adjustment < ApplicationRecord } scope :during, ->(range) { where(adjustments: { created_at: range }) } - validates :storage_location, :organization, presence: true validate :storage_locations_belong_to_organization def self.storage_locations_adjusted_for(organization) diff --git a/app/models/audit.rb b/app/models/audit.rb index 7f490e0675..b66c40ea86 100644 --- a/app/models/audit.rb +++ b/app/models/audit.rb @@ -27,7 +27,6 @@ class Audit < ApplicationRecord enum status: { in_progress: 0, confirmed: 1, finalized: 2 } - validates :storage_location, :organization, presence: true validate :line_items_quantity_is_not_negative validate :line_items_unique_by_item_id validate :user_is_organization_admin_of_the_organization diff --git a/app/models/barcode_item.rb b/app/models/barcode_item.rb index cb05987b43..3e2bb36141 100644 --- a/app/models/barcode_item.rb +++ b/app/models/barcode_item.rb @@ -20,7 +20,7 @@ class BarcodeItem < ApplicationRecord validates :organization, presence: true, unless: proc { |b| b.barcodeable_type == "BaseItem" } validates :value, presence: true validate :unique_barcode_value - validates :quantity, :barcodeable, presence: true + validates :quantity, presence: true validates :quantity, numericality: { only_integer: true, greater_than: 0 } include Filterable diff --git a/app/models/concerns/issued_at.rb b/app/models/concerns/issued_at.rb index b28261b96f..93d1c3e2ef 100644 --- a/app/models/concerns/issued_at.rb +++ b/app/models/concerns/issued_at.rb @@ -5,7 +5,7 @@ module IssuedAt extend ActiveSupport::Concern included do - scope :by_issued_at, ->(issued_at) { where(issued_at: issued_at.beginning_of_month..issued_at.end_of_month) } + scope :by_issued_at, ->(issued_at) { where(issued_at: issued_at.all_month) } scope :for_year, ->(year) { where("extract(year from issued_at) = ?", year) } validates :issued_at, presence: true validate :issued_at_cannot_be_before_2000 diff --git a/app/models/distribution.rb b/app/models/distribution.rb index 1f7d10c857..75a69e4bd6 100644 --- a/app/models/distribution.rb +++ b/app/models/distribution.rb @@ -38,7 +38,7 @@ class Distribution < ApplicationRecord has_one :request, dependent: :nullify accepts_nested_attributes_for :request - validates :storage_location, :partner, :organization, :delivery_method, presence: true + validates :delivery_method, presence: true validate :line_items_quantity_is_positive validates :shipping_cost, numericality: { greater_than_or_equal_to: 0 }, allow_blank: true, if: :shipped? @@ -59,7 +59,7 @@ class Distribution < ApplicationRecord # state scope to allow filtering by state scope :by_state, ->(state) { where(state: state) } scope :recent, ->(count = 3) { order(issued_at: :desc).limit(count) } - scope :future, -> { where("issued_at >= :tomorrow", tomorrow: Time.zone.tomorrow) } + scope :future, -> { where(issued_at: Time.zone.tomorrow..) } scope :during, ->(range) { where(distributions: { issued_at: range }) } scope :for_csv_export, ->(organization, filters = {}, date_range = nil) { where(organization: organization) diff --git a/app/models/donation_site.rb b/app/models/donation_site.rb index 99ddd71d97..13161e41f2 100644 --- a/app/models/donation_site.rb +++ b/app/models/donation_site.rb @@ -22,7 +22,7 @@ class DonationSite < ApplicationRecord belongs_to :organization - validates :name, :address, :organization, presence: true + validates :name, :address, presence: true validates :contact_name, length: {minimum: 3}, allow_blank: true validates :email, format: {with: URI::MailTo::EMAIL_REGEXP, message: "is not a valid email format"}, allow_blank: true diff --git a/app/models/inventory_item.rb b/app/models/inventory_item.rb index 1c46a2bda2..623c9fffc5 100644 --- a/app/models/inventory_item.rb +++ b/app/models/inventory_item.rb @@ -20,8 +20,6 @@ class InventoryItem < ApplicationRecord belongs_to :item validates :quantity, presence: true - validates :storage_location_id, presence: true - validates :item_id, presence: true scope :by_partner_key, ->(partner_key) { joins(:item).merge(Item.by_partner_key(partner_key)) } scope :active, -> { joins(:item).where(items: {active: true}) } diff --git a/app/models/item.rb b/app/models/item.rb index 688bd34512..dbea21a08b 100644 --- a/app/models/item.rb +++ b/app/models/item.rb @@ -36,7 +36,6 @@ class Item < ApplicationRecord validates :name, uniqueness: { scope: :organization, case_sensitive: false, message: "- An item with that name already exists (could be an inactive item)" } validates :name, presence: true - validates :organization, presence: true validates :distribution_quantity, numericality: { greater_than: 0 }, allow_blank: true validates :on_hand_recommended_quantity, numericality: { greater_than_or_equal_to: 0 }, allow_blank: true validates :on_hand_minimum_quantity, numericality: { greater_than_or_equal_to: 0 } @@ -115,7 +114,7 @@ def self.barcoded_items end def self.barcodes_for(item) - BarcodeItem.where("barcodeable_id = ?", item.id) + BarcodeItem.where(barcodeable_id: item.id) end def self.reactivate(item_ids) diff --git a/app/models/item_category.rb b/app/models/item_category.rb index c005bfe9b7..20c2fab014 100644 --- a/app/models/item_category.rb +++ b/app/models/item_category.rb @@ -12,7 +12,6 @@ class ItemCategory < ApplicationRecord has_paper_trail validates :name, presence: true, uniqueness: { scope: :organization_id } - validates :organization, presence: true validates :description, length: { maximum: 250 } belongs_to :organization diff --git a/app/models/line_item.rb b/app/models/line_item.rb index 8cdcb79b7c..68bc74a132 100644 --- a/app/models/line_item.rb +++ b/app/models/line_item.rb @@ -20,7 +20,6 @@ class LineItem < ApplicationRecord belongs_to :itemizable, polymorphic: true, inverse_of: :line_items, optional: false belongs_to :item - validates :item_id, presence: true validates :quantity, numericality: { only_integer: true, message: "is not a number. Note: commas are not allowed" } validate :quantity_must_be_a_number_within_range diff --git a/app/models/organization.rb b/app/models/organization.rb index 7a551a7a91..b59a2a420d 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -39,7 +39,7 @@ class Organization < ApplicationRecord has_paper_trail resourcify - DIAPER_APP_LOGO = Rails.root.join("public", "img", "humanessentials_logo.png") + DIAPER_APP_LOGO = Rails.public_path.join("img", "humanessentials_logo.png") include Deadlinable @@ -106,7 +106,7 @@ def all end has_many :distributions, dependent: :destroy do def upcoming - this_week.scheduled.where('issued_at >= ?', Time.zone.today) + this_week.scheduled.where(issued_at: Time.zone.today..) end end @@ -293,6 +293,6 @@ def get_admin_email end def logo_size_check - errors.add(:logo, 'File size is greater than 1 MB') if logo.byte_size > 1.megabyte + errors.add(:logo, 'File size is greater than 1 MB') if logo.byte_size > 1.megabytes end end diff --git a/app/models/partner.rb b/app/models/partner.rb index 15979d9d02..eddabcc5a4 100644 --- a/app/models/partner.rb +++ b/app/models/partner.rb @@ -46,7 +46,6 @@ class Partner < ApplicationRecord has_many_attached :documents - validates :organization, presence: true validates :name, presence: true, uniqueness: { scope: :organization } validates :email, presence: true, uniqueness: { case_sensitive: false }, format: { with: URI::MailTo::EMAIL_REGEXP } @@ -259,7 +258,7 @@ def partials_to_show def quantity_year_to_date distributions .includes(:line_items) - .where('distributions.issued_at >= ?', Time.zone.today.beginning_of_year) + .where(distributions: { issued_at: Time.zone.today.beginning_of_year.. }) .references(:line_items).map(&:line_items).flatten.sum(&:quantity) end diff --git a/app/models/partner_group.rb b/app/models/partner_group.rb index e7ac55c8fd..715aa101b2 100644 --- a/app/models/partner_group.rb +++ b/app/models/partner_group.rb @@ -19,7 +19,6 @@ class PartnerGroup < ApplicationRecord has_many :partners, dependent: :nullify has_and_belongs_to_many :item_categories - validates :organization, presence: true validates :name, presence: true, uniqueness: { scope: :organization } validates :deadline_day, :reminder_day, presence: true, if: :send_reminders? end diff --git a/app/models/partners/profile.rb b/app/models/partners/profile.rb index 271ec146b5..aac34d57d7 100644 --- a/app/models/partners/profile.rb +++ b/app/models/partners/profile.rb @@ -101,7 +101,7 @@ class Profile < Base validate :has_at_least_one_request_setting validate :pick_up_email_addresses - self.ignored_columns = %w[ + self.ignored_columns += %w[ evidence_based_description program_client_improvement incorporate_plan diff --git a/app/models/storage_location.rb b/app/models/storage_location.rb index 94f2a0a23e..4b2f655c5b 100644 --- a/app/models/storage_location.rb +++ b/app/models/storage_location.rb @@ -42,7 +42,7 @@ class StorageLocation < ApplicationRecord dependent: :destroy has_many :kit_allocations, dependent: :destroy - validates :name, :address, :organization, presence: true + validates :name, :address, presence: true validates :warehouse_type, inclusion: { in: WAREHOUSE_TYPES }, allow_blank: true before_destroy :validate_empty_inventory, prepend: true diff --git a/app/models/transfer.rb b/app/models/transfer.rb index 49b2248f2a..b29984a5ca 100644 --- a/app/models/transfer.rb +++ b/app/models/transfer.rb @@ -30,7 +30,6 @@ class Transfer < ApplicationRecord } scope :during, ->(range) { where(created_at: range) } - validates :from, :to, :organization, presence: true validate :storage_locations_belong_to_organization validate :storage_locations_must_be_different validate :from_storage_quantities diff --git a/app/services/organization_update_service.rb b/app/services/organization_update_service.rb index 9ebd27e4a8..d4959d2f39 100644 --- a/app/services/organization_update_service.rb +++ b/app/services/organization_update_service.rb @@ -15,12 +15,12 @@ def update(organization, params) org_params = params.dup if org_params.has_key?("partner_form_fields") - org_params["partner_form_fields"] = org_params["partner_form_fields"].reject(&:blank?) + org_params["partner_form_fields"] = org_params["partner_form_fields"].compact_blank end if Flipper.enabled?(:enable_packs) && org_params[:request_unit_names] # Find or create units for the organization - request_unit_ids = org_params[:request_unit_names].reject(&:blank?).map do |request_unit_name| + request_unit_ids = org_params[:request_unit_names].compact_blank.map do |request_unit_name| Unit.find_or_create_by(organization: organization, name: request_unit_name).id end org_params.delete(:request_unit_names) diff --git a/config/initializers/action_view.rb b/config/initializers/action_view.rb deleted file mode 100644 index 4c7de41729..0000000000 --- a/config/initializers/action_view.rb +++ /dev/null @@ -1,2 +0,0 @@ -# this is to enable the MoneyRails::ActionViewExtension in the helper files as they load -require "action_view/base" diff --git a/lib/seeds.rb b/lib/seeds.rb index f5cd4537ce..c2f629564e 100644 --- a/lib/seeds.rb +++ b/lib/seeds.rb @@ -1,7 +1,7 @@ module Seeds def self.seed_base_items # Initial starting qty for our test organizations - base_items = File.read(Rails.root.join("db", "base_items.json")) + base_items = Rails.root.join("db", "base_items.json").read items_by_category = JSON.parse(base_items) items_by_category.each do |category, entries| diff --git a/spec/controllers/transfers_controller_spec.rb b/spec/controllers/transfers_controller_spec.rb index 62cb737558..8fd316d048 100644 --- a/spec/controllers/transfers_controller_spec.rb +++ b/spec/controllers/transfers_controller_spec.rb @@ -25,8 +25,8 @@ context 'when date parameters are supplied' do it 'only returns the correct obejects' do - start_date = 3.days.ago.to_formatted_s(:date_picker) - end_date = Time.zone.today.to_formatted_s(:date_picker) + start_date = 3.days.ago.to_fs(:date_picker) + end_date = Time.zone.today.to_fs(:date_picker) get :index, params: { filters: { date_range: "#{start_date} - #{end_date}" } } expect(assigns(:transfers)).to eq([new_transfer]) end diff --git a/spec/factories/users.rb b/spec/factories/users.rb index 2438dcfcec..9177937b23 100644 --- a/spec/factories/users.rb +++ b/spec/factories/users.rb @@ -56,7 +56,7 @@ sequence(:email) { |n| "partner_user_#{n}@example.com" } password { "password!" } password_confirmation { "password!" } - invitation_sent_at { Time.current - 1.day } + invitation_sent_at { 1.day.ago } last_sign_in_at { Time.current } organization { nil } transient do diff --git a/spec/jobs/partner_mailer_job_spec.rb b/spec/jobs/partner_mailer_job_spec.rb index 9ff213a18b..173ff925aa 100644 --- a/spec/jobs/partner_mailer_job_spec.rb +++ b/spec/jobs/partner_mailer_job_spec.rb @@ -4,8 +4,8 @@ let(:mailer_subject) { 'PartnerMailerJob subject' } let(:distribution) { create :distribution } - let(:past_distribution) { create(:distribution, issued_at: Time.zone.now - 1.week) } - let(:future_distribution) { create(:distribution, issued_at: Time.zone.now + 1.week) } + let(:past_distribution) { create(:distribution, issued_at: 1.week.ago) } + let(:future_distribution) { create(:distribution, issued_at: 1.week.from_now) } let(:distribution_changes) { {} } it "does not send mail for past distributions" do diff --git a/spec/models/distribution_spec.rb b/spec/models/distribution_spec.rb index b75ae51c9f..40b09379c0 100644 --- a/spec/models/distribution_spec.rb +++ b/spec/models/distribution_spec.rb @@ -23,10 +23,6 @@ it_behaves_like "itemizable" context "Validations >" do - it { should validate_presence_of(:organization) } - it { should validate_presence_of(:partner) } - it { should validate_presence_of(:storage_location) } - it "ensures the associated line_items are valid" do organization = create(:organization) storage_location = create(:storage_location, organization: organization) @@ -95,7 +91,7 @@ create(:distribution, issued_at: Date.yesterday) # and one outside the range create(:distribution, issued_at: 1.year.ago) - expect(Distribution.during(Time.zone.now - 1.week..Time.zone.now + 2.days).size).to eq(2) + expect(Distribution.during(1.week.ago..2.days.from_now).size).to eq(2) end end @@ -105,10 +101,6 @@ travel_to Time.zone.local(2019, 6, 30) end - after do - travel_back - end - it "doesn't include distributions past Sunday" do sunday_distribution = create(:distribution, organization: organization, issued_at: Time.zone.local(2019, 6, 30)) create(:distribution, organization: organization, issued_at: Time.zone.local(2019, 7, 1)) @@ -123,10 +115,6 @@ travel_to Time.zone.local(2019, 7, 2) end - after do - travel_back - end - it "includes distributions as early as Monday and as late as upcoming Sunday" do create(:distribution, organization: organization, issued_at: Time.zone.local(2019, 6, 30)) tuesday_distribution = create(:distribution, organization: organization, issued_at: Time.zone.local(2019, 7, 2)) @@ -145,10 +133,6 @@ travel_to Time.zone.local(2023, 12, 31) end - after do - travel_back - end - it "includes distributions issued within the last 12 months" do included_distribution = create(:distribution, organization: organization, issued_at: Time.zone.local(2023, 1, 1)) excluded_distribution = create(:distribution, organization: organization, issued_at: Time.zone.local(2022, 12, 30)) diff --git a/spec/models/donation_spec.rb b/spec/models/donation_spec.rb index 2e66edc10b..5418920dec 100644 --- a/spec/models/donation_spec.rb +++ b/spec/models/donation_spec.rb @@ -82,7 +82,7 @@ create(:donation, issued_at: Date.yesterday) # and one outside the range create(:donation, issued_at: 1.year.ago) - expect(Donation.during(1.month.ago..Time.zone.now + 2.days).size).to eq(2) + expect(Donation.during(1.month.ago..2.days.from_now).size).to eq(2) end end diff --git a/spec/models/item_category_spec.rb b/spec/models/item_category_spec.rb index 74bf71f222..ac60dca39d 100644 --- a/spec/models/item_category_spec.rb +++ b/spec/models/item_category_spec.rb @@ -16,7 +16,6 @@ it { should validate_presence_of(:name) } it { should validate_uniqueness_of(:name).scoped_to(:organization_id) } - it { should validate_presence_of(:organization) } it { should validate_length_of(:description).is_at_most(250) } end diff --git a/spec/models/organization_spec.rb b/spec/models/organization_spec.rb index 89438098d9..4838d82120 100644 --- a/spec/models/organization_spec.rb +++ b/spec/models/organization_spec.rb @@ -68,7 +68,7 @@ end it "validates that attachment file size is not higher than 1 MB" do - fixture_path = File.join(Rails.root, 'spec', 'fixtures', 'files', 'logo.jpg') + fixture_path = Rails.root.join('spec', 'fixtures', 'files', 'logo.jpg') fixture_file = File.open(fixture_path) organization = build(:organization) @@ -131,10 +131,6 @@ travel_to Time.zone.local(2019, 7, 3) # Wednesday end - after do - travel_back - end - it "retrieves the distributions scheduled for this week that have not yet happened" do wednesday_distribution_scheduled = create(:distribution, organization: organization, state: :scheduled, issued_at: Time.zone.local(2019, 7, 3)) create(:distribution, organization: organization, state: :complete, issued_at: Time.zone.local(2019, 7, 3)) diff --git a/spec/models/purchase_spec.rb b/spec/models/purchase_spec.rb index 655a5999e1..e8d235a3d7 100644 --- a/spec/models/purchase_spec.rb +++ b/spec/models/purchase_spec.rb @@ -109,7 +109,7 @@ # and one outside the range create(:purchase, issued_at: 1.year.ago) - expect(Purchase.during(1.month.ago..Time.zone.now + 2.days).size).to eq(2) + expect(Purchase.during(1.month.ago..2.days.from_now).size).to eq(2) end end end diff --git a/spec/models/storage_location_spec.rb b/spec/models/storage_location_spec.rb index 5ebdb20ba2..95b9127aba 100644 --- a/spec/models/storage_location_spec.rb +++ b/spec/models/storage_location_spec.rb @@ -21,7 +21,6 @@ context "Validations >" do it { is_expected.to validate_presence_of(:name) } it { is_expected.to validate_presence_of(:address) } - it { is_expected.to validate_presence_of(:organization) } end context "Callbacks >" do diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index f2f37da4f0..e6ea890636 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -122,9 +122,9 @@ end it "#reinvitable?" do - expect(build(:user, invitation_sent_at: Time.current - 7.days).reinvitable?).to be true - expect(build(:user, invitation_sent_at: Time.current - 6.days).reinvitable?).to be false - expect(build(:user, invitation_sent_at: Time.current - 7.days, invitation_accepted_at: Time.current - 7.days).reinvitable?).to be false + expect(build(:user, invitation_sent_at: 7.days.ago).reinvitable?).to be true + expect(build(:user, invitation_sent_at: 6.days.ago).reinvitable?).to be false + expect(build(:user, invitation_sent_at: 7.days.ago, invitation_accepted_at: 7.days.ago).reinvitable?).to be false end it "discarded?" do diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 375094b245..1af8c6a50b 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -174,9 +174,11 @@ def self.capybara_tmp_path Faker::UniqueGenerator.clear # Clears used values to avoid retry limit exceeded error end + # rubocop:disable Rails/RedundantTravelBack config.after(:each) do travel_back end + # rubocop:enable Rails/RedundantTravelBack # RSpec Rails can automatically mix in different behaviours to your tests # based on their file location, for example enabling you to call `get` and diff --git a/spec/requests/organization_requests_spec.rb b/spec/requests/organization_requests_spec.rb index 3bf3754666..e1ada7916c 100644 --- a/spec/requests/organization_requests_spec.rb +++ b/spec/requests/organization_requests_spec.rb @@ -148,7 +148,7 @@ end it "can re-invite a user to an organization after 7 days" do - create(:user, name: "Ye Olde Invited User", invitation_sent_at: Time.current - 7.days) + create(:user, name: "Ye Olde Invited User", invitation_sent_at: 7.days.ago) get organization_path expect(response.body).to include("Re-send invitation") end diff --git a/spec/requests/reports/distributions_summary_requests_spec.rb b/spec/requests/reports/distributions_summary_requests_spec.rb index 6fcc04e0bd..63d6e6e25b 100644 --- a/spec/requests/reports/distributions_summary_requests_spec.rb +++ b/spec/requests/reports/distributions_summary_requests_spec.rb @@ -37,7 +37,7 @@ create :distribution, :with_items, item_quantity: 17, issued_at: 30.days.ago, organization: organization end - let(:formatted_date_range) { date_range.map { _1.to_formatted_s(:date_picker) }.join(" - ") } + let(:formatted_date_range) { date_range.map { _1.to_fs(:date_picker) }.join(" - ") } before do get reports_distributions_summary_path, params: {filters: {date_range: formatted_date_range}} diff --git a/spec/requests/reports/donations_summary_spec.rb b/spec/requests/reports/donations_summary_spec.rb index 7d16c5b37c..89daa7e96f 100644 --- a/spec/requests/reports/donations_summary_spec.rb +++ b/spec/requests/reports/donations_summary_spec.rb @@ -38,7 +38,7 @@ create :donation, :with_items, item_quantity: 17, issued_at: 30.days.ago, organization: organization end - let(:formatted_date_range) { date_range.map { _1.to_formatted_s(:date_picker) }.join(" - ") } + let(:formatted_date_range) { date_range.map { _1.to_fs(:date_picker) }.join(" - ") } before do get reports_donations_summary_path(user.organization), params: {filters: {date_range: formatted_date_range}} diff --git a/spec/requests/reports/manufacturer_donations_summary_spec.rb b/spec/requests/reports/manufacturer_donations_summary_spec.rb index e9172e1e9e..5487bf6370 100644 --- a/spec/requests/reports/manufacturer_donations_summary_spec.rb +++ b/spec/requests/reports/manufacturer_donations_summary_spec.rb @@ -28,7 +28,7 @@ end context "with manufacturer donations in the last year" do - let(:formatted_date_range) { date_range.map { _1.to_formatted_s(:date_picker) }.join(" - ") } + let(:formatted_date_range) { date_range.map { _1.to_fs(:date_picker) }.join(" - ") } let(:date_range) { [1.year.ago, 0.days.ago] } let!(:donations) do [ diff --git a/spec/requests/reports/product_drives_summary_spec.rb b/spec/requests/reports/product_drives_summary_spec.rb index 52d31f32e1..139c8f3419 100644 --- a/spec/requests/reports/product_drives_summary_spec.rb +++ b/spec/requests/reports/product_drives_summary_spec.rb @@ -35,7 +35,7 @@ create :product_drive_donation, :with_items, item_quantity: 117, money_raised: 1700, issued_at: 30.days.ago, organization: organization end - let(:formatted_date_range) { date_range.map { _1.to_formatted_s(:date_picker) }.join(" - ") } + let(:formatted_date_range) { date_range.map { _1.to_fs(:date_picker) }.join(" - ") } before do get reports_product_drives_summary_path(user.organization), params: {filters: {date_range: formatted_date_range}} diff --git a/spec/requests/reports/purchases_summary_requests_spec.rb b/spec/requests/reports/purchases_summary_requests_spec.rb index cc9f5b3399..f845c4e831 100644 --- a/spec/requests/reports/purchases_summary_requests_spec.rb +++ b/spec/requests/reports/purchases_summary_requests_spec.rb @@ -29,7 +29,7 @@ create :purchase, :with_items, item_quantity: 17, issued_at: 30.days.ago, organization: organization end - let(:formatted_date_range) { date_range.map { _1.to_formatted_s(:date_picker) }.join(" - ") } + let(:formatted_date_range) { date_range.map { _1.to_fs(:date_picker) }.join(" - ") } before do get reports_purchases_summary_path, params: {filters: {date_range: formatted_date_range}} diff --git a/spec/requests/transfers_requests_spec.rb b/spec/requests/transfers_requests_spec.rb index 80c406455e..65e2441150 100644 --- a/spec/requests/transfers_requests_spec.rb +++ b/spec/requests/transfers_requests_spec.rb @@ -30,8 +30,8 @@ context 'when date parameters are supplied' do it 'only returns the correct obejects' do - start_date = 3.days.ago.to_formatted_s(:date_picker) - end_date = Time.zone.today.to_formatted_s(:date_picker) + start_date = 3.days.ago.to_fs(:date_picker) + end_date = Time.zone.today.to_fs(:date_picker) get transfers_path(filters: { date_range: "#{start_date} - #{end_date}" }) expect(assigns(:transfers)).to eq([new_transfer]) end diff --git a/spec/services/distribution_reminder_spec.rb b/spec/services/distribution_reminder_spec.rb index d468597113..52cc73c43f 100644 --- a/spec/services/distribution_reminder_spec.rb +++ b/spec/services/distribution_reminder_spec.rb @@ -2,8 +2,8 @@ describe "conditionally sending the emails" do let(:organization) { create :organization } - let(:past_distribution) { create(:distribution, issued_at: Time.zone.now - 1.week) } - let(:future_distribution) { create(:distribution, issued_at: Time.zone.now + 1.week) } + let(:past_distribution) { create(:distribution, issued_at: 1.week.ago) } + let(:future_distribution) { create(:distribution, issued_at: 1.week.from_now) } let(:partner_with_no_reminders) { create :partner, send_reminders: false } let(:partner_with_reminders) { create :partner, send_reminders: true } diff --git a/spec/services/partners/fetch_partners_to_remind_now_service_spec.rb b/spec/services/partners/fetch_partners_to_remind_now_service_spec.rb index b4ca3d8eff..2c3c90b23a 100644 --- a/spec/services/partners/fetch_partners_to_remind_now_service_spec.rb +++ b/spec/services/partners/fetch_partners_to_remind_now_service_spec.rb @@ -3,7 +3,6 @@ subject { described_class.new.fetch } let(:current_day) { 14 } before { travel_to(Time.zone.local(2022, 6, current_day, 1, 1, 1)) } - after { travel_back } context "when there is a partner" do let!(:partner) { create(:partner) } diff --git a/spec/services/sync_ndbn_members_spec.rb b/spec/services/sync_ndbn_members_spec.rb index 18f5cc9a91..c1fd39ca2b 100644 --- a/spec/services/sync_ndbn_members_spec.rb +++ b/spec/services/sync_ndbn_members_spec.rb @@ -1,8 +1,8 @@ RSpec.describe SyncNDBNMembers do - let(:small_input) { File.open(Rails.root.join("spec", "fixtures", "ndbn-small-import.csv")) } - let(:invalid_input) { File.open(Rails.root.join("spec", "fixtures", "ndbn-invalid-import.csv")) } - let(:invalid_headers) { File.open(Rails.root.join("spec", "fixtures", "ndbn-invalid-header-import.csv")) } - let(:non_csv) { File.open(Rails.root.join("spec", "fixtures", "files", "logo.jpg")) } + let(:small_input) { Rails.root.join("spec", "fixtures", "ndbn-small-import.csv").open } + let(:invalid_input) { Rails.root.join("spec", "fixtures", "ndbn-invalid-import.csv").open } + let(:invalid_headers) { Rails.root.join("spec", "fixtures", "ndbn-invalid-header-import.csv").open } + let(:non_csv) { Rails.root.join("spec", "fixtures", "files", "logo.jpg").open } describe "#upload" do # NDBN Member Number,Member Name diff --git a/spec/support/date_range_picker_shared_example.rb b/spec/support/date_range_picker_shared_example.rb index 54ce71e7a8..3c7ba1213d 100644 --- a/spec/support/date_range_picker_shared_example.rb +++ b/spec/support/date_range_picker_shared_example.rb @@ -1,5 +1,5 @@ def date_range_picker_params(start_date, end_date) - "#{start_date.to_formatted_s(:date_picker)} - #{end_date.to_formatted_s(:date_picker)}" + "#{start_date.to_fs(:date_picker)} - #{end_date.to_fs(:date_picker)}" end def date_range_picker_select_range(range_name) @@ -34,10 +34,6 @@ def date_range_picker_select_range(range_name) sign_in user end - after do - travel_back - end - it "shows only 4 records" do visit subject expect(page).to have_css("table tbody tr", count: 4) @@ -51,13 +47,9 @@ def date_range_picker_select_range(range_name) sign_in user end - after do - travel_back - end - it "shows all the records" do visit subject - date_range = "#{Time.zone.local(1919, 7, 1).to_formatted_s(:date_picker)} - #{Time.zone.local(2020, 7, 31).to_formatted_s(:date_picker)}" + date_range = "#{Time.zone.local(1919, 7, 1).to_fs(:date_picker)} - #{Time.zone.local(2020, 7, 31).to_fs(:date_picker)}" fill_in "filters_date_range", with: date_range find(:id, 'filters_date_range').native.send_keys(:enter) expect(page).to have_css("table tbody tr", count: 6) @@ -71,15 +63,11 @@ def date_range_picker_select_range(range_name) sign_in user end - after do - travel_back - end - # NOTE: This spec MIGHT be flaky depending on the day of the month. # The dates being set may or may not respect the time travelling. it "shows only 2 of the records" do visit subject - date_range = "#{Time.zone.local(2019, 7, 1).to_formatted_s(:date_picker)} - #{Time.zone.local(2019, 7, 31).to_formatted_s(:date_picker)}" + date_range = "#{Time.zone.local(2019, 7, 1).to_fs(:date_picker)} - #{Time.zone.local(2019, 7, 31).to_fs(:date_picker)}" fill_in "filters_date_range", with: date_range find(:id, 'filters_date_range').native.send_keys(:enter) expect(page).to have_css("table tbody tr", count: 2) @@ -89,7 +77,7 @@ def date_range_picker_select_range(range_name) context "when choosing a date range that only includes the previous week" do it "shows only 1 record" do visit subject - date_range = "#{Time.zone.local(2019, 7, 22).to_formatted_s(:date_picker)} - #{Time.zone.local(2019, 7, 28).to_formatted_s(:date_picker)}" + date_range = "#{Time.zone.local(2019, 7, 22).to_fs(:date_picker)} - #{Time.zone.local(2019, 7, 28).to_fs(:date_picker)}" fill_in "filters_date_range", with: date_range find(:id, 'filters_date_range').native.send_keys(:enter) expect(page).to have_css("table tbody tr", count: 1) diff --git a/spec/system/partner_system_spec.rb b/spec/system/partner_system_spec.rb index 59c6d771e5..1733dd2b9f 100644 --- a/spec/system/partner_system_spec.rb +++ b/spec/system/partner_system_spec.rb @@ -497,8 +497,8 @@ subject { partner_users_path(partner) } let(:partner) { create(:partner, name: "Partner") } let(:partner_user) { partner.users.first } - let(:invitation_sent_at) { partner_user.invitation_sent_at.to_formatted_s(:date_picker) } - let(:last_sign_in_at) { partner_user.last_sign_in_at.to_formatted_s(:date_picker) } + let(:invitation_sent_at) { partner_user.invitation_sent_at.to_fs(:date_picker) } + let(:last_sign_in_at) { partner_user.last_sign_in_at.to_fs(:date_picker) } it 'can show users of a partner' do visit subject diff --git a/spec/system/purchase_system_spec.rb b/spec/system/purchase_system_spec.rb index c60ca20c40..39be2a13cb 100644 --- a/spec/system/purchase_system_spec.rb +++ b/spec/system/purchase_system_spec.rb @@ -19,10 +19,6 @@ visit subject end - after do - travel_back - end - it "User can click to the new purchase form" do find(".fa-plus").click diff --git a/spec/system/request_system_spec.rb b/spec/system/request_system_spec.rb index ce79f92089..ed2605fc06 100644 --- a/spec/system/request_system_spec.rb +++ b/spec/system/request_system_spec.rb @@ -19,8 +19,6 @@ }) end - after { travel_back } - context "#index" do subject { requests_path } From 220af873b625a9d9e9329b603e690c1674e9af90 Mon Sep 17 00:00:00 2001 From: Nozomi R <35720515+nozomirin@users.noreply.github.com> Date: Fri, 27 Dec 2024 22:35:12 +0800 Subject: [PATCH 05/15] Fix database migration failure during setup (#4890) (#4891) --- Gemfile.lock | 2 +- db/schema.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 13ff12d032..7c49075ff5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -809,4 +809,4 @@ DEPENDENCIES webmock (~> 3.24) BUNDLED WITH - 2.5.22 + 2.6.2 diff --git a/db/schema.rb b/db/schema.rb index 69dade3cbe..afc02b83d7 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2024_12_04_133715) do +ActiveRecord::Schema[7.2].define(version: 2024_12_20_020009) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" From 1957a795bdb1c2c5139daf35bad39a180ef1b296 Mon Sep 17 00:00:00 2001 From: Daniel Orner Date: Mon, 30 Dec 2024 19:57:10 -0500 Subject: [PATCH 06/15] Delete backup file after uploading (#4893) --- lib/tasks/backup_db_rds.rake | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/tasks/backup_db_rds.rake b/lib/tasks/backup_db_rds.rake index 272bd8ef9d..3abc59f6f5 100644 --- a/lib/tasks/backup_db_rds.rake +++ b/lib/tasks/backup_db_rds.rake @@ -19,4 +19,5 @@ task :backup_db_rds => :environment do logger.info("Uploading #{backup_filename}") blob_client.create_block_blob("backups", backup_filename, File.read(backup_filename)) + File.delete(backup_filename) end From 2fcd7a403decf397f6ee1f2394a0d087a5b0d9bc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Jan 2025 09:12:44 -0500 Subject: [PATCH 07/15] build(deps): bump nokogiri from 1.17.2 to 1.18.1 (#4898) Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.17.2 to 1.18.1. - [Release notes](https://github.com/sparklemotion/nokogiri/releases) - [Changelog](https://github.com/sparklemotion/nokogiri/blob/main/CHANGELOG.md) - [Commits](https://github.com/sparklemotion/nokogiri/compare/v1.17.2...v1.18.1) --- updated-dependencies: - dependency-name: nokogiri dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 7c49075ff5..a98a02c5ab 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -403,11 +403,11 @@ GEM net-protocol newrelic_rpm (9.16.0) nio4r (2.7.4) - nokogiri (1.17.2-arm64-darwin) + nokogiri (1.18.1-arm64-darwin) racc (~> 1.4) - nokogiri (1.17.2-x86_64-darwin) + nokogiri (1.18.1-x86_64-darwin) racc (~> 1.4) - nokogiri (1.17.2-x86_64-linux) + nokogiri (1.18.1-x86_64-linux-gnu) racc (~> 1.4) notiffany (0.1.3) nenv (~> 0.1) From 6e2e47febe3210f49e7fc6802f757943a8284b6e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Jan 2025 09:19:03 -0500 Subject: [PATCH 08/15] build(deps): bump dotenv-rails from 3.1.4 to 3.1.7 (#4899) Bumps [dotenv-rails](https://github.com/bkeepers/dotenv) from 3.1.4 to 3.1.7. - [Release notes](https://github.com/bkeepers/dotenv/releases) - [Changelog](https://github.com/bkeepers/dotenv/blob/main/Changelog.md) - [Commits](https://github.com/bkeepers/dotenv/compare/v3.1.4...v3.1.7) --- updated-dependencies: - dependency-name: dotenv-rails dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index a98a02c5ab..ff212c49e4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -105,7 +105,7 @@ GEM erubi (~> 1.4) parser (>= 2.4) smart_properties - bigdecimal (3.1.8) + bigdecimal (3.1.9) bindex (0.8.1) binding_of_caller (1.0.1) debug_inspector (>= 1.2.0) @@ -157,7 +157,7 @@ GEM activerecord (>= 5.a) database_cleaner-core (~> 2.0.0) database_cleaner-core (2.0.1) - date (3.4.0) + date (3.4.1) debug (1.9.2) irb (~> 1.10) reline (>= 0.3.8) @@ -185,9 +185,9 @@ GEM discard (1.3.0) activerecord (>= 4.2, < 8) docile (1.4.0) - dotenv (3.1.4) - dotenv-rails (3.1.4) - dotenv (= 3.1.4) + dotenv (3.1.7) + dotenv-rails (3.1.7) + dotenv (= 3.1.7) railties (>= 6.1) drb (2.2.1) dry-core (1.0.1) @@ -216,7 +216,7 @@ GEM rainbow rubocop (>= 1) smart_properties - erubi (1.13.0) + erubi (1.13.1) execjs (2.10.0) factory_bot (6.5.0) activesupport (>= 5.0.0) @@ -348,13 +348,13 @@ GEM listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - logger (1.6.3) + logger (1.6.4) lograge (0.14.0) actionpack (>= 4) activesupport (>= 4) railties (>= 4) request_store (~> 1.0) - loofah (2.23.1) + loofah (2.24.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) lumberjack (1.2.9) @@ -492,9 +492,9 @@ GEM rack (>= 3.0.0, < 4) rack-session (2.0.0) rack (>= 3.0.0) - rack-test (2.1.0) + rack-test (2.2.0) rack (>= 1.3) - rackup (2.2.0) + rackup (2.2.1) rack (>= 3) rails (7.2.2) actioncable (= 7.2.2) @@ -685,7 +685,7 @@ GEM unicode-emoji (~> 4.0, >= 4.0.4) unicode-emoji (4.0.4) uniform_notifier (1.16.0) - useragent (0.16.10) + useragent (0.16.11) version_gem (1.1.4) warden (1.2.9) rack (>= 2.0.9) From d99fb80f1f849775d8b30882689bcb9bacaec8e8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Jan 2025 09:38:14 -0500 Subject: [PATCH 09/15] build(deps-dev): bump faker from 3.4.2 to 3.5.1 (#4900) Bumps [faker](https://github.com/faker-ruby/faker) from 3.4.2 to 3.5.1. - [Release notes](https://github.com/faker-ruby/faker/releases) - [Changelog](https://github.com/faker-ruby/faker/blob/main/CHANGELOG.md) - [Commits](https://github.com/faker-ruby/faker/compare/v3.4.2...v3.5.1) --- updated-dependencies: - dependency-name: faker dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index ff212c49e4..aa5e52e94f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -223,7 +223,7 @@ GEM factory_bot_rails (6.4.4) factory_bot (~> 6.5) railties (>= 5.0.0) - faker (3.4.2) + faker (3.5.1) i18n (>= 1.8.11, < 2) faraday (1.10.4) faraday-em_http (~> 1.0) From dfd9d6404c4e8ace86a0b79802a51021a9045c0a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Jan 2025 09:55:52 -0500 Subject: [PATCH 10/15] build(deps): bump prawn-rails from 1.4.2 to 1.6.0 (#4901) Bumps [prawn-rails](https://github.com/cortiz/prawn-rails) from 1.4.2 to 1.6.0. - [Release notes](https://github.com/cortiz/prawn-rails/releases) - [Changelog](https://github.com/cortiz/prawn-rails/blob/master/CHANGELOG.md) - [Commits](https://github.com/cortiz/prawn-rails/compare/v1.4.2...v1.6.0) --- updated-dependencies: - dependency-name: prawn-rails dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index aa5e52e94f..c49473110a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -445,7 +445,7 @@ GEM parser (3.3.6.0) ast (~> 2.4.1) racc - pdf-core (0.9.0) + pdf-core (0.10.0) pdf-reader (2.12.0) Ascii85 (~> 1.0) afm (~> 0.2.1) @@ -454,11 +454,13 @@ GEM ttfunk pg (1.5.7) popper_js (2.11.8) - prawn (2.4.0) - pdf-core (~> 0.9.0) - ttfunk (~> 1.7) - prawn-rails (1.4.2) + prawn (2.5.0) + matrix (~> 0.4) + pdf-core (~> 0.10.0) + ttfunk (~> 1.8) + prawn-rails (1.6.0) actionview (>= 3.1.0) + activesupport (>= 3.1.0) prawn prawn-table prawn-table (0.2.2) @@ -675,7 +677,8 @@ GEM thor (1.3.2) tilt (2.2.0) timeout (0.4.1) - ttfunk (1.7.0) + ttfunk (1.8.0) + bigdecimal (~> 3.1) turbo-rails (2.0.10) actionpack (>= 6.0.0) railties (>= 6.0.0) From df38ad62c672694300888c922c0f4bd075db67df Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Jan 2025 10:25:29 -0500 Subject: [PATCH 11/15] build(deps-dev): bump rspec-rails from 7.0.1 to 7.1.0 (#4902) Bumps [rspec-rails](https://github.com/rspec/rspec-rails) from 7.0.1 to 7.1.0. - [Changelog](https://github.com/rspec/rspec-rails/blob/main/Changelog.md) - [Commits](https://github.com/rspec/rspec-rails/compare/v7.0.1...v7.1.0) --- updated-dependencies: - dependency-name: rspec-rails dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile | 2 +- Gemfile.lock | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index a0f606065e..00e2c4f275 100644 --- a/Gemfile +++ b/Gemfile @@ -152,7 +152,7 @@ group :development, :test do # Debugger which supports rdbg and Shopify Ruby LSP VSCode extension gem "debug", ">= 1.0.0" # RSpec behavioral testing framework for Rails. - gem "rspec-rails", "~> 7.0.1" + gem "rspec-rails", "~> 7.1.0" # Static analysis / linter. gem "rubocop" # Rails add-on for static analysis. diff --git a/Gemfile.lock b/Gemfile.lock index c49473110a..770dc98765 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -563,15 +563,15 @@ GEM rspec-core (~> 3.13.0) rspec-expectations (~> 3.13.0) rspec-mocks (~> 3.13.0) - rspec-core (3.13.1) + rspec-core (3.13.2) rspec-support (~> 3.13.0) rspec-expectations (3.13.3) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) - rspec-mocks (3.13.1) + rspec-mocks (3.13.2) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) - rspec-rails (7.0.1) + rspec-rails (7.1.0) actionpack (>= 7.0) activesupport (>= 7.0) railties (>= 7.0) @@ -579,7 +579,7 @@ GEM rspec-expectations (~> 3.13) rspec-mocks (~> 3.13) rspec-support (~> 3.13) - rspec-support (3.13.1) + rspec-support (3.13.2) rubocop (1.69.2) json (~> 2.3) language_server-protocol (>= 3.17.0) @@ -792,7 +792,7 @@ DEPENDENCIES recaptcha redis (~> 5.3) rolify (~> 6.0) - rspec-rails (~> 7.0.1) + rspec-rails (~> 7.1.0) rubocop rubocop-performance rubocop-rails (~> 2.25.1) From 4b29e2c58de82f8e25880bf3f693bfd4135c66b8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Jan 2025 11:52:10 -0500 Subject: [PATCH 12/15] build(deps-dev): bump knapsack_pro from 7.6.2 to 7.13.1 (#4903) Bumps [knapsack_pro](https://github.com/KnapsackPro/knapsack_pro-ruby) from 7.6.2 to 7.13.1. - [Changelog](https://github.com/KnapsackPro/knapsack_pro-ruby/blob/master/CHANGELOG.md) - [Commits](https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v7.6.2...v7.13.1) --- updated-dependencies: - dependency-name: knapsack_pro dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 770dc98765..ad727cbb74 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -336,7 +336,7 @@ GEM activerecord kaminari-core (= 1.2.2) kaminari-core (1.2.2) - knapsack_pro (7.6.2) + knapsack_pro (7.13.1) rake language_server-protocol (3.17.0.3) launchy (3.0.0) From 01c641a6377b56558b4869e6bf189334fc6649c7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Jan 2025 11:56:41 -0500 Subject: [PATCH 13/15] build(deps): bump icalendar from 2.10.2 to 2.10.3 (#4904) Bumps [icalendar](https://github.com/icalendar/icalendar) from 2.10.2 to 2.10.3. - [Changelog](https://github.com/icalendar/icalendar/blob/main/CHANGELOG.md) - [Commits](https://github.com/icalendar/icalendar/compare/v2.10.2...v2.10.3) --- updated-dependencies: - dependency-name: icalendar dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index ad727cbb74..ea293ac326 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -303,8 +303,9 @@ GEM multi_xml (>= 0.5.2) i18n (1.14.6) concurrent-ruby (~> 1.0) - icalendar (2.10.2) + icalendar (2.10.3) ice_cube (~> 0.16) + ostruct ice_cube (0.17.0) ice_nine (0.11.2) image_processing (1.13.0) @@ -438,6 +439,7 @@ GEM capybara (>= 1.1) rspec (>= 2.14) orm_adapter (0.5.0) + ostruct (0.6.1) paper_trail (15.2.0) activerecord (>= 6.1) request_store (~> 1.4) From 9a09a186488fa461cc372b94ccc9039ef5b6a877 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Jan 2025 12:01:24 -0500 Subject: [PATCH 14/15] build(deps): bump importmap-rails from 2.0.3 to 2.1.0 (#4905) Bumps [importmap-rails](https://github.com/rails/importmap-rails) from 2.0.3 to 2.1.0. - [Release notes](https://github.com/rails/importmap-rails/releases) - [Commits](https://github.com/rails/importmap-rails/compare/v2.0.3...v2.1.0) --- updated-dependencies: - dependency-name: importmap-rails dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile | 2 +- Gemfile.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 00e2c4f275..e43c80ea3a 100644 --- a/Gemfile +++ b/Gemfile @@ -221,4 +221,4 @@ end # Use Redis for Action Cable gem "redis", "~> 5.3" -gem "importmap-rails", "~> 2.0" +gem "importmap-rails", "~> 2.1" diff --git a/Gemfile.lock b/Gemfile.lock index ea293ac326..c064e89910 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -311,7 +311,7 @@ GEM image_processing (1.13.0) mini_magick (>= 4.9.5, < 5) ruby-vips (>= 2.0.17, < 3) - importmap-rails (2.0.3) + importmap-rails (2.1.0) actionpack (>= 6.0.0) activesupport (>= 6.0.0) railties (>= 6.0.0) @@ -762,7 +762,7 @@ DEPENDENCIES httparty icalendar image_processing - importmap-rails (~> 2.0) + importmap-rails (~> 2.1) jbuilder jwt kaminari From 2584427a66b983b70b8a21e8df822b0d67979fd8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 2 Jan 2025 13:01:45 -0500 Subject: [PATCH 15/15] build(deps): bump flipper-active_record from 1.3.0 to 1.3.2 (#4906) Bumps [flipper-active_record](https://github.com/flippercloud/flipper) from 1.3.0 to 1.3.2. - [Release notes](https://github.com/flippercloud/flipper/releases) - [Changelog](https://github.com/flippercloud/flipper/blob/main/Changelog.md) - [Commits](https://github.com/flippercloud/flipper/compare/v1.3.0...v1.3.2) --- updated-dependencies: - dependency-name: flipper-active_record dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index c064e89910..bd0ca81706 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -259,11 +259,11 @@ GEM ffi (1.17.0-x86_64-darwin) ffi (1.17.0-x86_64-linux-gnu) filterrific (5.2.5) - flipper (1.3.1) + flipper (1.3.2) concurrent-ruby (< 2) - flipper-active_record (1.3.0) - activerecord (>= 4.2, < 8) - flipper (~> 1.3.0) + flipper-active_record (1.3.2) + activerecord (>= 4.2, < 9) + flipper (~> 1.3.2) flipper-ui (1.3.1) erubi (>= 1.0.0, < 2.0.0) flipper (~> 1.3.1) @@ -678,7 +678,7 @@ GEM execjs (>= 0.3.0, < 3) thor (1.3.2) tilt (2.2.0) - timeout (0.4.1) + timeout (0.4.3) ttfunk (1.8.0) bigdecimal (~> 3.1) turbo-rails (2.0.10)