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
6deeaf76
Commit
6deeaf76
authored
Aug 07, 2008
by
Barry Hess
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for convert_options thumbnail setting.
parent
c0257f81
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
0 deletions
+58
-0
test/integration_test.rb
+32
-0
test/thumbnail_test.rb
+26
-0
No files found.
test/integration_test.rb
View file @
6deeaf76
...
...
@@ -91,6 +91,38 @@ class IntegrationTest < Test::Unit::TestCase
end
end
context
"A model with no thumbnail_convert_options setting"
do
setup
do
rebuild_model
:styles
=>
{
:large
=>
"300x300>"
,
:medium
=>
"100x100"
,
:thumb
=>
[
"32x32#"
,
:gif
]
},
:default_style
=>
:medium
,
:url
=>
"/:attachment/:class/:style/:id/:basename.:extension"
,
:path
=>
":rails_root/tmp/:attachment/:class/:style/:id/:basename.:extension"
@dummy
=
Dummy
.
new
end
should
"have its definition return nil when asked about convert_options"
do
assert
!
Dummy
.
attachment_definitions
[
:avatar
][
:thumbnail_convert_options
]
end
context
"redefined to have convert_options setting"
do
setup
do
rebuild_model
:styles
=>
{
:large
=>
"300x300>"
,
:medium
=>
"100x100"
,
:thumb
=>
[
"32x32#"
,
:gif
]
},
:thumbnail_convert_options
=>
"-strip -depth 8"
,
:default_style
=>
:medium
,
:url
=>
"/:attachment/:class/:style/:id/:basename.:extension"
,
:path
=>
":rails_root/tmp/:attachment/:class/:style/:id/:basename.:extension"
end
should
"have its definition return convert_options value when asked about convert_options"
do
assert_equal
"-strip -depth 8"
,
Dummy
.
attachment_definitions
[
:avatar
][
:thumbnail_convert_options
]
end
end
end
context
"A model with a filesystem attachment"
do
setup
do
rebuild_model
:styles
=>
{
:large
=>
"300x300>"
,
...
...
test/thumbnail_test.rb
View file @
6deeaf76
...
...
@@ -90,6 +90,10 @@ class ThumbnailTest < Test::Unit::TestCase
should
"have whiny_thumbnails turned on by default"
do
assert
@thumb
.
whiny_thumbnails
end
should
"have convert_options set to nil by default"
do
assert_equal
nil
,
@thumb
.
convert_options
end
should
"send the right command to convert when sent #make"
do
@thumb
.
expects
(
:system
).
with
do
|
arg
|
...
...
@@ -103,5 +107,27 @@ class ThumbnailTest < Test::Unit::TestCase
assert_match
/100x50/
,
`identify
#{
dst
.
path
}
`
end
end
context
"being thumbnailed with convert options set"
do
setup
do
@thumb
=
Paperclip
::
Thumbnail
.
new
(
@file
,
"100x50#"
,
format
=
nil
,
whiny_thumbnails
=
true
,
convert_options
=
"-strip -depth 8"
)
end
should
"have convert_options value set"
do
assert_equal
"-strip -depth 8"
,
@thumb
.
convert_options
end
should
"send the right command to convert when sent #make"
do
@thumb
.
expects
(
:system
).
with
do
|
arg
|
arg
.
match
%r{convert
\s
+"
#{
File
.
expand_path
(
@thumb
.
file
.
path
)
}
"
\s
+-scale
\s
+
\"
x50
\"\s
+-crop
\s
+
\"
100x50
\+
114
\+
0
\"\s
+
\+
repage
\s
+-strip
\s
+-depth
\s
+8
\s
+".*?"}
end
@thumb
.
make
end
should
"create the thumbnail when sent #make"
do
dst
=
@thumb
.
make
assert_match
/100x50/
,
`identify
#{
dst
.
path
}
`
end
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