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
e54b5bdf
Commit
e54b5bdf
authored
Jul 16, 2013
by
Jon Yurek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Assigning an empty string does nothing
parent
fab4aea3
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
53 additions
and
0 deletions
+53
-0
lib/paperclip.rb
+1
-0
lib/paperclip/attachment.rb
+1
-0
lib/paperclip/io_adapters/abstract_adapter.rb
+8
-0
lib/paperclip/io_adapters/empty_string_adapter.rb
+18
-0
test/io_adapters/abstract_adapter_test.rb
+8
-0
test/io_adapters/empty_string_adapter_test.rb
+17
-0
No files found.
lib/paperclip.rb
View file @
e54b5bdf
...
@@ -181,6 +181,7 @@ end
...
@@ -181,6 +181,7 @@ end
# This stuff needs to be run after Paperclip is defined.
# This stuff needs to be run after Paperclip is defined.
require
'paperclip/io_adapters/registry'
require
'paperclip/io_adapters/registry'
require
'paperclip/io_adapters/abstract_adapter'
require
'paperclip/io_adapters/abstract_adapter'
require
'paperclip/io_adapters/empty_string_adapter'
require
'paperclip/io_adapters/identity_adapter'
require
'paperclip/io_adapters/identity_adapter'
require
'paperclip/io_adapters/file_adapter'
require
'paperclip/io_adapters/file_adapter'
require
'paperclip/io_adapters/stringio_adapter'
require
'paperclip/io_adapters/stringio_adapter'
...
...
lib/paperclip/attachment.rb
View file @
e54b5bdf
...
@@ -93,6 +93,7 @@ module Paperclip
...
@@ -93,6 +93,7 @@ module Paperclip
ensure_required_accessors!
ensure_required_accessors!
file
=
Paperclip
.
io_adapters
.
for
(
uploaded_file
)
file
=
Paperclip
.
io_adapters
.
for
(
uploaded_file
)
return
nil
if
not
file
.
assignment?
self
.
clear
(
*
only_process
)
self
.
clear
(
*
only_process
)
return
nil
if
file
.
nil?
return
nil
if
file
.
nil?
...
...
lib/paperclip/io_adapters/abstract_adapter.rb
View file @
e54b5bdf
...
@@ -23,6 +23,14 @@ module Paperclip
...
@@ -23,6 +23,14 @@ module Paperclip
@original_filename
=
new_filename
.
gsub
(
OS_RESTRICTED_CHARACTERS
,
"_"
)
@original_filename
=
new_filename
.
gsub
(
OS_RESTRICTED_CHARACTERS
,
"_"
)
end
end
def
nil?
false
end
def
assignment?
true
end
private
private
def
destination
def
destination
...
...
lib/paperclip/io_adapters/empty_string_adapter.rb
0 → 100644
View file @
e54b5bdf
module
Paperclip
class
EmptyStringAdapter
<
AbstractAdapter
def
initialize
(
target
)
end
def
nil?
false
end
def
assignment?
false
end
end
end
Paperclip
.
io_adapters
.
register
Paperclip
::
EmptyStringAdapter
do
|
target
|
target
.
is_a?
(
String
)
&&
target
.
empty?
end
test/io_adapters/abstract_adapter_test.rb
View file @
e54b5bdf
...
@@ -47,4 +47,12 @@ class AbstractAdapterTest < Test::Unit::TestCase
...
@@ -47,4 +47,12 @@ class AbstractAdapterTest < Test::Unit::TestCase
assert_equal
"awesome_file_name.png"
,
@adapter
.
original_filename
assert_equal
"awesome_file_name.png"
,
@adapter
.
original_filename
end
end
should
'be an assignment'
do
assert
TestAdapter
.
new
.
assignment?
end
should
'not be nil'
do
assert
!
TestAdapter
.
new
.
nil?
end
end
end
test/io_adapters/empty_string_adapter_test.rb
0 → 100644
View file @
e54b5bdf
require
'./test/helper'
class
EmptyStringAdapterTest
<
Test
::
Unit
::
TestCase
context
'a new instance'
do
setup
do
@subject
=
Paperclip
.
io_adapters
.
for
(
''
)
end
should
"return false for a call to nil?"
do
assert
!
@subject
.
nil?
end
should
'return false for a call to assignment?'
do
assert
!
@subject
.
assignment?
end
end
end
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