Sha256: 3ab46b2535464716722ce3964f38369424907be88031dda2b8f6f11de5d9972d

Contents?: true

Size: 695 Bytes

Versions: 4

Compression:

Stored size: 695 Bytes

Contents

require 'test_helper'
require 'active_record/database_validations/varchar_191'

class Varchar < ActiveRecord::Base; end

class VarcharDefaultSizeTest < Minitest::Test
  def test_field_was_created_with_191_characters
    ActiveRecord::Migration.suppress_messages do
      ActiveRecord::Migration.create_table(:varchars, force: true, options: "CHARACTER SET utf8mb4") do |t|
        t.string :string
      end

      # This will fail if the field is more than 767 bytes.
      ActiveRecord::Migration.add_index(:varchars, :string, unique: true)
    end

    assert_match(/\Autf8mb4_/, Varchar.columns_hash['string'].collation)
    assert_equal(191, Varchar.columns_hash['string'].limit)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
activerecord-databasevalidations-1.0.1 test/varchar_default_size_test.rb
activerecord-databasevalidations-1.0.0 test/varchar_default_size_test.rb
activerecord-databasevalidations-0.5.1 test/varchar_default_size_test.rb
activerecord-databasevalidations-0.5.0 test/varchar_default_size_test.rb