Skip to content

Commit

Permalink
delegate respond_to? to decorated model with second param
Browse files Browse the repository at this point in the history
  • Loading branch information
nashby committed Apr 10, 2012
1 parent da4666e commit 3504393
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/draper/base.rb
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions spec/draper/base_spec.rb
Expand Up @@ -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
Expand Down

0 comments on commit 3504393

Please sign in to comment.