Permalink
Browse files

Fix the collision with Object#hash.

Closes #678. Closes #450.
  • Loading branch information...
1 parent dc53432 commit 3fd4c96b28962a95447472eb4046d9f47560c4f8 @jyurek jyurek committed Jan 13, 2012
Showing with 6 additions and 6 deletions.
  1. +1 −1 lib/paperclip/attachment.rb
  2. +2 −2 lib/paperclip/interpolations.rb
  3. +1 −1 test/attachment_test.rb
  4. +2 −2 test/interpolations_test.rb
@@ -284,7 +284,7 @@ def time_zone
# Returns a unique hash suitable for obfuscating the URL of an otherwise
# 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]
require 'openssl' unless defined?(OpenSSL)
data = interpolate(@options[:hash_data], style_name)
@@ -137,11 +137,11 @@ def fingerprint attachment, style_name
attachment.fingerprint
end
- # Returns a the attachment hash. See Paperclip::Attachment#hash for
+ # Returns a the attachment hash. See Paperclip::Attachment#hash_key for
# more details.
def hash attachment=nil, style_name=nil
if attachment && style_name
- attachment.hash(style_name)
+ attachment.hash_key(style_name)
else
super()
end
View
@@ -245,7 +245,7 @@ class AttachmentTest < Test::Unit::TestCase
should "interpolate the hash data" do
@attachment.expects(:interpolate).with(@attachment.options[:hash_data],anything).returns("interpolated_stuff")
- @attachment.hash
+ @attachment.hash_key
end
should "result in the correct interpolation" do
@@ -195,14 +195,14 @@ def url(*args)
should "return attachment's hash when passing both arguments" do
attachment = mock
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)
end
should "return Object#hash when passing no argument" do
attachment = mock
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
end

0 comments on commit 3fd4c96

Please sign in to comment.