Skip to content

Commit

Permalink
Procs are working inside geomety specifications again.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Yurek committed Jan 19, 2009
1 parent 75d10b9 commit 5647740
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/paperclip/attachment.rb
Expand Up @@ -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

Expand Down
18 changes: 18 additions & 0 deletions test/attachment_test.rb
Expand Up @@ -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 => {
Expand Down

0 comments on commit 5647740

Please sign in to comment.