Commit ecfb5e2a by soramugi
parent 804b4edc
...@@ -8,8 +8,8 @@ module Paperclip ...@@ -8,8 +8,8 @@ module Paperclip
end end
def for(style_name, options) def for(style_name, options)
escape_url_as_needed(
timestamp_as_needed( timestamp_as_needed(
escape_url_as_needed(
@attachment_options[:interpolator].interpolate(most_appropriate_url, @attachment, style_name), @attachment_options[:interpolator].interpolate(most_appropriate_url, @attachment, style_name),
options options
), options) ), options)
......
...@@ -184,16 +184,30 @@ describe Paperclip::UrlGenerator do ...@@ -184,16 +184,30 @@ describe Paperclip::UrlGenerator do
"expected the interpolator to be passed #{expected.inspect} but it wasn't" "expected the interpolator to be passed #{expected.inspect} but it wasn't"
end end
it "should be able to escape (, ), [, and ]." do describe "should be able to escape (, ), [, and ]." do
expected = "the(expected)result[]" def generate(expected, updated_at=nil)
mock_attachment = MockAttachment.new mock_attachment = MockAttachment.new(updated_at: updated_at)
mock_interpolator = MockInterpolator.new(result: expected) mock_interpolator = MockInterpolator.new(result: expected)
options = { interpolator: mock_interpolator } options = { interpolator: mock_interpolator }
url_generator = Paperclip::UrlGenerator.new(mock_attachment, options) url_generator = Paperclip::UrlGenerator.new(mock_attachment, options)
def url_generator.respond_to(params) def url_generator.respond_to(params)
false if params == :escape false if params == :escape
end end
result = url_generator.for(:style_name, {escape: true}) if updated_at
assert_equal "the%28expected%29result%5B%5D", result url_generator.for(:style_name, {escape: true, timestamp: true})
else
url_generator.for(:style_name, {escape: true})
end
end
it "not timestamp" do
expected = "the(expected)result[]"
assert_equal "the%28expected%29result%5B%5D", generate(expected)
end
it "timestamp" do
expected = "the(expected)result[]"
updated_at = 1231231234
assert_equal "the%28expected%29result%5B%5D?#{updated_at}", generate(expected, updated_at)
end
end end
end end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment