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
06ee1b3f
Commit
06ee1b3f
authored
Sep 29, 2008
by
Henrik N
Committed by
Jon Yurek
Dec 01, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Return nil as attachment.path when no file assigned; don't explode.
parent
7ee9dfca
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
1 deletions
+7
-1
lib/paperclip/attachment.rb
+1
-1
test/attachment_test.rb
+6
-0
No files found.
lib/paperclip/attachment.rb
View file @
06ee1b3f
...
...
@@ -106,7 +106,7 @@ module Paperclip
# 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:
interpolate
(
@path
,
style
)
original_filename
.
nil?
?
nil
:
interpolate
(
@path
,
style
)
end
# Alias to +url+
...
...
test/attachment_test.rb
View file @
06ee1b3f
...
...
@@ -229,6 +229,12 @@ class AttachmentTest < Test::Unit::TestCase
assert_equal
"/avatars/blah/missing.png"
,
@attachment
.
url
(
:blah
)
end
should
"return nil as path when no file assigned"
do
assert
@attachment
.
to_file
.
nil?
assert_equal
nil
,
@attachment
.
path
assert_equal
nil
,
@attachment
.
path
(
:blah
)
end
context
"with a file assigned in the database"
do
setup
do
@attachment
.
stubs
(
:instance_read
).
with
(
:file_name
).
returns
(
"5k.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