Sha256: c9574567ff30e6610e8fd11ff97d585db7fee547712b8e58c96c3ef1dda3f1f5

Contents?: true

Size: 1.83 KB

Versions: 11

Compression:

Stored size: 1.83 KB

Contents

Feature: Migration

  Background:
    Given I generate a new rails application
    And I write to "app/models/user.rb" with:
      """
      class User < ActiveRecord::Base; end
      """

  Scenario: Vintage syntax
    When I write to "db/migrate/01_add_attachment_to_users.rb" with:
      """
      class AddAttachmentToUsers < ActiveRecord::Migration
        def self.up
          create_table :users do |t|
            t.has_attached_file :avatar
          end
        end

        def self.down
          drop_attached_file :users, :avatar
        end
      end
      """
    And I run a migration
    Then I should have attachment columns for "avatar"

    When I rollback a migration
    Then I should not have attachment columns for "avatar"

  Scenario: New syntax with create_table
    When I write to "db/migrate/01_add_attachment_to_users.rb" with:
      """
      class AddAttachmentToUsers < ActiveRecord::Migration
        def self.up
          create_table :users do |t|
            t.attachment :avatar
          end
        end
      end
      """
    And I run a migration
    Then I should have attachment columns for "avatar"

  Scenario: New syntax outside of create_table
    When I write to "db/migrate/01_create_users.rb" with:
      """
      class CreateUsers < ActiveRecord::Migration
        def self.up
          create_table :users
        end
      end
      """
    And I write to "db/migrate/02_add_attachment_to_users.rb" with:
      """
      class AddAttachmentToUsers < ActiveRecord::Migration
        def self.up
          add_attachment :users, :avatar
        end

        def self.down
          remove_attachment :users, :avatar
        end
      end
      """
    And I run a migration
    Then I should have attachment columns for "avatar"

    When I rollback a migration
    Then I should not have attachment columns for "avatar"

Version data entries

11 entries across 11 versions & 4 rubygems

Version Path
kt-paperclip-5.4.0 features/migration.feature
paperclip-6.1.0 features/migration.feature
paperclip-6.0.0 features/migration.feature
paperclip-5.3.0 features/migration.feature
paperclip-5.2.1 features/migration.feature
paperclip-5.2.0 features/migration.feature
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/paperclip-5.1.0/features/migration.feature
paperclip-5.1.0 features/migration.feature
paperclip-5.0.0 features/migration.feature
paperclip_jk-5.0.0.beta2 features/migration.feature
paperclip-5.0.0.beta2 features/migration.feature