added #include? to DecoratedEnumerableProxy class

This commit is contained in:
Chris Ledet 2011-10-26 13:27:58 -04:00
parent 03bf0b9af8
commit 064ac47bdd
2 changed files with 12 additions and 0 deletions

View File

@ -22,6 +22,10 @@ module Draper
super || @wrapped_collection.respond_to?(method)
end
def include?(member)
@wrapped_collection.include?(member)
end
def to_s
"#<DecoratedEnumerableProxy of #{@klass} for #{@wrapped_collection.inspect}>"
end

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
decorator = ProductDecorator.decorate(paged_array)
decorator.respond_to?(:include?)
decorator.include?(member).should == true
decorator.include?(Product.new).should == false
end
end
describe "a sample usage with denies" do