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
78cfebd5
Commit
78cfebd5
authored
Mar 30, 2012
by
Jon Yurek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changes from merging with master/3.0
parent
89c8d117
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
46 additions
and
40 deletions
+46
-40
features/step_definitions/attachment_steps.rb
+7
-0
lib/paperclip.rb
+8
-0
lib/paperclip/attachment.rb
+0
-10
lib/paperclip/io_adapters/registry.rb
+1
-1
lib/paperclip/io_adapters/stringio_adapter.rb
+5
-0
lib/paperclip/storage/fog.rb
+0
-1
lib/paperclip/storage/s3.rb
+0
-1
lib/tasks/paperclip.rake
+1
-1
test/storage/fog_test.rb
+0
-13
test/storage/s3_live_test.rb
+24
-0
test/storage/s3_test.rb
+0
-13
No files found.
features/step_definitions/attachment_steps.rb
View file @
78cfebd5
...
...
@@ -51,6 +51,13 @@ Then /^the attachment should have the same content type as the fixture "([^"]*)"
end
end
Then
/^the attachment should have the same file name as the fixture "([^"]*)"$/
do
|
filename
|
in_current_dir
do
attachment_file_name
=
`bundle exec
#{
runner_command
}
"puts User.last.attachment_file_name"`
.
strip
attachment_file_name
.
should
==
File
.
name
(
fixture_path
(
filename
)).
to_s
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
#{
runner_command
}
"puts User.last.attachment_file_size"`
.
strip
...
...
lib/paperclip.rb
View file @
78cfebd5
...
...
@@ -77,6 +77,14 @@ module Paperclip
}
end
def
self
.
io_adapters
=
(
new_registry
)
@io_adapters
=
new_registry
end
def
self
.
io_adapters
@io_adapters
||=
Paperclip
::
AdapterRegistry
.
new
end
module
ClassMethods
# +has_attached_file+ gives the class it is called on an attribute that maps to a file. This
# is typically a file stored somewhere on the filesystem and has been uploaded by a user.
...
...
lib/paperclip/attachment.rb
View file @
78cfebd5
...
...
@@ -269,16 +269,6 @@ module Paperclip
OpenSSL
::
HMAC
.
hexdigest
(
OpenSSL
::
Digest
.
const_get
(
@options
[
:hash_digest
]).
new
,
@options
[
:hash_secret
],
data
)
end
def
generate_fingerprint
(
source
)
if
source
.
respond_to?
(
:path
)
&&
source
.
path
&&
!
source
.
path
.
blank?
Digest
::
MD5
.
file
(
source
.
path
).
to_s
else
data
=
source
.
read
source
.
rewind
if
source
.
respond_to?
(
:rewind
)
Digest
::
MD5
.
hexdigest
(
data
)
end
end
# This method really shouldn't be called that often. It's expected use is
# in the paperclip:refresh rake task and that's it. It will regenerate all
# thumbnails forcefully, by reobtaining the original file and going through
...
...
lib/paperclip/io_adapters/registry.rb
View file @
78cfebd5
module
Paperclip
class
AdapterRegistry
class
NoHandlerError
<
PaperclipError
;
end
class
NoHandlerError
<
Paperclip
::
Error
;
end
attr_reader
:registered_handlers
...
...
lib/paperclip/io_adapters/stringio_adapter.rb
View file @
78cfebd5
...
...
@@ -31,6 +31,11 @@ module Paperclip
@tempfile
.
read
(
length
,
buffer
)
end
# We don't use this directly, but aws/sdk does.
def
rewind
@tempfile
.
rewind
end
def
eof?
@tempfile
.
eof?
end
...
...
lib/paperclip/storage/fog.rb
View file @
78cfebd5
...
...
@@ -77,7 +77,6 @@ module Paperclip
def
flush_writes
for
style
,
file
in
@queued_for_write
do
log
(
"saving
#{
path
(
style
)
}
"
)
file
.
rewind
retried
=
false
begin
directory
.
files
.
create
(
fog_file
.
merge
(
...
...
lib/paperclip/storage/s3.rb
View file @
78cfebd5
...
...
@@ -272,7 +272,6 @@ module Paperclip
@queued_for_write
.
each
do
|
style
,
file
|
begin
log
(
"saving
#{
path
(
style
)
}
"
)
file
.
rewind
acl
=
@s3_permissions
[
style
]
||
@s3_permissions
[
:default
]
acl
=
acl
.
call
(
self
,
style
)
if
acl
.
respond_to?
(
:call
)
write_options
=
{
...
...
lib/tasks/paperclip.rake
View file @
78cfebd5
...
...
@@ -45,7 +45,7 @@ namespace :paperclip do
names
=
Paperclip
::
Task
.
obtain_attachments
(
klass
)
names
.
each
do
|
name
|
Paperclip
.
each_instance_with_attachment
(
klass
,
name
)
do
|
instance
|
if
file
=
instance
.
send
(
name
)
if
file
=
Paperclip
.
io_adapters
.
for
(
instance
.
send
(
name
)
)
instance
.
send
(
"
#{
name
}
_file_name="
,
instance
.
send
(
"
#{
name
}
_file_name"
).
strip
)
instance
.
send
(
"
#{
name
}
_content_type="
,
file
.
content_type
.
to_s
.
strip
)
instance
.
send
(
"
#{
name
}
_file_size="
,
file
.
size
)
if
instance
.
respond_to?
(
"
#{
name
}
_file_size"
)
...
...
test/storage/fog_test.rb
View file @
78cfebd5
...
...
@@ -102,19 +102,6 @@ class FogTest < Test::Unit::TestCase
directory
.
destroy
end
# NOTE: This might not be necessary, watch for this to error
should
"always be rewound when returning from #to_file"
do
assert_equal
0
,
@dummy
.
avatar
.
to_file
.
pos
@dummy
.
avatar
.
to_file
.
seek
(
10
)
assert_equal
0
,
@dummy
.
avatar
.
to_file
.
pos
end
# NOTE: This might not be necessary, watch for this to error
should
"rewind file in flush_writes"
do
@dummy
.
avatar
.
queued_for_write
.
each
{
|
style
,
file
|
file
.
expects
(
:rewind
).
with
()
}
@dummy
.
save
end
should
"pass the content type to the Fog::Storage::AWS::Files instance"
do
Fog
::
Storage
::
AWS
::
Files
.
any_instance
.
expects
(
:create
).
with
do
|
hash
|
hash
[
:content_type
]
...
...
test/storage/s3_live_test.rb
View file @
78cfebd5
require
'./test/helper'
require
'aws'
unless
ENV
[
"S3_BUCKET"
].
blank?
class
S3LiveTest
<
Test
::
Unit
::
TestCase
context
"when assigning an S3 attachment directly to another model"
do
setup
do
rebuild_model
:styles
=>
{
:thumb
=>
"100x100"
,
:square
=>
"32x32#"
},
:storage
=>
:s3
,
:bucket
=>
ENV
[
"S3_BUCKET"
],
:path
=>
":class/:attachment/:id/:style.:extension"
,
:s3_credentials
=>
File
.
new
(
File
.
join
(
File
.
dirname
(
__FILE__
),
".."
,
"fixtures"
,
"s3.yml"
))
@dummy
=
Dummy
.
new
@attachment
=
Dummy
.
new
.
avatar
@file
=
File
.
new
(
fixture_file
(
"5k.png"
))
@attachment
.
assign
(
@file
)
@attachment
.
save
@attachment2
=
Dummy
.
new
.
avatar
@attachment2
.
assign
(
@file
)
@attachment2
.
save
binding
.
pry
end
end
context
"Generating an expiring url on a nonexistant attachment"
do
setup
do
rebuild_model
:styles
=>
{
:thumb
=>
"100x100"
,
:square
=>
"32x32#"
},
...
...
test/storage/s3_test.rb
View file @
78cfebd5
...
...
@@ -88,7 +88,6 @@ class S3Test < Test::Unit::TestCase
setup
do
rebuild_model
:storage
=>
:s3
,
#:bucket => "testing", # intentionally left out
:http_proxy
=>
@proxy_settings
,
:s3_credentials
=>
{
:not
=>
:important
}
...
...
@@ -336,18 +335,6 @@ class S3Test < Test::Unit::TestCase
assert_match
%r{^avatars/stringio
\.
txt}
,
@dummy
.
avatar
.
url
end
# NOTE: This might not be necessary, watch for this to error
should
"always be rewound when returning from #to_file"
do
assert_equal
0
,
@dummy
.
avatar
.
to_file
.
pos
@dummy
.
avatar
.
to_file
.
seek
(
10
)
assert_equal
0
,
@dummy
.
avatar
.
to_file
.
pos
end
# NOTE: This might not be necessary, watch for this to error
should
"rewind file in flush_writes"
do
@dummy
.
avatar
.
queued_for_write
.
each
{
|
style
,
file
|
file
.
expects
(
:rewind
).
with
()
}
@dummy
.
save
end
end
context
"Generating a secure url with an expiration"
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