Commit b8f061c2 by Prem Sichanugrist

Revert "Adding Attachment#geometry to get file's dimension"

It's not working correctly as expected, so let's revert this for now.

This reverts commit 51bb0f9f.
parent d61ddd5c
......@@ -319,11 +319,6 @@ module Paperclip
instance.send(getter) if responds || attr.to_s == "file_name"
end
# Returns a geometry object which you can get the image's dimension.
def geometry(style = :original)
Geometry.from_file(path(style))
end
private
def path_option
......
......@@ -11,11 +11,6 @@ module Paperclip
@modifier = modifier
end
# Returns the equality based on height, width, and modifier
def ==(other)
height == other.height && width == other.width && modifier == other.modifier
end
# Uses ImageMagick to determing the dimensions of a file, passed in as either a
# File or path.
# NOTE: (race cond) Do not reassign the 'file' variable inside this method as it is likely to be
......
......@@ -1158,19 +1158,4 @@ class AttachmentTest < Test::Unit::TestCase
end
end
context "attachment's geometry" do
setup do
rebuild_model
@dummy = Dummy.new
@file = File.new(File.join(File.dirname(__FILE__), "fixtures", "5k.png"), 'rb')
@dummy.avatar = @file
@dummy.save!
@attachment = @dummy.avatar
@geometry = Paperclip::Geometry.from_file(@file.path)
end
should "return a correct geometry object" do
assert_equal @geometry, @attachment.geometry
end
end
end
require './test/helper'
class GeometryTest < Test::Unit::TestCase
context "equality check" do
should "return true when width, height, modifier are all the same" do
assert_equal Paperclip::Geometry.new(100, 100, "foo"),
Paperclip::Geometry.new(100, 100, "foo")
end
should "return false if width, height, modifier are not the same" do
assert_not_equal Paperclip::Geometry.new(100, 100, "foo"),
Paperclip::Geometry.new(100, 200, "foo")
assert_not_equal Paperclip::Geometry.new(100, 100, "foo"),
Paperclip::Geometry.new(200, 100, "foo")
assert_not_equal Paperclip::Geometry.new(100, 100, "foo"),
Paperclip::Geometry.new(100, 100, "bar")
end
end
context "Paperclip::Geometry" do
should "correctly report its given dimensions" do
assert @geo = Paperclip::Geometry.new(1024, 768)
assert_equal 1024, @geo.width
......@@ -154,13 +139,11 @@ class GeometryTest < Test::Unit::TestCase
should "let us know when a command isn't found versus a processing error" do
old_path = ENV['PATH']
begin
silence_stream(STDERR) do
ENV['PATH'] = ''
assert_raises(Paperclip::Errors::CommandNotFoundError) do
file = File.join(File.dirname(__FILE__), "fixtures", "5k.png")
@geo = Paperclip::Geometry.from_file(file)
end
end
ensure
ENV['PATH'] = old_path
end
......@@ -219,4 +202,5 @@ class GeometryTest < Test::Unit::TestCase
end
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