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
1d023306
Commit
1d023306
authored
Dec 24, 2008
by
Jon Yurek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Multiple processors can be specified, and styles can take hashes instead of strings/arrays
parent
f1118c6b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
0 deletions
+46
-0
lib/paperclip/attachment.rb
+6
-0
test/attachment_test.rb
+40
-0
No files found.
lib/paperclip/attachment.rb
View file @
1d023306
...
...
@@ -267,6 +267,12 @@ module Paperclip
:whiny
=>
@whiny
,
:convert_options
=>
extra_options_for
(
name
)
}
else
@styles
[
name
]
=
{
:processors
=>
@processors
,
:whiny
=>
@whiny
,
:convert_options
=>
extra_options_for
(
name
)
}.
merge
(
@styles
[
name
])
end
end
end
...
...
test/attachment_test.rb
View file @
1d023306
...
...
@@ -134,6 +134,46 @@ class AttachmentTest < Test::Unit::TestCase
end
end
context
"An attachment with both 'normal' and hash-style styles"
do
setup
do
rebuild_model
:styles
=>
{
:normal
=>
[
"50x50#"
,
:png
],
:hash
=>
{
:geometry
=>
"50x50#"
,
:format
=>
:png
}
}
@dummy
=
Dummy
.
new
@attachment
=
@dummy
.
avatar
end
[
:processors
,
:whiny
,
:convert_options
,
:geometry
,
:format
].
each
do
|
field
|
should
"have the same
#{
field
}
field"
do
assert_equal
@attachment
.
styles
[
:normal
][
field
],
@attachment
.
styles
[
:hash
][
field
]
end
end
end
context
"An attachment with multiple processors"
do
setup
do
class
Paperclip
::
Test
<
Paperclip
::
Processor
;
end
@style_params
=
{
:once
=>
{
:one
=>
1
,
:two
=>
2
}
}
rebuild_model
:processors
=>
[
:thumbnail
,
:test
],
:styles
=>
@style_params
@dummy
=
Dummy
.
new
@file
=
StringIO
.
new
(
"..."
)
@file
.
stubs
(
:to_tempfile
).
returns
(
@file
)
Paperclip
::
Test
.
stubs
(
:make
).
returns
(
@file
)
Paperclip
::
Thumbnail
.
stubs
(
:make
).
returns
(
@file
)
end
context
"when assigned"
do
setup
{
@dummy
.
avatar
=
@file
}
before_should
"call #make on all specified processors"
do
expected_params
=
@style_params
[
:once
].
merge
({
:processors
=>
[
:thumbnail
,
:test
],
:whiny
=>
nil
,
:convert_options
=>
""
})
Paperclip
::
Thumbnail
.
expects
(
:make
).
with
(
@file
,
expected_params
).
returns
(
@file
)
Paperclip
::
Test
.
expects
(
:make
).
with
(
@file
,
expected_params
).
returns
(
@file
)
end
end
end
context
"Assigning an attachment with post_process hooks"
do
setup
do
rebuild_model
:styles
=>
{
:something
=>
"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