Commit 5b44407a by Lewisou Committed by Jon Yurek

test code of adding Proc support to style rule own processors

parent 56614294
...@@ -30,6 +30,7 @@ module Paperclip ...@@ -30,6 +30,7 @@ module Paperclip
# (which method (in the attachment) will call any supplied procs) # (which method (in the attachment) will call any supplied procs)
# There is an important change of interface here: a style rule can set its own processors # There is an important change of interface here: a style rule can set its own processors
# by default we behave as before, though. # by default we behave as before, though.
# if a proc has been supplied, we call it here
def processors def processors
@processors || attachment.processors @processors || attachment.processors
end end
......
...@@ -138,4 +138,26 @@ class StyleTest < Test::Unit::TestCase ...@@ -138,4 +138,26 @@ class StyleTest < Test::Unit::TestCase
end end
end end
context "A style rule with :processors supplied as procs" do
setup do
@attachment = attachment :path => ":basename.:extension",
:styles => {
:foo => {
:geometry => "100x100#",
:format => :png,
:processors => lambda{|a| [:test]}
}
},
:processors => [:thumbnail]
end
should "defer processing of procs until they are needed" do
assert_kind_of Proc, @attachment.styles[:foo].instance_variable_get("@processors")
end
should "call procs when they are needed" do
assert_equal [:test], @attachment.styles[:foo].processors
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