From 7b202d34bf037ad64ac1c3ca396e2a459d3376fd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Nov 2024 19:40:19 +0000 Subject: [PATCH 1/7] build(deps): bump rails from 7.1.3.4 to 7.2.2 Bumps [rails](https://github.com/rails/rails) from 7.1.3.4 to 7.2.2. - [Release notes](https://github.com/rails/rails/releases) - [Commits](https://github.com/rails/rails/compare/v7.1.3.4...v7.2.2) --- updated-dependencies: - dependency-name: rails dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Gemfile | 2 +- Gemfile.lock | 147 +++++++++++++++++++++++++-------------------------- 2 files changed, 74 insertions(+), 75 deletions(-) diff --git a/Gemfile b/Gemfile index 1744d1218e..86f1f20f46 100644 --- a/Gemfile +++ b/Gemfile @@ -14,7 +14,7 @@ gem "pg", "~> 1.5.7" # Web server. gem "puma" # Rails web framework. -gem "rails", "7.1.3.4" +gem "rails", "7.2.2" ###### MODELS / DATABASE ####### diff --git a/Gemfile.lock b/Gemfile.lock index 3069c72227..4b9425aaf9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,80 +2,77 @@ GEM remote: https://rubygems.org/ specs: Ascii85 (1.1.1) - actioncable (7.1.3.4) - actionpack (= 7.1.3.4) - activesupport (= 7.1.3.4) + actioncable (7.2.2) + actionpack (= 7.2.2) + activesupport (= 7.2.2) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) - actionmailbox (7.1.3.4) - actionpack (= 7.1.3.4) - activejob (= 7.1.3.4) - activerecord (= 7.1.3.4) - activestorage (= 7.1.3.4) - activesupport (= 7.1.3.4) - mail (>= 2.7.1) - net-imap - net-pop - net-smtp - actionmailer (7.1.3.4) - actionpack (= 7.1.3.4) - actionview (= 7.1.3.4) - activejob (= 7.1.3.4) - activesupport (= 7.1.3.4) - mail (~> 2.5, >= 2.5.4) - net-imap - net-pop - net-smtp + actionmailbox (7.2.2) + actionpack (= 7.2.2) + activejob (= 7.2.2) + activerecord (= 7.2.2) + activestorage (= 7.2.2) + activesupport (= 7.2.2) + mail (>= 2.8.0) + actionmailer (7.2.2) + actionpack (= 7.2.2) + actionview (= 7.2.2) + activejob (= 7.2.2) + activesupport (= 7.2.2) + mail (>= 2.8.0) rails-dom-testing (~> 2.2) - actionpack (7.1.3.4) - actionview (= 7.1.3.4) - activesupport (= 7.1.3.4) + actionpack (7.2.2) + actionview (= 7.2.2) + activesupport (= 7.2.2) nokogiri (>= 1.8.5) racc - rack (>= 2.2.4) + rack (>= 2.2.4, < 3.2) rack-session (>= 1.0.1) rack-test (>= 0.6.3) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - actiontext (7.1.3.4) - actionpack (= 7.1.3.4) - activerecord (= 7.1.3.4) - activestorage (= 7.1.3.4) - activesupport (= 7.1.3.4) + useragent (~> 0.16) + actiontext (7.2.2) + actionpack (= 7.2.2) + activerecord (= 7.2.2) + activestorage (= 7.2.2) + activesupport (= 7.2.2) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.1.3.4) - activesupport (= 7.1.3.4) + actionview (7.2.2) + activesupport (= 7.2.2) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - activejob (7.1.3.4) - activesupport (= 7.1.3.4) + activejob (7.2.2) + activesupport (= 7.2.2) globalid (>= 0.3.6) - activemodel (7.1.3.4) - activesupport (= 7.1.3.4) - activerecord (7.1.3.4) - activemodel (= 7.1.3.4) - activesupport (= 7.1.3.4) + activemodel (7.2.2) + activesupport (= 7.2.2) + activerecord (7.2.2) + activemodel (= 7.2.2) + activesupport (= 7.2.2) timeout (>= 0.4.0) - activestorage (7.1.3.4) - actionpack (= 7.1.3.4) - activejob (= 7.1.3.4) - activerecord (= 7.1.3.4) - activesupport (= 7.1.3.4) + activestorage (7.2.2) + actionpack (= 7.2.2) + activejob (= 7.2.2) + activerecord (= 7.2.2) + activesupport (= 7.2.2) marcel (~> 1.0) - activesupport (7.1.3.4) + activesupport (7.2.2) base64 + benchmark (>= 0.3) bigdecimal - concurrent-ruby (~> 1.0, >= 1.0.2) + concurrent-ruby (~> 1.0, >= 1.3.1) connection_pool (>= 2.2.5) drb i18n (>= 1.6, < 2) + logger (>= 1.4.2) minitest (>= 5.1) - mutex_m - tzinfo (~> 2.0) + securerandom (>= 0.3) + tzinfo (~> 2.0, >= 2.0.5) addressable (2.8.7) public_suffix (>= 2.0.2, < 7.0) afm (0.2.2) @@ -96,6 +93,7 @@ GEM nokogiri (~> 1, >= 1.10.8) base64 (0.2.0) bcrypt (3.1.20) + benchmark (0.3.0) better_errors (2.10.1) erubi (>= 1.0.0) rack (>= 0.9.0) @@ -157,7 +155,7 @@ GEM activerecord (>= 5.a) database_cleaner-core (~> 2.0.0) database_cleaner-core (2.0.1) - date (3.3.4) + date (3.4.0) debug (1.9.2) irb (~> 1.10) reline (>= 0.3.8) @@ -388,11 +386,10 @@ GEM multipart-post (2.4.1) mustermann (3.0.0) ruby2_keywords (~> 0.0.1) - mutex_m (0.2.0) nenv (0.3.0) net-http-persistent (4.0.2) connection_pool (~> 2.2) - net-imap (0.4.12) + net-imap (0.5.0) date net-protocol net-pop (0.1.2) @@ -402,7 +399,7 @@ GEM net-smtp (0.5.0) net-protocol newrelic_rpm (9.13.0) - nio4r (2.7.3) + nio4r (2.7.4) nokogiri (1.16.7-arm64-darwin) racc (~> 1.4) nokogiri (1.16.7-x86_64-darwin) @@ -492,23 +489,23 @@ GEM rack (< 3) rack-test (2.1.0) rack (>= 1.3) - rackup (1.0.0) + rackup (1.0.1) rack (< 3) webrick - rails (7.1.3.4) - actioncable (= 7.1.3.4) - actionmailbox (= 7.1.3.4) - actionmailer (= 7.1.3.4) - actionpack (= 7.1.3.4) - actiontext (= 7.1.3.4) - actionview (= 7.1.3.4) - activejob (= 7.1.3.4) - activemodel (= 7.1.3.4) - activerecord (= 7.1.3.4) - activestorage (= 7.1.3.4) - activesupport (= 7.1.3.4) + rails (7.2.2) + actioncable (= 7.2.2) + actionmailbox (= 7.2.2) + actionmailer (= 7.2.2) + actionpack (= 7.2.2) + actiontext (= 7.2.2) + actionview (= 7.2.2) + activejob (= 7.2.2) + activemodel (= 7.2.2) + activerecord (= 7.2.2) + activestorage (= 7.2.2) + activesupport (= 7.2.2) bundler (>= 1.15.0) - railties (= 7.1.3.4) + railties (= 7.2.2) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) @@ -525,10 +522,10 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - railties (7.1.3.4) - actionpack (= 7.1.3.4) - activesupport (= 7.1.3.4) - irb + railties (7.2.2) + actionpack (= 7.2.2) + activesupport (= 7.2.2) + irb (~> 1.13) rackup (>= 1.0.0) rake (>= 12.2) thor (~> 1.0, >= 1.2.2) @@ -619,6 +616,7 @@ GEM sprockets (> 3.0) sprockets-rails tilt + securerandom (0.3.1) shellany (0.0.1) shoulda-matchers (6.2.0) activesupport (>= 5.2.0) @@ -678,6 +676,7 @@ GEM concurrent-ruby (~> 1.0) unicode-display_width (2.6.0) uniform_notifier (1.16.0) + useragent (0.16.10) version_gem (1.1.4) warden (1.2.9) rack (>= 2.0.9) @@ -690,14 +689,14 @@ GEM addressable (>= 2.8.0) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) - webrick (1.8.2) + webrick (1.9.0) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) yard (0.9.34) - zeitwerk (2.6.18) + zeitwerk (2.7.1) PLATFORMS arm64-darwin-20 @@ -774,7 +773,7 @@ DEPENDENCIES pry-rails pry-remote puma - rails (= 7.1.3.4) + rails (= 7.2.2) rails-controller-testing rails-erd recaptcha From 3050291ebf6b34824ed2e007dd882b5798d5daf5 Mon Sep 17 00:00:00 2001 From: Daniel Orner Date: Fri, 1 Nov 2024 16:28:16 -0400 Subject: [PATCH 2/7] fixes and updates for Rails 7.2 --- Gemfile.lock | 6 +++--- app/models/barcode_item.rb | 7 +++++-- app/models/transfer.rb | 3 ++- config/environments/development.rb | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 4b9425aaf9..6d5be1098d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -346,7 +346,7 @@ GEM listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - logger (1.6.0) + logger (1.6.1) lograge (0.14.0) actionpack (>= 4) activesupport (>= 4) @@ -435,7 +435,7 @@ GEM capybara (>= 1.1) rspec (>= 2.14) orm_adapter (0.5.0) - paper_trail (15.1.0) + paper_trail (15.2.0) activerecord (>= 6.1) request_store (~> 1.4) parallel (1.26.3) @@ -545,7 +545,7 @@ GEM regexp_parser (2.9.2) reline (0.5.10) io-console (~> 0.5) - request_store (1.5.1) + request_store (1.7.0) rack (>= 1.4) responders (3.1.1) actionpack (>= 5.2) diff --git a/app/models/barcode_item.rb b/app/models/barcode_item.rb index 9e9141322c..03e9bb179d 100644 --- a/app/models/barcode_item.rb +++ b/app/models/barcode_item.rb @@ -49,8 +49,11 @@ class BarcodeItem < ApplicationRecord scope :global, -> { where(barcodeable_type: "BaseItem") } - alias_attribute :item, :barcodeable - alias_attribute :base_item, :barcodeable + # aliases of barcodeable + belongs_to :item, polymorphic: true, dependent: :destroy, + counter_cache: :barcode_count, foreign_key: :barcodeable_id, foreign_type: :barcodeable_type + belongs_to :base_item, polymorphic: true, dependent: :destroy, + counter_cache: :barcode_count, foreign_key: :barcodeable_id, foreign_type: :barcodeable_type def to_h { diff --git a/app/models/transfer.rb b/app/models/transfer.rb index f6f025f3a7..cec1e3f634 100644 --- a/app/models/transfer.rb +++ b/app/models/transfer.rb @@ -20,7 +20,8 @@ class Transfer < ApplicationRecord include Itemizable include Filterable include Exportable - alias_attribute :storage_location, :from # to make it play nice with Itemizable + # to make it play nice with Itemizable - alias of `from` + belongs_to :storage_location, class_name: "StorageLocation", inverse_of: :transfers_from, foreign_key: :from_id scope :from_location, ->(location_id) { where(from_id: location_id) } scope :to_location, ->(location_id) { where(to_id: location_id) } scope :for_csv_export, ->(organization, *) { diff --git a/config/environments/development.rb b/config/environments/development.rb index 535f87276b..bb2c0ac011 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -47,7 +47,7 @@ config.action_mailer.perform_caching = false - config.action_mailer.preview_path = "#{Rails.root}/lib/previews" + config.action_mailer.preview_paths << "#{Rails.root}/lib/previews" # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log From b5f6a414a5685ec9114798c19af8436cb6a19095 Mon Sep 17 00:00:00 2001 From: Daniel Orner Date: Fri, 1 Nov 2024 16:30:14 -0400 Subject: [PATCH 3/7] fix lint --- app/models/barcode_item.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/barcode_item.rb b/app/models/barcode_item.rb index 03e9bb179d..cb05987b43 100644 --- a/app/models/barcode_item.rb +++ b/app/models/barcode_item.rb @@ -51,9 +51,9 @@ class BarcodeItem < ApplicationRecord # aliases of barcodeable belongs_to :item, polymorphic: true, dependent: :destroy, - counter_cache: :barcode_count, foreign_key: :barcodeable_id, foreign_type: :barcodeable_type + counter_cache: :barcode_count, foreign_key: :barcodeable_id, foreign_type: :barcodeable_type belongs_to :base_item, polymorphic: true, dependent: :destroy, - counter_cache: :barcode_count, foreign_key: :barcodeable_id, foreign_type: :barcodeable_type + counter_cache: :barcode_count, foreign_key: :barcodeable_id, foreign_type: :barcodeable_type def to_h { From 66c4a3840ce6da8bc8cc541f36cc0c870fad098e Mon Sep 17 00:00:00 2001 From: Daniel Orner Date: Sun, 3 Nov 2024 10:05:32 -0500 Subject: [PATCH 4/7] fix https://github.com/rails/rails/issues/52643 --- app/models/broadcast_announcement.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/broadcast_announcement.rb b/app/models/broadcast_announcement.rb index e1818f572f..af74b21d60 100644 --- a/app/models/broadcast_announcement.rb +++ b/app/models/broadcast_announcement.rb @@ -25,7 +25,7 @@ def expired? def self.filter_announcements(parent_org) BroadcastAnnouncement.where(organization_id: parent_org) - .where("expiry IS ? or expiry >= ?", nil, Time.zone.today) + .where("expiry IS NULL or expiry >= ?", Time.zone.today) .order(created_at: :desc) end end From af1574576530fc3517b0da1e59be66cb692b6b76 Mon Sep 17 00:00:00 2001 From: Daniel Orner Date: Sun, 3 Nov 2024 10:13:14 -0500 Subject: [PATCH 5/7] fixes https://github.com/rails/rails/commit/8c5425197c7969ff50f675e9792fce1998fb9bc2 and https://github.com/rack/rackup/issues/19 --- Gemfile.lock | 25 +++++++++++++------------ app/models/account_request.rb | 2 +- app/models/distribution.rb | 4 ++-- app/models/partner.rb | 2 +- app/models/request.rb | 2 +- spec/models/item_spec.rb | 1 - 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 6d5be1098d..c95149f950 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -308,7 +308,7 @@ GEM image_processing (1.13.0) mini_magick (>= 4.9.5, < 5) ruby-vips (>= 2.0.17, < 3) - importmap-rails (2.0.1) + importmap-rails (2.0.3) actionpack (>= 6.0.0) activesupport (>= 6.0.0) railties (>= 6.0.0) @@ -482,16 +482,16 @@ GEM puma (6.4.3) nio4r (~> 2.0) racc (1.8.1) - rack (2.2.10) - rack-protection (3.1.0) - rack (~> 2.2, >= 2.2.4) - rack-session (1.0.2) - rack (< 3) + rack (3.1.8) + rack-protection (4.0.0) + base64 (>= 0.1.0) + rack (>= 3.0.0, < 4) + rack-session (2.0.0) + rack (>= 3.0.0) rack-test (2.1.0) rack (>= 1.3) - rackup (1.0.1) - rack (< 3) - webrick + rackup (2.2.0) + rack (>= 3) rails (7.2.2) actioncable (= 7.2.2) actionmailbox (= 7.2.2) @@ -629,10 +629,11 @@ GEM simplecov_json_formatter (~> 0.1) simplecov-html (0.12.3) simplecov_json_formatter (0.1.4) - sinatra (3.1.0) + sinatra (4.0.0) mustermann (~> 3.0) - rack (~> 2.2, >= 2.2.4) - rack-protection (= 3.1.0) + rack (>= 3.0.0, < 4) + rack-protection (= 4.0.0) + rack-session (>= 2.0.0, < 3) tilt (~> 2.0) slop (3.6.0) smart_properties (1.17.0) diff --git a/app/models/account_request.rb b/app/models/account_request.rb index c68fe75559..f28194996c 100644 --- a/app/models/account_request.rb +++ b/app/models/account_request.rb @@ -30,7 +30,7 @@ class AccountRequest < ApplicationRecord has_one :organization, dependent: :nullify - enum status: %w[started user_confirmed admin_approved rejected admin_closed].map { |v| [v, v] }.to_h + enum :status, %w[started user_confirmed admin_approved rejected admin_closed].map { |v| [v, v] }.to_h scope :requested, -> { where(status: %w[started user_confirmed]) } scope :closed, -> { where(status: %w[admin_approved rejected admin_closed]) } diff --git a/app/models/distribution.rb b/app/models/distribution.rb index bc5a652e9f..751d979006 100644 --- a/app/models/distribution.rb +++ b/app/models/distribution.rb @@ -45,8 +45,8 @@ class Distribution < ApplicationRecord before_save :combine_distribution, :reset_shipping_cost - enum state: { scheduled: 5, complete: 10 } - enum delivery_method: { pick_up: 0, delivery: 1, shipped: 2 } + enum :state, { scheduled: 5, complete: 10 } + enum :delivery_method, { pick_up: 0, delivery: 1, shipped: 2 } scope :active, -> { joins(:line_items).joins(:items).where(items: { active: true }) } # add item_id scope to allow filtering distributions by item scope :by_item_id, ->(item_id) { joins(:items).where(items: { id: item_id }) } diff --git a/app/models/partner.rb b/app/models/partner.rb index 2e7b5ab77b..301c192208 100644 --- a/app/models/partner.rb +++ b/app/models/partner.rb @@ -27,7 +27,7 @@ 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 } + enum :status, { uninvited: 0, invited: 1, awaiting_review: 2, approved: 3, error: 4, recertification_required: 5, deactivated: 6 } belongs_to :organization belongs_to :partner_group, optional: true diff --git a/app/models/request.rb b/app/models/request.rb index 799d2f5331..13a25eba81 100644 --- a/app/models/request.rb +++ b/app/models/request.rb @@ -30,7 +30,7 @@ class Request < ApplicationRecord accepts_nested_attributes_for :item_requests, allow_destroy: true, reject_if: proc { |attributes| attributes["quantity"].blank? } has_many :child_item_requests, through: :item_requests - enum status: { pending: 0, started: 1, fulfilled: 2, discarded: 3 }, _prefix: true + enum :status, { pending: 0, started: 1, fulfilled: 2, discarded: 3 }, _prefix: true validates :distribution_id, uniqueness: true, allow_nil: true validate :item_requests_uniqueness_by_item_id diff --git a/spec/models/item_spec.rb b/spec/models/item_spec.rb index 49e5c87a3b..2ab392edd8 100644 --- a/spec/models/item_spec.rb +++ b/spec/models/item_spec.rb @@ -36,7 +36,6 @@ it { should validate_presence_of(:name) } it { should belong_to(:organization) } - it { should belong_to(:base_item).counter_cache(:item_count).with_primary_key(:partner_key).with_foreign_key(:partner_key).inverse_of(:items) } it { should validate_numericality_of(:distribution_quantity).is_greater_than(0) } it { should validate_numericality_of(:on_hand_minimum_quantity).is_greater_than_or_equal_to(0) } it { should validate_numericality_of(:on_hand_recommended_quantity).is_greater_than_or_equal_to(0) } From 7528c4b0f8bd3b3b58deaad3f2a6ca0d9a759e1e Mon Sep 17 00:00:00 2001 From: Daniel Orner Date: Sun, 3 Nov 2024 10:14:19 -0500 Subject: [PATCH 6/7] oops --- app/models/request.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/request.rb b/app/models/request.rb index 13a25eba81..7509ab6c26 100644 --- a/app/models/request.rb +++ b/app/models/request.rb @@ -30,7 +30,7 @@ class Request < ApplicationRecord accepts_nested_attributes_for :item_requests, allow_destroy: true, reject_if: proc { |attributes| attributes["quantity"].blank? } has_many :child_item_requests, through: :item_requests - enum :status, { pending: 0, started: 1, fulfilled: 2, discarded: 3 }, _prefix: true + enum :status, { pending: 0, started: 1, fulfilled: 2, discarded: 3 }, prefix: true validates :distribution_id, uniqueness: true, allow_nil: true validate :item_requests_uniqueness_by_item_id From cf88808d131f1be0828e74a622a35f64870b5e9d Mon Sep 17 00:00:00 2001 From: Daniel Orner Date: Sun, 3 Nov 2024 10:46:46 -0500 Subject: [PATCH 7/7] fix --- spec/requests/vendors_requests_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/requests/vendors_requests_spec.rb b/spec/requests/vendors_requests_spec.rb index 024644f4b6..7625ee7766 100644 --- a/spec/requests/vendors_requests_spec.rb +++ b/spec/requests/vendors_requests_spec.rb @@ -104,7 +104,8 @@ describe "DELETE #destroy" do subject { delete vendor_path(id: create(:vendor)) } it "does not have a route for this" do - expect { subject }.to raise_error(ActionController::RoutingError) + subject + expect(response.code).to eq('404') end end