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
826c4e6e
Commit
826c4e6e
authored
Dec 30, 2008
by
Jon Yurek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed a bug where modifying the :original didn't report the correct file_size
parent
3cc7ab7d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
3 deletions
+22
-3
lib/paperclip/attachment.rb
+1
-1
test/attachment_test.rb
+4
-2
test/integration_test.rb
+17
-0
No files found.
lib/paperclip/attachment.rb
View file @
826c4e6e
...
...
@@ -92,7 +92,7 @@ module Paperclip
post_process
if
valid?
# Reset the file size if the original file was reprocessed.
instance_write
(
:file_size
,
uploaded_file
.
size
.
to_i
)
instance_write
(
:file_size
,
@queued_for_write
[
:original
]
.
size
.
to_i
)
ensure
uploaded_file
.
close
if
close_uploaded_file
validate
...
...
test/attachment_test.rb
View file @
826c4e6e
...
...
@@ -298,11 +298,13 @@ class AttachmentTest < Test::Unit::TestCase
rebuild_model
@not_file
=
mock
@tempfile
=
mock
@not_file
.
stubs
(
:nil?
).
returns
(
false
)
@not_file
.
expects
(
:to_tempfile
).
returns
(
self
)
@not_file
.
expects
(
:size
).
returns
(
10
)
@tempfile
.
expects
(
:size
).
returns
(
10
)
@not_file
.
expects
(
:to_tempfile
).
returns
(
@tempfile
)
@not_file
.
expects
(
:original_filename
).
returns
(
"sheep_say_bæ.png
\r\n
"
)
@not_file
.
expects
(
:content_type
).
returns
(
"image/png
\r\n
"
)
@not_file
.
expects
(
:size
).
returns
(
10
).
times
(
2
)
@dummy
=
Dummy
.
new
@attachment
=
@dummy
.
avatar
...
...
test/integration_test.rb
View file @
826c4e6e
...
...
@@ -51,6 +51,23 @@ class IntegrationTest < Test::Unit::TestCase
end
end
context
"A model that modifies its original"
do
setup
do
rebuild_model
:styles
=>
{
:original
=>
"2x2#"
}
@dummy
=
Dummy
.
new
@file
=
File
.
new
(
File
.
join
(
File
.
dirname
(
__FILE__
),
"fixtures"
,
"5k.png"
),
'rb'
)
@dummy
.
avatar
=
@file
end
should
"report the file size of the processed file and not the original"
do
assert_not_equal
@file
.
size
,
@dummy
.
avatar
.
size
end
teardown
{
@file
.
close
}
end
context
"A model with attachments scoped under an id"
do
setup
do
rebuild_model
:styles
=>
{
:large
=>
"100x100"
,
...
...
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