Commit 9e71b211 by Jon Yurek

Moved the geometry proc running to assignment instead of initialization

parent f07487f6
......@@ -90,6 +90,7 @@ module Paperclip
@dirty = true
solidify_style_definitions
post_process if valid?
# Reset the file size if the original file was reprocessed.
......@@ -303,6 +304,11 @@ module Paperclip
:convert_options => extra_options_for(name)
}.merge(@styles[name])
end
end
end
def solidify_style_definitions #:nodoc:
@styles.each do |name, args|
if @styles[name][:geometry].respond_to?(:call)
@styles[name][:geometry] = @styles[name][:geometry].call(instance)
end
......
......@@ -182,11 +182,22 @@ class AttachmentTest < Test::Unit::TestCase
@attachment = Dummy.new.avatar
end
should "not run the procs immediately" do
assert_kind_of Proc, @attachment.styles[:normal][:geometry]
end
context "when assigned" do
setup do
@file = StringIO.new(".")
@attachment.assign(@file)
end
should "have the correct geometry" do
assert_equal "50x50#", @attachment.styles[:normal][:geometry]
end
end
end
end
context "An attachment with both 'normal' and hash-style styles" do
setup do
......
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