Sha256: 88a2eb4f537e2c4a52b579cd62e0cc4c55b41ba349cf6ec581e75a37c46d650a
Contents?: true
Size: 840 Bytes
Versions: 48
Compression:
Stored size: 840 Bytes
Contents
# frozen_string_literal: true require 'rails_helper' RSpec.describe Spree::Validations::DbMaximumLengthValidator, type: :model do with_model 'LimitedProduct', scope: :all do table do |t| t.string :slug, limit: 255 end model do validates_with Spree::Validations::DbMaximumLengthValidator, field: :slug end end let(:record) { LimitedProduct.new(slug: slug) } context "when slug is below limit" do let(:slug) { 'a' * 255 } it 'should be valid' do expect(record).to be_valid expect(record.errors).to be_empty end end context "when slug is too long" do let(:slug) { 'a' * 256 } it 'should be invalid and set error' do expect(record).not_to be_valid expect(record.errors[:slug]).to include(I18n.t("errors.messages.too_long", count: 255)) end end end
Version data entries
48 entries across 48 versions & 2 rubygems