Commit 9e71b211 by Jon Yurek

Moved the geometry proc running to assignment instead of initialization

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