Commit ecfb5e2a by soramugi
parent 804b4edc
......@@ -8,8 +8,8 @@ module Paperclip
end
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),
options
), options)
......
......@@ -184,16 +184,30 @@ describe Paperclip::UrlGenerator do
"expected the interpolator to be passed #{expected.inspect} but it wasn't"
end
it "should be able to escape (, ), [, and ]." do
expected = "the(expected)result[]"
mock_attachment = MockAttachment.new
mock_interpolator = MockInterpolator.new(result: expected)
options = { interpolator: mock_interpolator }
url_generator = Paperclip::UrlGenerator.new(mock_attachment, options)
def url_generator.respond_to(params)
false if params == :escape
describe "should be able to escape (, ), [, and ]." do
def generate(expected, updated_at=nil)
mock_attachment = MockAttachment.new(updated_at: updated_at)
mock_interpolator = MockInterpolator.new(result: expected)
options = { interpolator: mock_interpolator }
url_generator = Paperclip::UrlGenerator.new(mock_attachment, options)
def url_generator.respond_to(params)
false if params == :escape
end
if updated_at
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
result = url_generator.for(:style_name, {escape: true})
assert_equal "the%28expected%29result%5B%5D", result
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