Revert "Validate voucher code length doesn't exceed the database column length i.e. 255 characters"

This reverts commit 0d0df82522.
This commit is contained in:
Cillian O'Ruanaidh
2023-08-04 10:24:21 +01:00
parent 9eba266efc
commit d026438edc
4 changed files with 2 additions and 6 deletions

View File

@@ -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

View File

@@ -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") }

View File

@@ -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)

View File

@@ -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) }