From 39a984f06871be482206746185a67206de986544 Mon Sep 17 00:00:00 2001 From: Vasiliy Ermolovich Date: Wed, 21 Nov 2012 21:55:56 +0300 Subject: [PATCH] add spec to ensure that decorators work with delegation --- spec/draper/decorator_spec.rb | 4 ++++ spec/support/models/product.rb | 2 ++ spec/support/models/some_thing.rb | 3 +++ 3 files changed, 9 insertions(+) diff --git a/spec/draper/decorator_spec.rb b/spec/draper/decorator_spec.rb index 4f88319..c120794 100755 --- a/spec/draper/decorator_spec.rb +++ b/spec/draper/decorator_spec.rb @@ -357,6 +357,10 @@ describe Draper::Decorator do Array(subject).should be_a Array end + it "proxies delegated methods" do + subject.delegated_method.should == "Yay, delegation" + end + context "with method security" do it "respects allows" do source.stub(:hello_world, :goodnight_moon).and_return(:proxied) diff --git a/spec/support/models/product.rb b/spec/support/models/product.rb index a613723..d46427e 100644 --- a/spec/support/models/product.rb +++ b/spec/support/models/product.rb @@ -1,6 +1,8 @@ class Product < ActiveRecord::Base include Draper::Decoratable + delegate :delegated_method, to: :thing + def self.find_by_name(name) @@dummy ||= Product.new end diff --git a/spec/support/models/some_thing.rb b/spec/support/models/some_thing.rb index 57309d3..daa7c28 100644 --- a/spec/support/models/some_thing.rb +++ b/spec/support/models/some_thing.rb @@ -1,2 +1,5 @@ class SomeThing < Product + def delegated_method + 'Yay, delegation' + end end