From d026438edcd7f0211f1528dcef0318176b414fa1 Mon Sep 17 00:00:00 2001 From: Cillian O'Ruanaidh Date: Fri, 4 Aug 2023 10:24:21 +0100 Subject: [PATCH] Revert "Validate voucher code length doesn't exceed the database column length i.e. 255 characters" This reverts commit 0d0df82522599f4ac6cd465d5b6c7225683d8e92. --- app/models/application_record.rb | 2 -- app/models/spree/product_property.rb | 2 +- app/models/voucher.rb | 3 +-- spec/models/voucher_spec.rb | 1 - 4 files changed, 2 insertions(+), 6 deletions(-) diff --git a/app/models/application_record.rb b/app/models/application_record.rb index c5ebb8d385..7870e01a56 100644 --- a/app/models/application_record.rb +++ b/app/models/application_record.rb @@ -9,8 +9,6 @@ class ApplicationRecord < ActiveRecord::Base include ArelHelpers::Aliases include ArelHelpers::JoinAssociation - STRING_COLUMN_LIMIT = 255 - self.abstract_class = true def self.image_service diff --git a/app/models/spree/product_property.rb b/app/models/spree/product_property.rb index 0f7d87a189..2f67dbcd9b 100644 --- a/app/models/spree/product_property.rb +++ b/app/models/spree/product_property.rb @@ -6,7 +6,7 @@ module Spree belongs_to :property, class_name: 'Spree::Property' validates :property, presence: true - validates :value, length: { maximum: STRING_COLUMN_LIMIT } + validates :value, length: { maximum: 255 } default_scope -> { order("#{table_name}.position") } diff --git a/app/models/voucher.rb b/app/models/voucher.rb index 62eb661be1..d309786513 100644 --- a/app/models/voucher.rb +++ b/app/models/voucher.rb @@ -10,8 +10,7 @@ class Voucher < ApplicationRecord class_name: 'Spree::Adjustment', dependent: :nullify - validates :code, length: { maximum: STRING_COLUMN_LIMIT }, - presence: true, uniqueness: { scope: :enterprise_id } + validates :code, presence: true, uniqueness: { scope: :enterprise_id } validates :amount, presence: true, numericality: { greater_than: 0 } def code=(value) diff --git a/spec/models/voucher_spec.rb b/spec/models/voucher_spec.rb index 5d8c4844e9..e9f36496e1 100644 --- a/spec/models/voucher_spec.rb +++ b/spec/models/voucher_spec.rb @@ -21,7 +21,6 @@ describe Voucher do describe 'validations' do subject { build(:voucher, code: 'new_code', enterprise: enterprise) } - it { is_expected.to validate_length_of(:code).is_at_most(255) } it { is_expected.to validate_presence_of(:code) } it { is_expected.to validate_uniqueness_of(:code).scoped_to(:enterprise_id) } it { is_expected.to validate_presence_of(:amount) }