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
a6c86832
Commit
a6c86832
authored
May 04, 2012
by
Prem Sichanugrist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle the case when :restricted_characters is nil
Fixes #762
parent
3a3c2277
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
7 deletions
+28
-7
lib/paperclip/attachment.rb
+2
-0
test/attachment_test.rb
+26
-7
No files found.
lib/paperclip/attachment.rb
View file @
a6c86832
...
...
@@ -441,6 +441,8 @@ module Paperclip
def
cleanup_filename
(
filename
)
if
@options
[
:restricted_characters
]
filename
.
gsub
(
@options
[
:restricted_characters
],
'_'
)
else
filename
end
end
end
...
...
test/attachment_test.rb
View file @
a6c86832
...
...
@@ -768,19 +768,38 @@ class AttachmentTest < Test::Unit::TestCase
context
"with specified regexp replacement"
do
setup
do
@old_defaults
=
Paperclip
::
Attachment
.
default_options
.
dup
Paperclip
::
Attachment
.
default_options
.
merge!
:restricted_characters
=>
/o/
@file
.
stubs
(
:original_filename
).
returns
(
"goood.png"
)
@dummy
=
Dummy
.
new
@dummy
.
avatar
=
@file
end
teardown
do
Paperclip
::
Attachment
.
default_options
.
merge!
@old_defaults
end
should
"match and convert that character"
do
assert_equal
"g___d.png"
,
@dummy
.
avatar
.
original_filename
context
'as another regexp'
do
setup
do
Paperclip
::
Attachment
.
default_options
.
merge!
:restricted_characters
=>
/o/
@file
.
stubs
(
:original_filename
).
returns
(
"goood.png"
)
@dummy
=
Dummy
.
new
@dummy
.
avatar
=
@file
end
should
"match and convert that character"
do
assert_equal
"g___d.png"
,
@dummy
.
avatar
.
original_filename
end
end
context
'as nil'
do
setup
do
Paperclip
::
Attachment
.
default_options
.
merge!
:restricted_characters
=>
nil
@file
.
stubs
(
:original_filename
).
returns
(
"goood.png"
)
@dummy
=
Dummy
.
new
@dummy
.
avatar
=
@file
end
should
"ignore and return the original file name"
do
assert_equal
"goood.png"
,
@dummy
.
avatar
.
original_filename
end
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