From 35043936784eef6dc8c455854a2683b55304f457 Mon Sep 17 00:00:00 2001 From: Vasiliy Ermolovich Date: Tue, 10 Apr 2012 23:09:29 +0300 Subject: [PATCH] delegate respond_to? to decorated model with second param --- lib/draper/base.rb | 2 +- spec/draper/base_spec.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/draper/base.rb b/lib/draper/base.rb index 5d995a08..bc9131ab 100644 --- a/lib/draper/base.rb +++ b/lib/draper/base.rb @@ -211,7 +211,7 @@ def kind_of?(klass) alias :is_a? :kind_of? def respond_to?(method, include_private = false) - super || (allow?(method) && model.respond_to?(method)) + super || (allow?(method) && model.respond_to?(method, include_private)) end def method_missing(method, *args, &block) diff --git a/spec/draper/base_spec.rb b/spec/draper/base_spec.rb index 39c6f97a..2ff9e0ce 100644 --- a/spec/draper/base_spec.rb +++ b/spec/draper/base_spec.rb @@ -414,6 +414,14 @@ class CustomDecorator < Draper::Base end end + context ".respond_to?" do + it "should delegate respond_to? to the decorated model" do + other = Draper::Base.new(source) + source.should_receive(:respond_to?).with(:whatever, true) + subject.respond_to?(:whatever, true) + end + end + context 'position accessors' do [:first, :last].each do |method| context "##{method}" do