Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
paperclip
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ikcrm_common
paperclip
Commits
af7a99c5
Commit
af7a99c5
authored
Sep 03, 2009
by
Jon Yurek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed bug with DateTimes not having a #to_i method.
parent
a05fb27d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
6 deletions
+7
-6
lib/paperclip/attachment.rb
+1
-1
test/attachment_test.rb
+6
-5
No files found.
lib/paperclip/attachment.rb
View file @
af7a99c5
...
...
@@ -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
...
...
test/attachment_test.rb
View file @
af7a99c5
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment