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
ab9a0f7e
Commit
ab9a0f7e
authored
Nov 01, 2012
by
Janko Marohnić
Committed by
Jon Yurek
Nov 02, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add #blank? to Attachment
parent
eb466fac
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
0 deletions
+27
-0
lib/paperclip/attachment.rb
+4
-0
test/attachment_test.rb
+23
-0
No files found.
lib/paperclip/attachment.rb
View file @
ab9a0f7e
...
...
@@ -320,6 +320,10 @@ module Paperclip
alias
:present?
:file?
def
blank?
not
present?
end
# Determines whether the instance responds to this attribute. Used to prevent
# calculations on fields we won't even store.
def
instance_respond_to?
(
attr
)
...
...
test/attachment_test.rb
View file @
ab9a0f7e
...
...
@@ -6,6 +6,29 @@ class Dummy; end
class
AttachmentTest
<
Test
::
Unit
::
TestCase
context
"presence"
do
setup
do
rebuild_class
@dummy
=
Dummy
.
new
end
context
"when file not set"
do
should
"not be present"
do
assert
@dummy
.
avatar
.
blank?
refute
@dummy
.
avatar
.
present?
end
end
context
"when file set"
do
setup
{
@dummy
.
avatar
=
File
.
new
(
fixture_file
(
"50x50.png"
),
"rb"
)
}
should
"be present"
do
refute
@dummy
.
avatar
.
blank?
assert
@dummy
.
avatar
.
present?
end
end
end
should
"process :original style first"
do
file
=
File
.
new
(
fixture_file
(
"50x50.png"
),
'rb'
)
rebuild_class
:styles
=>
{
:small
=>
'100x>'
,
:original
=>
'42x42#'
}
...
...
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