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
0d04ae1b
Commit
0d04ae1b
authored
Jul 31, 2013
by
Jon Yurek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Responses to PR comments
parent
f29f96b2
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
60 additions
and
32 deletions
+60
-32
features/basic_integration.feature
+8
-15
features/rake_tasks.feature
+2
-3
features/step_definitions/rails_steps.rb
+30
-11
features/support/file_helpers.rb
+10
-0
features/support/rails.rb
+4
-0
gemfiles/4.0.gemfile
+1
-2
test/helper.rb
+4
-0
test/paperclip_test.rb
+1
-1
No files found.
features/basic_integration.feature
View file @
0d04ae1b
...
...
@@ -14,11 +14,7 @@ Feature: Rails integration
"""
config.paperclip_defaults = {:url => "/paperclip/custom/:attachment/:style/:filename"}
"""
Given I add this snippet to the User model
:
"""
attr_accessible :name, :attachment if Rails::VERSION::MAJOR < 4
has_attached_file :attachment
"""
And I attach
:
attachment
And
I start the rails application
When
I go to the new user page
And
I fill in
"Name"
with
"something"
...
...
@@ -29,10 +25,9 @@ Feature: Rails integration
And
the file at
"/paperclip/custom/attachments/original/5k.png"
should be the same as
"test/fixtures/5k.png"
Scenario
:
Filesystem integration test
Given I a
dd this snippet to the User model
:
Given I a
ttach
:
attachment with
:
"""
attr_accessible :name, :attachment if Rails::VERSION::MAJOR < 4
has_attached_file :attachment, :url => "/system/:attachment/:style/:filename"
:url => "/system/:attachment/:style/:filename"
"""
And
I start the rails application
When
I go to the new user page
...
...
@@ -44,14 +39,12 @@ Feature: Rails integration
And
the file at
"/system/attachments/original/5k.png"
should be the same as
"test/fixtures/5k.png"
Scenario
:
S3 Integration test
Given I a
dd this snippet to the User model
:
Given I a
ttach
:
attachment with
:
"""
attr_accessible :name, :attachment if Rails::VERSION::MAJOR < 4
has_attached_file :attachment,
:storage => :s3,
:path => "/:attachment/:style/:filename",
:s3_credentials => Rails.root.join("config/s3.yml"),
:styles => { :square => "100x100#" }
:storage => :s3,
:path => "/:attachment/:style/:filename",
:s3_credentials => Rails.root.join("config/s3.yml"),
:styles => { :square => "100x100#" }
"""
And I write to "config/s3.yml" with
:
"""
...
...
features/rake_tasks.feature
View file @
0d04ae1b
...
...
@@ -5,10 +5,9 @@ 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 a
dd this snippet to the User model
:
And I a
ttach
:
attachment with
:
"""
attr_accessible :name, :attachment if Rails::VERSION::MAJOR < 4
has_attached_file :attachment, :path => ":rails_root/public/system/:attachment/:style/:filename"
:path => ":rails_root/public/system/:attachment/:style/:filename"
"""
Scenario
:
Paperclip refresh thumbnails task
...
...
features/step_definitions/rails_steps.rb
View file @
0d04ae1b
...
...
@@ -15,8 +15,8 @@ Given /^I generate a new rails application$/ do
gem "gherkin"
gem "aws-sdk"
"""
And I remove turbolinks
if it exists
And I empty the application.js file
if it exists
And I remove turbolinks
And I empty the application.js file
And I configure the application to use "paperclip" from this project
And I reset Bundler environment variable
And I successfully run `bundle install --local`
...
...
@@ -40,7 +40,7 @@ Given "I allow the attachment to be submitted" do
end
end
Given
"I remove turbolinks
if it exists
"
do
Given
"I remove turbolinks"
do
in_current_dir
do
transform_file
(
"app/assets/javascripts/application.js"
)
do
|
content
|
content
.
gsub
(
"//= require turbolinks"
,
""
)
...
...
@@ -51,7 +51,32 @@ Given "I remove turbolinks if it exists" do
end
end
Given
"I empty the application.js file if it exists"
do
Given
/^I attach :attachment$/
do
attach_attachment
(
"attachment"
)
end
Given
/^I attach :attachment with:$/
do
|
definition
|
attach_attachment
(
"attachment"
,
definition
)
end
def
attach_attachment
(
name
,
definition
=
nil
)
snippet
=
""
if
using_protected_attributes?
snippet
+=
"attr_accessible :name, :
#{
name
}
\n
"
end
snippet
+=
"has_attached_file :
#{
name
}
"
if
definition
snippet
+=
",
\n
"
snippet
+=
definition
end
in_current_dir
do
transform_file
(
"app/models/user.rb"
)
do
|
content
|
content
.
sub
(
/end\Z/
,
"
#{
snippet
}
\n
end"
)
end
end
end
Given
"I empty the application.js file"
do
in_current_dir
do
transform_file
(
"app/assets/javascripts/application.js"
)
do
|
content
|
""
...
...
@@ -139,13 +164,7 @@ 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?://}
Net
::
HTTP
.
get
(
URI
.
parse
(
web_file
))
else
visit
(
web_file
)
page
.
source
end
actual
.
force_encoding
(
"UTF-8"
)
if
actual
.
respond_to?
(
:force_encoding
)
actual
=
read_from_web
(
web_file
)
actual
.
should
==
expected
end
...
...
features/support/file_helpers.rb
View file @
0d04ae1b
...
...
@@ -19,6 +19,16 @@ module FileHelpers
File
.
open
(
"Gemfile"
,
'w'
){
|
file
|
file
.
write
(
gemfile
)
}
end
end
def
read_from_web
(
url
)
file
=
if
url
.
match
%r{^https?://}
Net
::
HTTP
.
get
(
URI
.
parse
(
url
))
else
visit
(
url
)
page
.
source
end
file
.
force_encoding
(
"UTF-8"
)
if
file
.
respond_to?
(
:force_encoding
)
end
end
World
(
FileHelpers
)
features/support/rails.rb
View file @
0d04ae1b
...
...
@@ -35,6 +35,10 @@ module RailsCommandHelpers
framework_version
.
split
(
"."
).
first
.
to_i
end
def
using_protected_attributes?
framework_major_version
<
4
end
def
new_application_command
"rails new"
end
...
...
gemfiles/4.0.gemfile
View file @
0d04ae1b
...
...
@@ -8,4 +8,4 @@ gem "sqlite3", :platform=>:ruby
gem "rails", "~> 4.0.0"
gem "paperclip", :path=>"../"
gemspec :path=>"../"
\ No newline at end of file
gemspec :path=>"../"
test/helper.rb
View file @
0d04ae1b
...
...
@@ -51,6 +51,10 @@ ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log")
ActiveRecord
::
Base
.
establish_connection
(
config
[
'test'
])
Paperclip
.
options
[
:logger
]
=
ActiveRecord
::
Base
.
logger
def
using_protected_attributes?
ActiveRecord
::
VERSION
::
MAJOR
<
4
end
def
require_everything_in_directory
(
directory_name
)
Dir
[
File
.
join
(
File
.
dirname
(
__FILE__
),
directory_name
,
'*'
)].
each
do
|
f
|
require
f
...
...
test/paperclip_test.rb
View file @
0d04ae1b
...
...
@@ -123,7 +123,7 @@ class PaperclipTest < Test::Unit::TestCase
end
end
if
ActiveSupport
::
VERSION
::
MAJOR
<
4
if
using_protected_attributes?
context
"that is attr_protected"
do
setup
do
Dummy
.
class_eval
do
...
...
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