Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
not escape to timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
soramugi committed Nov 14, 2014
1 parent 804b4ed commit ecfb5e2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
4 changes: 2 additions & 2 deletions lib/paperclip/url_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ def initialize(attachment, attachment_options)
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)
Expand Down
34 changes: 24 additions & 10 deletions spec/paperclip/url_generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,16 +184,30 @@ def escape
"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

0 comments on commit ecfb5e2

Please sign in to comment.