Sha256: 4c952573f3f8067f13440135179c2357860d42814a86222532740cd14eeb3fe4

Contents?: true

Size: 693 Bytes

Versions: 7

Compression:

Stored size: 693 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

7 entries across 7 versions & 1 rubygems

Version Path
activerecord-databasevalidations-0.4.0 test/varchar_default_size_test.rb
activerecord-databasevalidations-0.3.1 test/varchar_default_size_test.rb
activerecord-databasevalidations-0.3.0 test/varchar_default_size_test.rb
activerecord-databasevalidations-0.2.6 test/varchar_default_size_test.rb
activerecord-databasevalidations-0.2.5 test/varchar_default_size_test.rb
activerecord-databasevalidations-0.2.4 test/varchar_default_size_test.rb
activerecord-databasevalidations-0.2.3 test/varchar_default_size_test.rb