Sha256: 8b0b527902d78e7e25860b70344a4e1ff2f2c1c89636bc32193190c06f148d31

Contents?: true

Size: 1.63 KB

Versions: 2

Compression:

Stored size: 1.63 KB

Contents

FactoryBot.define do
  factory :post_one, class: Hash do
    model_name { 'Post' }
    attributes do
      [
        {
          'column_name' => 'title',
          'column_type' => 'string',
          'unique' => true,
          'index' => 'default',
          'index_algorithm' => 'default'
        },
        {
          'column_name' => 'tags',
          'column_type' => 'array',
          'nullable' => false,
          'default' => '[]',
          'index' => 'gin',
          'index_algorithm' => 'concurrently',
          'unique' => true
        },
        {
          'column_name' => 'content',
          'column_type' => 'text',
          'nullable' => false,
          "index" => "gist",
          "index_algorithm" => "default"
        },
        {
          'column_name' => 'likes_count',
          'column_type' => 'integer',
          'nullable' => true,
          'default' => '0',
        },
        {
          'column_name' => 'score',
          'column_type' => 'float',
        },
        {
          'column_name' => 'metadata',
          'column_type' => 'jsonb',
          'nullable' => false,
          'default' => '{}',
        },
      ]
    end
  end

  factory :post_two, class: "Hash" do
    model_name { 'Post' }
    attributes do
      [
        {
          'column_name' => 'user',
          'column_type' => 'references',
          'foreign_key' => true
        }
      ]
    end
  end

  factory :post_three, class: "Hash" do
    model_name { 'Post' }
    attributes do
      [
        {
          'column_name' => 'user',
          'column_type' => 'references',
          'foreign_key' => false
        }
      ]
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
localtower-2.0.1 spec/factories/model.rb
localtower-2.0.0 spec/factories/model.rb