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
ec09660b
Commit
ec09660b
authored
Feb 22, 2009
by
Rob Anderton
Committed by
Jon Yurek
Feb 22, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved style solidification to the post_process method, this also fixes the reprocess! method
parent
723618a2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
5 deletions
+27
-5
lib/paperclip/attachment.rb
+3
-4
test/attachment_test.rb
+22
-1
test/integration_test.rb
+2
-0
No files found.
lib/paperclip/attachment.rb
View file @
ec09660b
...
...
@@ -92,7 +92,6 @@ module Paperclip
@dirty
=
true
solidify_style_definitions
post_process
if
valid?
# Reset the file size if the original file was reprocessed.
...
...
@@ -314,9 +313,8 @@ module Paperclip
def
solidify_style_definitions
#:nodoc:
@styles
.
each
do
|
name
,
args
|
if
@styles
[
name
][
:geometry
].
respond_to?
(
:call
)
@styles
[
name
][
:geometry
]
=
@styles
[
name
][
:geometry
].
call
(
instance
)
end
@styles
[
name
][
:geometry
]
=
@styles
[
name
][
:geometry
].
call
(
instance
)
if
@styles
[
name
][
:geometry
].
respond_to?
(
:call
)
@styles
[
name
][
:processors
]
=
@styles
[
name
][
:processors
].
call
(
instance
)
if
@styles
[
name
][
:processors
].
respond_to?
(
:call
)
end
end
...
...
@@ -336,6 +334,7 @@ module Paperclip
def
post_process
#:nodoc:
return
if
@queued_for_write
[
:original
].
nil?
solidify_style_definitions
return
if
fire_events
(
:before
)
post_process_styles
return
if
fire_events
(
:after
)
...
...
test/attachment_test.rb
View file @
ec09660b
...
...
@@ -265,7 +265,28 @@ class AttachmentTest < Test::Unit::TestCase
end
end
end
context
"An attachment with :processors that is a proc"
do
setup
do
rebuild_model
:styles
=>
{
:normal
=>
''
},
:processors
=>
lambda
{
|
a
|
[
:test
]
}
@attachment
=
Dummy
.
new
.
avatar
end
should
"not run the proc immediately"
do
assert_kind_of
Proc
,
@attachment
.
styles
[
:normal
][
:processors
]
end
context
"when assigned"
do
setup
do
@attachment
.
assign
(
StringIO
.
new
(
"."
))
end
should
"have the correct processors"
do
assert_equal
[
:test
],
@attachment
.
styles
[
:normal
][
:processors
]
end
end
end
context
"An attachment with erroring processor"
do
setup
do
rebuild_model
:processor
=>
[
:thumbnail
],
:styles
=>
{
:small
=>
''
},
:whiny_thumbnails
=>
true
...
...
test/integration_test.rb
View file @
ec09660b
...
...
@@ -39,6 +39,7 @@ class IntegrationTest < Test::Unit::TestCase
setup
do
Dummy
.
class_eval
do
has_attached_file
:avatar
,
:styles
=>
{
:thumb
=>
"150x25#"
}
has_attached_file
:avatar
,
:styles
=>
{
:thumb
=>
"150x25#"
,
:dynamic
=>
lambda
{
|
a
|
'50x50#'
}
}
end
@d2
=
Dummy
.
find
(
@dummy
.
id
)
@d2
.
avatar
.
reprocess!
...
...
@@ -47,6 +48,7 @@ class IntegrationTest < Test::Unit::TestCase
should
"create its thumbnails properly"
do
assert_match
/\b150x25\b/
,
`identify "
#{
@dummy
.
avatar
.
path
(
:thumb
)
}
"`
assert_match
/\b50x50\b/
,
`identify "
#{
@dummy
.
avatar
.
path
(
:dynamic
)
}
"`
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