Skip to content

Commit

Permalink
Merge pull request #5541 from solidusio/elia+rainer/deprecate-named-type
Browse files Browse the repository at this point in the history
Deprecate `Spree::NamedType`
  • Loading branch information
elia authored Dec 19, 2023
2 parents e281b6c + af0c7d3 commit 7afb2cd
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 4 deletions.
2 changes: 2 additions & 0 deletions core/app/models/concerns/spree/named_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ module NamedType
extend ActiveSupport::Concern

included do
Spree.deprecator.warn "Spree::NamedType is deprecated. Please set scopes and validations locally instead.", caller

scope :active, -> { where(active: true) }
default_scope -> { order(arel_table[:name].lower) }

Expand Down
5 changes: 4 additions & 1 deletion core/app/models/spree/refund_reason.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

module Spree
class RefundReason < Spree::Base
include Spree::NamedType
scope :active, -> { where(active: true) }
default_scope -> { order(arel_table[:name].lower) }

validates :name, presence: true, uniqueness: { case_sensitive: false, allow_blank: true }

RETURN_PROCESSING_REASON = 'Return processing'

Expand Down
5 changes: 4 additions & 1 deletion core/app/models/spree/reimbursement_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

module Spree
class ReimbursementType < Spree::Base
include Spree::NamedType
scope :active, -> { where(active: true) }
default_scope -> { order(arel_table[:name].lower) }

validates :name, presence: true, uniqueness: { case_sensitive: false, allow_blank: true }

ORIGINAL = 'original'

Expand Down
5 changes: 4 additions & 1 deletion core/app/models/spree/return_reason.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

module Spree
class ReturnReason < Spree::Base
include Spree::NamedType
scope :active, -> { where(active: true) }
default_scope -> { order(arel_table[:name].lower) }

validates :name, presence: true, uniqueness: { case_sensitive: false, allow_blank: true }

has_many :return_authorizations

Expand Down
5 changes: 4 additions & 1 deletion core/app/models/spree/store_credit_reason.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# frozen_string_literal: true

class Spree::StoreCreditReason < Spree::Base
include Spree::NamedType
scope :active, -> { where(active: true) }
default_scope -> { order(arel_table[:name].lower) }

validates :name, presence: true, uniqueness: { case_sensitive: false, allow_blank: true }

has_many :store_credit_events, inverse_of: :store_credit_reason

Expand Down

0 comments on commit 7afb2cd

Please sign in to comment.