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
65fb9268
Commit
65fb9268
authored
May 11, 2009
by
Jon Yurek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed extension interpolation bug when relying on default_style
parent
93073d5f
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
3 deletions
+17
-3
lib/paperclip/attachment.rb
+1
-1
test/attachment_test.rb
+14
-0
test/helper.rb
+1
-1
test/interpolations_test.rb
+1
-1
No files found.
lib/paperclip/attachment.rb
View file @
65fb9268
...
...
@@ -108,7 +108,7 @@ module Paperclip
# file is stored in the filesystem the path refers to the path of the file
# on disk. If the file is stored in S3, the path is the "key" part of the
# URL, and the :bucket option refers to the S3 bucket.
def
path
style
=
nil
#:nodoc:
def
path
style
=
default_style
original_filename
.
nil?
?
nil
:
interpolate
(
@path
,
style
)
end
...
...
test/attachment_test.rb
View file @
65fb9268
...
...
@@ -114,6 +114,20 @@ class AttachmentTest < Test::Unit::TestCase
end
end
context
"An attachment with a default style and an extension interpolation"
do
setup
do
@attachment
=
attachment
:path
=>
":basename.:extension"
,
:styles
=>
{
:default
=>
[
"100x100"
,
:png
]
},
:default_style
=>
:default
@file
=
StringIO
.
new
(
"..."
)
@file
.
expects
(
:original_filename
).
returns
(
"file.jpg"
)
end
should
"return the right extension for the path"
do
@attachment
.
assign
(
@file
)
assert_equal
"file.png"
,
@attachment
.
path
end
end
context
"An attachment with :convert_options"
do
setup
do
rebuild_model
:styles
=>
{
...
...
test/helper.rb
View file @
65fb9268
...
...
@@ -91,7 +91,7 @@ class FakeModel
@errors
||=
[]
end
def
run_callbacks
def
run_callbacks
name
,
*
args
end
end
...
...
test/interpolations_test.rb
View file @
65fb9268
...
...
@@ -39,7 +39,7 @@ class InterpolationsTest < Test::Unit::TestCase
assert_equal
"jpg"
,
Paperclip
::
Interpolations
.
extension
(
attachment
,
:style
)
end
should
"return the extension of the file as the format i
s
defined in the style"
do
should
"return the extension of the file as the format i
f
defined in the style"
do
attachment
=
mock
attachment
.
expects
(
:original_filename
).
never
attachment
.
expects
(
:styles
).
returns
({
:style
=>
{
:format
=>
"png"
}})
...
...
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