Sha256: cb999c76c600ff886fad03b93587bdb9756dc58c3045dcff0344c1493c0f774a

Contents?: true

Size: 1.39 KB

Versions: 1

Compression:

Stored size: 1.39 KB

Contents

require 'spec_helper'

describe ActiveRecord::MySQL::Strict::Validation::TextValidation do
  describe :apply do
    context 'for model without other validations' do
      let(:model) { strict_model 'User' }

      context 'with field with default limit' do
        before do
          run_migration do
            create_table(:users, force: true) { |t| t.text :bio }
          end
        end

        context 'with field value exceeding limit' do
          subject { model.new(bio: '*' * 70000) }
          it { should_not be_valid }
        end

        context 'with field value not exceeding limit' do
          subject { model.new(bio: '*' * 4000) }
          it { should be_valid }
        end
      end

      context 'with field with custom limit' do
        before do
          run_migration do
            create_table(:users, force: true) { |t| t.text :bio, limit: 10000 }
          end
        end

        context 'with field value exceeding default limit' do
          subject { model.new(bio: '*' * 70000) }
          it { should_not be_valid }
        end

        context 'with field value exceeding custom limit' do
          subject { model.new(bio: '*' * 12000) }
          it { should_not be_valid }
        end

        context 'with field value not exceeding custom limit' do
          subject { model.new(bio: '*' * 4000) }
          it { should be_valid }
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
activerecord_mysql_strict-0.2.1 spec/activerecord_mysql_strict/validation/text_validation_spec.rb