add spec to ensure that decorators work with delegation

This commit is contained in:
Vasiliy Ermolovich 2012-11-21 21:55:56 +03:00
parent bc1bae91b1
commit 39a984f068
3 changed files with 9 additions and 0 deletions

View File

@ -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)

View File

@ -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

View File

@ -1,2 +1,5 @@
class SomeThing < Product
def delegated_method
'Yay, delegation'
end
end