Commit af1ae004 by Jon Yurek

Made geometry spec case insensitive.

parent 81704d1d
...@@ -26,7 +26,7 @@ module Paperclip ...@@ -26,7 +26,7 @@ module Paperclip
# Parses a "WxH" formatted string, where W is the width and H is the height. # Parses a "WxH" formatted string, where W is the width and H is the height.
def self.parse string def self.parse string
if match = (string && string.match(/\b(\d*)x?(\d*)\b([\>\<\#\@\%^!])?/)) if match = (string && string.match(/\b(\d*)x?(\d*)\b([\>\<\#\@\%^!])?/i))
Geometry.new(*match[1,3]) Geometry.new(*match[1,3])
end end
end end
......
...@@ -49,6 +49,15 @@ class GeometryTest < Test::Unit::TestCase ...@@ -49,6 +49,15 @@ class GeometryTest < Test::Unit::TestCase
assert_nil @geo.modifier assert_nil @geo.modifier
end end
should "treat x and X the same in geometries" do
@lower = Paperclip::Geometry.parse("123x456")
@upper = Paperclip::Geometry.parse("123X456")
assert_equal 123, @lower.width
assert_equal 123, @upper.width
assert_equal 456, @lower.height
assert_equal 456, @upper.height
end
['>', '<', '#', '@', '%', '^', '!', nil].each do |mod| ['>', '<', '#', '@', '%', '^', '!', nil].each do |mod|
should "ensure the modifier #{mod.inspect} is preserved" do should "ensure the modifier #{mod.inspect} is preserved" do
assert @geo = Paperclip::Geometry.parse("123x456#{mod}") assert @geo = Paperclip::Geometry.parse("123x456#{mod}")
......
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