Permalink
Browse files

Tested my changes.

  • Loading branch information...
1 parent 55b07e4 commit 599a74dfa5b2602165c7511f2f8eff829b7627a7 Darrick Wiebe committed Feb 13, 2009
Showing with 52 additions and 0 deletions.
  1. +13 −0 test/geometry_test.rb
  2. +39 −0 test/thumbnail_test.rb
View
@@ -49,6 +49,19 @@ class GeometryTest < Test::Unit::TestCase
assert_nil @geo.modifier
end
+ should "not be generated if the string is blank" do
+ assert_nil Paperclip::Geometry.parse('')
+ end
+
+ should 'not be generated if the arguement is nil' do
+ assert_nil Paperclip::Geometry.parse(nil)
+ end
+
+ should 'do nothing for transformation_to nil' do
+ @geo = Paperclip::Geometry.new(100, 200)
+ assert_equal [nil, nil], @geo.transformation_to(nil)
+ end
+
['>', '<', '#', '@', '%', '^', '!', nil].each do |mod|
should "ensure the modifier #{mod.inspect} is preserved" do
assert @geo = Paperclip::Geometry.parse("123x456#{mod}")
@@ -142,6 +142,45 @@ class ThumbnailTest < Test::Unit::TestCase
end
end
+ context "being thumbnailed with nil geometry" do
+ setup do
+ @file = File.new(File.join(File.dirname(__FILE__), "fixtures", "5k.png"), 'rb')
+ @thumb = Paperclip::Thumbnail.new(@file, :geometry => nil)
+ end
+
+ teardown { @file.close }
+
+ should "report its correct current and target geometries" do
+ assert_nil @thumb.target_geometry
+ assert_equal "434x66", @thumb.current_geometry.to_s
+ end
+
+ should "report its correct format" do
+ assert_nil @thumb.format
+ end
+
+ should "have whiny turned on by default" do
+ assert @thumb.whiny
+ 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
+ Paperclip::Tempfile.expects(:new).returns(mock('Tempfile', :binmode => nil, :path => 'some_path'))
+ Paperclip.expects(:"`").with do |arg|
+ arg.match %r{^convert +"#{File.expand_path(@thumb.file.path)}\[0\]" +"[^"]*" +2>/dev/null *$}
+ end
+ @thumb.make
+ end
+
+ should "create the thumbnail when sent #make" do
+ dst = @thumb.make
+ assert_match /434x66/, `identify "#{dst.path}"`
+ end
+ end
+
context "A multipage PDF" do
setup do
@file = File.new(File.join(File.dirname(__FILE__), "fixtures", "twopage.pdf"), 'rb')

0 comments on commit 599a74d

Please sign in to comment.