test/model_test.rb in paperdragon-0.0.5 vs test/model_test.rb in paperdragon-0.0.6

- old
+ new

@@ -45,8 +45,43 @@ model.image do |v| v.reprocess!(:thumb, "1") { |j| j.thumb!("8x8") } end + model.image_meta_data.class.must_equal Hash model.image_meta_data.must_equal({:original=>{:width=>216, :height=>63, :uid=>"original-apotomo.png"}, :thumb=>{:width=>8, :height=>2, :uid=>"thumb-apotomo-1.png"}}) + end + + + # passing options from image(file, {..}) to the Attachment. + class ImageWithAttachment < OpenStruct + include Paperdragon::Model + + class Attachment < Paperdragon::Attachment + def build_uid(style, file) + @options.inspect # we use options here! + end + + def rebuild_uid(style, file) + @options.inspect + end + end + + processable :image, Attachment + end + + it do + model = ImageWithAttachment.new + model.image(logo, :path => "/") do |v| + v.process!(:original) + end + + # this assures that both :model and :path (see above) are passed through. + model.image_meta_data.must_equal({:original=>{:width=>216, :height=>63, :uid=>"{:path=>\"/\", :model=>_<PaperdragonModelTest::ImageWithAttachment>}"}}) + + model.image(nil, :new => true) do |v| + v.reprocess!(:original, "1") { |j| j.thumb!("8x8") } + end + + model.image_meta_data.must_equal({:original=>{:width=>8, :height=>2, :uid=>"{:new=>true, :model=>#<PaperdragonModelTest::ImageWithAttachment image_meta_data={:original=>{:width=>216, :height=>63, :uid=>\"{:path=>\\\"/\\\", :model=>_<PaperdragonModelTest::ImageWithAttachment>}\"}}>}"}}) end end \ No newline at end of file