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
3fd4c96b
Commit
3fd4c96b
authored
Jan 13, 2012
by
Jon Yurek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix the collision with Object#hash.
Closes #678. Closes #450.
parent
dc53432b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
6 additions
and
6 deletions
+6
-6
lib/paperclip/attachment.rb
+1
-1
lib/paperclip/interpolations.rb
+2
-2
test/attachment_test.rb
+1
-1
test/interpolations_test.rb
+2
-2
No files found.
lib/paperclip/attachment.rb
View file @
3fd4c96b
...
@@ -284,7 +284,7 @@ module Paperclip
...
@@ -284,7 +284,7 @@ module Paperclip
# Returns a unique hash suitable for obfuscating the URL of an otherwise
# Returns a unique hash suitable for obfuscating the URL of an otherwise
# publicly viewable attachment.
# publicly viewable attachment.
def
hash
(
style_name
=
default_style
)
def
hash
_key
(
style_name
=
default_style
)
raise
ArgumentError
,
"Unable to generate hash without :hash_secret"
unless
@options
[
:hash_secret
]
raise
ArgumentError
,
"Unable to generate hash without :hash_secret"
unless
@options
[
:hash_secret
]
require
'openssl'
unless
defined?
(
OpenSSL
)
require
'openssl'
unless
defined?
(
OpenSSL
)
data
=
interpolate
(
@options
[
:hash_data
],
style_name
)
data
=
interpolate
(
@options
[
:hash_data
],
style_name
)
...
...
lib/paperclip/interpolations.rb
View file @
3fd4c96b
...
@@ -137,11 +137,11 @@ module Paperclip
...
@@ -137,11 +137,11 @@ module Paperclip
attachment
.
fingerprint
attachment
.
fingerprint
end
end
# Returns a the attachment hash. See Paperclip::Attachment#hash for
# Returns a the attachment hash. See Paperclip::Attachment#hash
_key
for
# more details.
# more details.
def
hash
attachment
=
nil
,
style_name
=
nil
def
hash
attachment
=
nil
,
style_name
=
nil
if
attachment
&&
style_name
if
attachment
&&
style_name
attachment
.
hash
(
style_name
)
attachment
.
hash
_key
(
style_name
)
else
else
super
()
super
()
end
end
...
...
test/attachment_test.rb
View file @
3fd4c96b
...
@@ -245,7 +245,7 @@ class AttachmentTest < Test::Unit::TestCase
...
@@ -245,7 +245,7 @@ class AttachmentTest < Test::Unit::TestCase
should
"interpolate the hash data"
do
should
"interpolate the hash data"
do
@attachment
.
expects
(
:interpolate
).
with
(
@attachment
.
options
[
:hash_data
],
anything
).
returns
(
"interpolated_stuff"
)
@attachment
.
expects
(
:interpolate
).
with
(
@attachment
.
options
[
:hash_data
],
anything
).
returns
(
"interpolated_stuff"
)
@attachment
.
hash
@attachment
.
hash
_key
end
end
should
"result in the correct interpolation"
do
should
"result in the correct interpolation"
do
...
...
test/interpolations_test.rb
View file @
3fd4c96b
...
@@ -195,14 +195,14 @@ class InterpolationsTest < Test::Unit::TestCase
...
@@ -195,14 +195,14 @@ class InterpolationsTest < Test::Unit::TestCase
should
"return attachment's hash when passing both arguments"
do
should
"return attachment's hash when passing both arguments"
do
attachment
=
mock
attachment
=
mock
fake_hash
=
"a_wicked_secure_hash"
fake_hash
=
"a_wicked_secure_hash"
attachment
.
expects
(
:hash
).
returns
(
fake_hash
)
attachment
.
expects
(
:hash
_key
).
returns
(
fake_hash
)
assert_equal
fake_hash
,
Paperclip
::
Interpolations
.
hash
(
attachment
,
:style
)
assert_equal
fake_hash
,
Paperclip
::
Interpolations
.
hash
(
attachment
,
:style
)
end
end
should
"return Object#hash when passing no argument"
do
should
"return Object#hash when passing no argument"
do
attachment
=
mock
attachment
=
mock
fake_hash
=
"a_wicked_secure_hash"
fake_hash
=
"a_wicked_secure_hash"
attachment
.
expects
(
:hash
).
never
.
returns
(
fake_hash
)
attachment
.
expects
(
:hash
_key
).
never
.
returns
(
fake_hash
)
assert_not_equal
fake_hash
,
Paperclip
::
Interpolations
.
hash
assert_not_equal
fake_hash
,
Paperclip
::
Interpolations
.
hash
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