Skip to content

Commit

Permalink
Tested my changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Darrick Wiebe committed Feb 13, 2009
1 parent 55b07e4 commit 599a74d
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/geometry_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down
39 changes: 39 additions & 0 deletions test/thumbnail_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 599a74d

Please sign in to comment.