mirror of
https://github.com/drapergem/draper
synced 2023-03-27 23:21:17 -04:00
Merge pull request #67 from chrisledet/master
DecoratedEnumerableProxy#== to checks the collection it decorates
This commit is contained in:
commit
d72f2a1ee8
2 changed files with 19 additions and 0 deletions
|
@ -22,6 +22,10 @@ module Draper
|
|||
super || @wrapped_collection.respond_to?(method)
|
||||
end
|
||||
|
||||
def ==(other)
|
||||
@wrapped_collection == other
|
||||
end
|
||||
|
||||
def to_s
|
||||
"#<DecoratedEnumerableProxy of #{@klass} for #{@wrapped_collection.inspect}>"
|
||||
end
|
||||
|
|
|
@ -215,6 +215,7 @@ 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
|
||||
|
@ -223,6 +224,20 @@ describe Draper::Base do
|
|||
subject.include?(subject.first).should == true
|
||||
subject.include?(Product.new).should == false
|
||||
end
|
||||
|
||||
it "should equal each other when decorating the same collection" do
|
||||
subject_one = ProductDecorator.decorate(paged_array)
|
||||
subject_two = ProductDecorator.decorate(paged_array)
|
||||
subject_one.should == subject_two
|
||||
end
|
||||
|
||||
it "should not equal each other when decorating different collections" do
|
||||
subject_one = ProductDecorator.decorate(paged_array)
|
||||
new_paged_array = paged_array + [Product.new]
|
||||
subject_two = ProductDecorator.decorate(new_paged_array)
|
||||
subject_one.should_not == subject_two
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "a sample usage with denies" do
|
||||
|
|
Loading…
Reference in a new issue