From 41dbb42d89f510f56087f29bcae1422d2f80e9f7 Mon Sep 17 00:00:00 2001 From: Andrew Roth Date: Thu, 12 Dec 2024 16:17:50 -0500 Subject: [PATCH] fix gift card type regex don't filter out certificate column in gift cards --- app/models/gift_card_type.rb | 2 +- app/models/issuance.rb | 2 +- config/initializers/filter_parameter_logging.rb | 2 +- db/schema.rb | 3 +++ 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/models/gift_card_type.rb b/app/models/gift_card_type.rb index 1ffe0ca..2f2f0d6 100644 --- a/app/models/gift_card_type.rb +++ b/app/models/gift_card_type.rb @@ -1,7 +1,7 @@ class GiftCardType < ApplicationRecord include HasNumbering - validates :numbering, presence: true, format: { with: /^[^x]*x+[^x]*$/ } + validates :numbering, presence: true, format: { with: /\A[^x]*x+[^x]*\z/ } def to_s label diff --git a/app/models/issuance.rb b/app/models/issuance.rb index 10df740..0e16be9 100644 --- a/app/models/issuance.rb +++ b/app/models/issuance.rb @@ -77,7 +77,7 @@ def largest_existing_number_in_certificate # pulling all allocated certificate ids instead of a regex isn't ideal, but there shouldn't be many, if any, times there # are previewed gift cards issuances while another one is being previewed - existing_matching_certificates += Issuance.preview.pluck(:allocated_certificates).collect do |allocated_certificates| + existing_matching_certificates += Issuance.previewing.pluck(:allocated_certificates).collect do |allocated_certificates| allocated_certificates.split(CERTIFICATE_DISPLAY_SEPARATOR).find_all { |certificate| certificate =~ numbering_regex } end.flatten diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb index c010b83..9794e5c 100644 --- a/config/initializers/filter_parameter_logging.rb +++ b/config/initializers/filter_parameter_logging.rb @@ -4,5 +4,5 @@ # Use this to limit dissemination of sensitive information. # See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors. Rails.application.config.filter_parameters += [ - :passw, :email, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn + :passw, :email, :secret, :token, :_key, :crypt, :salt, :otp, :ssn ] diff --git a/db/schema.rb b/db/schema.rb index d858b07..c76fe44 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -12,7 +12,10 @@ ActiveRecord::Schema[7.2].define(version: 2024_11_26_111253) do # These are extensions that must be enabled in order to support this database + enable_extension "pg_stat_statements" + enable_extension "pgcrypto" enable_extension "plpgsql" + enable_extension "uuid-ossp" create_table "active_admin_comments", force: :cascade do |t| t.string "namespace"