This repository has been archived by the owner on Jul 13, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
103 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters