I'm using Test::Unit
, and I'd like to test a paperclip url.
Right now, I have a test that looks like this:
def test_our_custom_url
dummy = Dummy.new(:image => File.open("#{RAILS_ROOT}/test/fixtures/12k.png"))
dummy.save!
assert_match "/system/images/1/original/12k.png", dummy.image.url
dummy.reload
assert_match "/system/images/1/original/12k.png", dummy.image.url
end
And it fails like this:
Expected /\/system\/images\/1\/original\/12k.png/ to match "/system/dummies/images/000/000/001/original/12k.png?1352140343".
How can I get the ?1352140343
part added to the test?
I see in paperclips source code that they seem to define it like this:
def timestamp_as_needed(url, options)
if options[:timestamp] && timestamp_possible?
delimiter_char = url.match(/\?.+=/) ? '&' : '?'
"#{url}#{delimiter_char}#{@attachment.updated_at.to_s}"
else
url
end
end
but doing dummy.updated_at.to_s
returns a normal date/timestamp, not 1352140343
(in this case).
I'm using local storage, if it makes a difference.