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
948ddfa5
Commit
948ddfa5
authored
Oct 14, 2011
by
Prem Sichanugrist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure that we're copy the rake task to Rails' folder on Rails 2.3.x
parent
cd856aa0
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
5 deletions
+18
-5
features/rake_tasks.feature
+1
-0
features/step_definitions/attachment_steps.rb
+3
-5
features/step_definitions/rails_steps.rb
+10
-0
features/support/rails.rb
+4
-0
No files found.
features/rake_tasks.feature
View file @
948ddfa5
...
...
@@ -5,6 +5,7 @@ Feature: Rake tasks
And I run a rails generator to generate a "User" scaffold with "name
:
string"
And
I run a paperclip generator to add a paperclip
"attachment"
to the
"User"
model
And
I run a migration
And
I prepare my old Rails application for rake task
And I add this snippet to the User model
:
"""
has_attached_file :attachment, :path => ":rails_root/public/system/:attachment/:style/:filename"
...
...
features/step_definitions/attachment_steps.rb
View file @
948ddfa5
...
...
@@ -22,9 +22,7 @@ When /^I modify my attachment definition to:$/ do |definition|
end
When
/^I upload the fixture "([^"]*)"$/
do
|
filename
|
in_current_dir
do
run_simple
%(bundle exec rails runner "User.create!(:attachment => File.open('#{fixture_path(filename)}'))")
end
run_simple
%(bundle exec #{runner_command} "User.create!(:attachment => File.open('#{fixture_path(filename)}'))")
end
Then
/^the attachment "([^"]*)" should have a dimension of (\d+x\d+)$/
do
|
filename
,
dimension
|
...
...
@@ -51,14 +49,14 @@ end
Then
/^the attachment should have the same content type as the fixture "([^"]*)"$/
do
|
filename
|
in_current_dir
do
require
'mime/types'
attachment_content_type
=
`bundle exec
rails runner
"puts User.last.attachment_content_type"`
.
strip
attachment_content_type
=
`bundle exec
#{
runner_command
}
"puts User.last.attachment_content_type"`
.
strip
attachment_content_type
.
should
==
MIME
::
Types
.
type_for
(
filename
).
first
.
content_type
end
end
Then
/^the attachment should have the same file size as the fixture "([^"]*)"$/
do
|
filename
|
in_current_dir
do
attachment_file_size
=
`bundle exec
rails runner
"puts User.last.attachment_file_size"`
.
strip
attachment_file_size
=
`bundle exec
#{
runner_command
}
"puts User.last.attachment_file_size"`
.
strip
attachment_file_size
.
should
==
File
.
size
(
fixture_path
(
filename
)).
to_s
end
end
...
...
features/step_definitions/rails_steps.rb
View file @
948ddfa5
...
...
@@ -113,6 +113,16 @@ Given /^I update my application to use Bundler$/ do
end
end
Given
/^I prepare my old Rails application for rake task$/
do
if
framework_version?
(
"2.3"
)
require
'fileutils'
source
=
File
.
expand_path
(
'lib/tasks/paperclip.rake'
)
destination
=
in_current_dir
{
File
.
expand_path
(
"lib/tasks"
)
}
FileUtils
.
cp
source
,
destination
append_to
"Rakefile"
,
"require 'paperclip'"
end
end
Then
/^the file at "([^"]*)" should be the same as "([^"]*)"$/
do
|
web_file
,
path
|
expected
=
IO
.
read
(
path
)
actual
=
if
web_file
.
match
%r{^https?://}
...
...
features/support/rails.rb
View file @
948ddfa5
...
...
@@ -38,5 +38,9 @@ module RailsCommandHelpers
def
generator_command
framework_version?
(
"3"
)
?
"script/rails generate"
:
"script/generate"
end
def
runner_command
framework_version?
(
"3"
)
?
"script/rails runner"
:
"script/runner"
end
end
World
(
RailsCommandHelpers
)
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