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
9ad074a0
Commit
9ad074a0
authored
Feb 17, 2012
by
Prem Sichanugrist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert style name to symbol for the interpolator
Fixes #745
parent
7045e297
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
3 deletions
+6
-3
lib/paperclip/interpolations.rb
+1
-1
test/interpolations_test.rb
+5
-2
No files found.
lib/paperclip/interpolations.rb
View file @
9ad074a0
...
...
@@ -93,7 +93,7 @@ module Paperclip
# If the style has a format defined, it will return the format instead
# of the actual extension.
def
extension
attachment
,
style_name
((
style
=
attachment
.
styles
[
style_name
])
&&
style
[
:format
])
||
((
style
=
attachment
.
styles
[
style_name
.
to_sym
])
&&
style
[
:format
])
||
File
.
extname
(
attachment
.
original_filename
).
gsub
(
/^\.+/
,
""
)
end
...
...
test/interpolations_test.rb
View file @
9ad074a0
...
...
@@ -46,8 +46,11 @@ class InterpolationsTest < Test::Unit::TestCase
should
"return the extension of the file as the format if defined in the style"
do
attachment
=
mock
attachment
.
expects
(
:original_filename
).
never
attachment
.
expects
(
:styles
).
returns
({
:style
=>
{
:format
=>
"png"
}})
assert_equal
"png"
,
Paperclip
::
Interpolations
.
extension
(
attachment
,
:style
)
attachment
.
expects
(
:styles
).
twice
.
returns
({
:style
=>
{
:format
=>
"png"
}})
[
:style
,
'style'
].
each
do
|
style
|
assert_equal
"png"
,
Paperclip
::
Interpolations
.
extension
(
attachment
,
style
)
end
end
should
"return the extension of the file based on the content type"
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