Sha256: 0a68ff7d80b32d5319d64a949fa53b7907cf0b07890b744f6a82ed1a4dab740d
Contents?: true
Size: 809 Bytes
Versions: 11
Compression:
Stored size: 809 Bytes
Contents
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
11 entries across 11 versions & 1 rubygems