mirror of
https://github.com/drapergem/draper
synced 2023-03-27 23:21:17 -04:00
add spec to ensure that decorators work with delegation
This commit is contained in:
parent
bc1bae91b1
commit
39a984f068
3 changed files with 9 additions and 0 deletions
|
@ -357,6 +357,10 @@ describe Draper::Decorator do
|
||||||
Array(subject).should be_a Array
|
Array(subject).should be_a Array
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "proxies delegated methods" do
|
||||||
|
subject.delegated_method.should == "Yay, delegation"
|
||||||
|
end
|
||||||
|
|
||||||
context "with method security" do
|
context "with method security" do
|
||||||
it "respects allows" do
|
it "respects allows" do
|
||||||
source.stub(:hello_world, :goodnight_moon).and_return(:proxied)
|
source.stub(:hello_world, :goodnight_moon).and_return(:proxied)
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
class Product < ActiveRecord::Base
|
class Product < ActiveRecord::Base
|
||||||
include Draper::Decoratable
|
include Draper::Decoratable
|
||||||
|
|
||||||
|
delegate :delegated_method, to: :thing
|
||||||
|
|
||||||
def self.find_by_name(name)
|
def self.find_by_name(name)
|
||||||
@@dummy ||= Product.new
|
@@dummy ||= Product.new
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,2 +1,5 @@
|
||||||
class SomeThing < Product
|
class SomeThing < Product
|
||||||
|
def delegated_method
|
||||||
|
'Yay, delegation'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue