Permalink
Browse files

add spec to ensure that decorators work with delegation

  • Loading branch information...
nashby committed Nov 21, 2012
1 parent bc1bae9 commit 39a984f06871be482206746185a67206de986544
Showing with 9 additions and 0 deletions.
  1. +4 −0 spec/draper/decorator_spec.rb
  2. +2 −0 spec/support/models/product.rb
  3. +3 −0 spec/support/models/some_thing.rb
@@ -357,6 +357,10 @@
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)
@@ -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
@@ -1,2 +1,5 @@
class SomeThing < Product
+ def delegated_method
+ 'Yay, delegation'
+ end
end

0 comments on commit 39a984f

Please sign in to comment.