Skip to content
Browse files

Procs are working inside geomety specifications again.

  • Loading branch information...
1 parent 75d10b9 commit 56477408d78dd8c935da954b846d91edc69a4bd0 @jyurek jyurek committed Jan 19, 2009
Showing with 21 additions and 0 deletions.
  1. +3 −0 lib/paperclip/attachment.rb
  2. +18 −0 test/attachment_test.rb
View
3 lib/paperclip/attachment.rb
@@ -303,6 +303,9 @@ def normalize_style_definition #:nodoc:
:convert_options => extra_options_for(name)
}.merge(@styles[name])
end
+ if @styles[name][:geometry].respond_to?(:call)
+ @styles[name][:geometry] = @styles[name][:geometry].call(instance)
+ end
end
end
View
18 test/attachment_test.rb
@@ -170,6 +170,24 @@ def thumb; "-thumb"; end
end
end
+ geometry_specs = [
+ [ lambda{|z| "50x50#" }, :png ],
+ lambda{|z| "50x50#" },
+ { :geometry => lambda{|z| "50x50#" } }
+ ]
+ geometry_specs.each do |geometry_spec|
+ context "An attachment geomtry like #{geometry_spec}" do
+ setup do
+ rebuild_model :styles => { :normal => geometry_spec }
+ @attachment = Dummy.new.avatar
+ end
+
+ should "have the correct geometry" do
+ assert_equal "50x50#", @attachment.styles[:normal][:geometry]
+ end
+ end
+ end
+
context "An attachment with both 'normal' and hash-style styles" do
setup do
rebuild_model :styles => {

0 comments on commit 5647740

Please sign in to comment.
Something went wrong with that request. Please try again.