Commit af7a99c5 by Jon Yurek

Fixed bug with DateTimes not having a #to_i method.

parent a05fb27d
......@@ -187,7 +187,7 @@ module Paperclip
# lives in the <attachment>_updated_at attribute of the model.
def updated_at
time = instance_read(:updated_at)
time && time.to_i
time && time.to_f.to_i
end
# Paths and URLs can have a number of variables interpolated into them
......
......@@ -531,9 +531,10 @@ class AttachmentTest < Test::Unit::TestCase
@attachment.stubs(:instance_read).with(:file_name).returns("5k.png")
@attachment.stubs(:instance_read).with(:content_type).returns("image/png")
@attachment.stubs(:instance_read).with(:file_size).returns(12345)
now = Time.now
Time.stubs(:now).returns(now)
@attachment.stubs(:instance_read).with(:updated_at).returns(Time.now)
dtnow = DateTime.now
@now = Time.now
Time.stubs(:now).returns(@now)
@attachment.stubs(:instance_read).with(:updated_at).returns(dtnow)
end
should "return a correct url even if the file does not exist" do
......@@ -542,11 +543,11 @@ class AttachmentTest < Test::Unit::TestCase
end
should "make sure the updated_at mtime is in the url if it is defined" do
assert_match %r{#{Time.now.to_i}$}, @attachment.url(:blah)
assert_match %r{#{@now.to_i}$}, @attachment.url(:blah)
end
should "make sure the updated_at mtime is NOT in the url if false is passed to the url method" do
assert_no_match %r{#{Time.now.to_i}$}, @attachment.url(:blah, false)
assert_no_match %r{#{@now.to_i}$}, @attachment.url(:blah, false)
end
context "with the updated_at field removed" do
......
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