Merge pull request #65 from chrisledet/master

Added #include? to DecoratedEnumerableProxy class
This commit is contained in:
Jeff Casimir 2011-10-27 08:06:46 -07:00
commit 251ace9ce2
2 changed files with 9 additions and 1 deletions

View File

@ -127,7 +127,7 @@ module Draper
#
# @return [Boolean] true if other's model == self's model
def ==(other)
@model == other.model
@model == (other.respond_to?(:model) ? other.model : other)
end
def respond_to?(method, include_private = false)

View File

@ -215,6 +215,14 @@ describe Draper::Base do
decorator = ProductDecorator.decorate(empty_collection)
decorator.should be_blank
end
it "should return whether the member is in the array for a decorated wrapped collection" do
# This tests that include? is defined for the DecoratedEnumerableProxy
member = paged_array.first
subject.respond_to?(:include?)
subject.include?(member).should == true
subject.include?(subject.first).should == true
subject.include?(Product.new).should == false
end
end
describe "a sample usage with denies" do