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
8b778b30
Commit
8b778b30
authored
Apr 24, 2012
by
Jon Yurek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enforce saving content_type as a string with test
parent
e59d0b53
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
2 deletions
+17
-2
lib/paperclip/attachment.rb
+1
-1
lib/paperclip/io_adapters/stringio_adapter.rb
+1
-1
test/attachment_test.rb
+15
-0
No files found.
lib/paperclip/attachment.rb
View file @
8b778b30
...
@@ -95,7 +95,7 @@ module Paperclip
...
@@ -95,7 +95,7 @@ module Paperclip
@queued_for_write
[
:original
]
=
file
@queued_for_write
[
:original
]
=
file
instance_write
(
:file_name
,
cleanup_filename
(
file
.
original_filename
))
instance_write
(
:file_name
,
cleanup_filename
(
file
.
original_filename
))
instance_write
(
:content_type
,
file
.
content_type
)
instance_write
(
:content_type
,
file
.
content_type
.
to_s
.
strip
)
instance_write
(
:file_size
,
file
.
size
)
instance_write
(
:file_size
,
file
.
size
)
instance_write
(
:fingerprint
,
file
.
fingerprint
)
if
instance_respond_to?
(
:fingerprint
)
instance_write
(
:fingerprint
,
file
.
fingerprint
)
if
instance_respond_to?
(
:fingerprint
)
instance_write
(
:updated_at
,
Time
.
now
)
instance_write
(
:updated_at
,
Time
.
now
)
...
...
lib/paperclip/io_adapters/stringio_adapter.rb
View file @
8b778b30
...
@@ -16,7 +16,7 @@ module Paperclip
...
@@ -16,7 +16,7 @@ module Paperclip
def
content_type
def
content_type
@content_type
||=
@target
.
content_type
if
@target
.
respond_to?
(
:content_type
)
@content_type
||=
@target
.
content_type
if
@target
.
respond_to?
(
:content_type
)
@content_type
||=
"text/plain"
@content_type
||=
"text/plain"
@content_type
.
strip
@content_type
end
end
def
size
def
size
...
...
test/attachment_test.rb
View file @
8b778b30
...
@@ -691,6 +691,21 @@ class AttachmentTest < Test::Unit::TestCase
...
@@ -691,6 +691,21 @@ class AttachmentTest < Test::Unit::TestCase
end
end
end
end
context
"Assigning an attachment"
do
setup
do
rebuild_model
:styles
=>
{
:something
=>
"100x100#"
}
@file
=
StringIO
.
new
(
"."
)
@file
.
stubs
(
:original_filename
).
returns
(
"5k.png
\n\n
"
)
@file
.
stubs
(
:content_type
).
returns
(
MIME
::
Type
.
new
(
"image/png"
))
@dummy
=
Dummy
.
new
@dummy
.
avatar
=
@file
end
should
"make sure the content_type is a string"
do
assert_equal
"image/png"
,
@dummy
.
avatar
.
instance
.
avatar_content_type
end
end
context
"Attachment with strange letters"
do
context
"Attachment with strange letters"
do
setup
do
setup
do
rebuild_model
rebuild_model
...
...
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