Permalink
Browse files

Cropping from 0 type geometry (height or width) should raise a ZeroIn…

…itialCropGeometryError and not a NaN.
  • Loading branch information...
1 parent 5150b39 commit b30072921be8768c09a8d148edcb66d153b8dc28 @adriancb committed Oct 24, 2011
Showing with 3 additions and 3 deletions.
  1. +1 −1 lib/paperclip/geometry.rb
  2. +2 −2 test/geometry_test.rb
@@ -89,7 +89,7 @@ def inspect
# is weighted at the center of the Geometry.
def transformation_to dst, crop = false
if crop
- raise InvalidCropGeometryError if self.width <= 0 or self.height <= 0
+ raise ZeroInitialCropGeometryError if self.width <= 0 or self.height <= 0
ratio = Geometry.new( dst.width / self.width, dst.height / self.height )
scale_geometry, scale = scaling(dst, ratio)
View
@@ -139,13 +139,13 @@ class GeometryTest < Test::Unit::TestCase
should "raise a ZeroInitialCropGeometryError when cropping from an initial width geometry that is 0" do
assert @src = Paperclip::Geometry.parse("0x100")
assert @dst = Paperclip::Geometry.parse("123x456>")
- assert_raise(Paperclip::InvalidCropGeometryError) { @src.transformation_to(@dst, true) }
+ assert_raise(Paperclip::ZeroInitialCropGeometryError) { @src.transformation_to(@dst, true) }
end
should "raise a ZeroInitialCropGeometryError when cropping from an initial height geometry that is 0" do
assert @src = Paperclip::Geometry.parse("30x0")
assert @dst = Paperclip::Geometry.parse("123x456>")
- assert_raise(Paperclip::InvalidCropGeometryError) { @src.transformation_to(@dst, true) }
+ assert_raise(Paperclip::ZeroInitialCropGeometryError) { @src.transformation_to(@dst, true) }
end
should "let us know when a command isn't found versus a processing error" do

0 comments on commit b300729

Please sign in to comment.