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
1d756110
Commit
1d756110
authored
May 10, 2009
by
Jon Yurek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added :filename interpolation
parent
634864d7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
1 deletions
+19
-1
lib/paperclip/interpolations.rb
+4
-0
test/interpolations_test.rb
+15
-1
No files found.
lib/paperclip/interpolations.rb
View file @
1d756110
...
...
@@ -22,6 +22,10 @@ module Paperclip
end
end
def
filename
attachment
,
style
"
#{
basename
(
attachment
,
style
)
}
.
#{
extension
(
attachment
,
style
)
}
"
end
def
url
attachment
,
style
raise
InfiniteInterpolationError
if
attachment
.
options
[
:url
].
include?
(
":url"
)
attachment
.
url
(
style
)
...
...
test/interpolations_test.rb
View file @
1d756110
...
...
@@ -83,12 +83,26 @@ class InterpolationsTest < Test::Unit::TestCase
assert_equal
"1234"
,
Paperclip
::
Interpolations
.
url
(
attachment
,
:style
)
end
should
"raise if infinite loop detcted reinterpolatin :url"
do
should
"raise if infinite loop detcted reinterpolatin
g
:url"
do
attachment
=
mock
attachment
.
expects
(
:options
).
returns
({
:url
=>
":url"
})
assert_raises
(
Paperclip
::
InfiniteInterpolationError
){
Paperclip
::
Interpolations
.
url
(
attachment
,
:style
)
}
end
should
"return the filename as basename.extension"
do
attachment
=
mock
attachment
.
expects
(
:styles
).
returns
({})
attachment
.
expects
(
:original_filename
).
returns
(
"one.jpg"
).
times
(
3
)
assert_equal
"one.jpg"
,
Paperclip
::
Interpolations
.
filename
(
attachment
,
:style
)
end
should
"return the filename as basename.extension when format supplied"
do
attachment
=
mock
attachment
.
expects
(
:styles
).
returns
({
:style
=>
{
:format
=>
:png
}})
attachment
.
expects
(
:original_filename
).
returns
(
"one.jpg"
).
times
(
2
)
assert_equal
"one.png"
,
Paperclip
::
Interpolations
.
filename
(
attachment
,
:style
)
end
should
"return the timestamp"
do
now
=
Time
.
now
attachment
=
mock
...
...
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