mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
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:
@@ -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
|
||||
|
||||
@@ -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") }
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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) }
|
||||
|
||||
Reference in New Issue
Block a user