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
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
4 deletions
+25
-4
lib/paperclip/attachment.rb
+2
-0
test/attachment_test.rb
+23
-4
No files found.
lib/paperclip/attachment.rb
View file @
a6c86832
...
@@ -441,6 +441,8 @@ module Paperclip
...
@@ -441,6 +441,8 @@ module Paperclip
def
cleanup_filename
(
filename
)
def
cleanup_filename
(
filename
)
if
@options
[
:restricted_characters
]
if
@options
[
:restricted_characters
]
filename
.
gsub
(
@options
[
:restricted_characters
],
'_'
)
filename
.
gsub
(
@options
[
:restricted_characters
],
'_'
)
else
filename
end
end
end
end
end
end
...
...
test/attachment_test.rb
View file @
a6c86832
...
@@ -768,6 +768,14 @@ class AttachmentTest < Test::Unit::TestCase
...
@@ -768,6 +768,14 @@ class AttachmentTest < Test::Unit::TestCase
context
"with specified regexp replacement"
do
context
"with specified regexp replacement"
do
setup
do
setup
do
@old_defaults
=
Paperclip
::
Attachment
.
default_options
.
dup
@old_defaults
=
Paperclip
::
Attachment
.
default_options
.
dup
end
teardown
do
Paperclip
::
Attachment
.
default_options
.
merge!
@old_defaults
end
context
'as another regexp'
do
setup
do
Paperclip
::
Attachment
.
default_options
.
merge!
:restricted_characters
=>
/o/
Paperclip
::
Attachment
.
default_options
.
merge!
:restricted_characters
=>
/o/
@file
.
stubs
(
:original_filename
).
returns
(
"goood.png"
)
@file
.
stubs
(
:original_filename
).
returns
(
"goood.png"
)
...
@@ -775,14 +783,25 @@ class AttachmentTest < Test::Unit::TestCase
...
@@ -775,14 +783,25 @@ class AttachmentTest < Test::Unit::TestCase
@dummy
.
avatar
=
@file
@dummy
.
avatar
=
@file
end
end
teardown
do
Paperclip
::
Attachment
.
default_options
.
merge!
@old_defaults
end
should
"match and convert that character"
do
should
"match and convert that character"
do
assert_equal
"g___d.png"
,
@dummy
.
avatar
.
original_filename
assert_equal
"g___d.png"
,
@dummy
.
avatar
.
original_filename
end
end
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
end
context
"Attachment with uppercase extension and a default style"
do
context
"Attachment with uppercase extension and a default style"
do
...
...
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