Commit 6deeaf76 by Barry Hess

Add tests for convert_options thumbnail setting.

parent c0257f81
......@@ -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>",
......
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment