Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
paperclip
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ikcrm_common
paperclip
Commits
77ee8a51
Commit
77ee8a51
authored
Apr 23, 2012
by
Prem Sichanugrist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add command recorder for our migrations
This is for Rails 3.1+
parent
76cbfb80
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
0 deletions
+46
-0
features/migration.feature
+24
-0
features/step_definitions/rails_steps.rb
+6
-0
lib/paperclip/schema.rb
+16
-0
No files found.
features/migration.feature
View file @
77ee8a51
...
...
@@ -68,3 +68,27 @@ Feature: Migration
When
I rollback a migration
Then
I should not have attachment columns for
"avatar"
Scenario
:
Rails 3.2 change method
Given
I am using Rails newer than 3.1
When I write to "db/migrate/01_create_users.rb" with
:
"""
class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users
end
end
"""
When I write to "db/migrate/02_add_attachment_to_users.rb" with
:
"""
class AddAttachmentToUsers < ActiveRecord::Migration
def change
add_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"
features/step_definitions/rails_steps.rb
View file @
77ee8a51
...
...
@@ -130,3 +130,9 @@ end
When
/^I comment out the gem "([^"]*)" from the Gemfile$/
do
|
gemname
|
comment_out_gem_in_gemfile
gemname
end
Given
/^I am using Rails newer than ([\d\.]+)$/
do
|
version
|
if
framework_version
<
version
pending
"Not supported in Rails <
#{
version
}
"
end
end
lib/paperclip/schema.rb
View file @
77ee8a51
...
...
@@ -12,6 +12,10 @@ module Paperclip
ActiveRecord
::
ConnectionAdapters
::
Table
.
send
:include
,
TableDefinition
ActiveRecord
::
ConnectionAdapters
::
TableDefinition
.
send
:include
,
TableDefinition
ActiveRecord
::
ConnectionAdapters
::
AbstractAdapter
.
send
:include
,
Statements
if
defined?
(
ActiveRecord
::
Migration
::
CommandRecorder
)
# Rails 3.1+
ActiveRecord
::
Migration
::
CommandRecorder
.
send
:include
,
CommandRecorder
end
end
module
Statements
...
...
@@ -55,5 +59,17 @@ module Paperclip
attachment
(
*
attachment_names
)
end
end
module
CommandRecorder
def
add_attachment
(
*
args
)
record
(
:add_attachment
,
args
)
end
private
def
invert_add_attachment
(
args
)
[
:remove_attachment
,
args
]
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment