Merge pull request #95 from tmaier/issue-92
Overwrite #kind_of? and #is_a? in Draper::DecoratedEnumerableProxy
This commit is contained in:
commit
1c9cb11f9e
|
@ -22,6 +22,11 @@ module Draper
|
||||||
super || @wrapped_collection.respond_to?(method)
|
super || @wrapped_collection.respond_to?(method)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def kind_of?(klass)
|
||||||
|
super || @wrapped_collection.kind_of?(klass)
|
||||||
|
end
|
||||||
|
alias :is_a? :kind_of?
|
||||||
|
|
||||||
def ==(other)
|
def ==(other)
|
||||||
@wrapped_collection == other
|
@wrapped_collection == other
|
||||||
end
|
end
|
||||||
|
|
|
@ -315,6 +315,26 @@ describe Draper::Base do
|
||||||
subject[0].should be_instance_of ProductDecorator
|
subject[0].should be_instance_of ProductDecorator
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "pretends to be of kind of wrapped collection class" do
|
||||||
|
subject { ProductDecorator.decorate(paged_array) }
|
||||||
|
|
||||||
|
it "#kind_of? DecoratedEnumerableProxy" do
|
||||||
|
subject.should be_kind_of Draper::DecoratedEnumerableProxy
|
||||||
|
end
|
||||||
|
|
||||||
|
it "#is_a? DecoratedEnumerableProxy" do
|
||||||
|
subject.is_a?(Draper::DecoratedEnumerableProxy).should be_true
|
||||||
|
end
|
||||||
|
|
||||||
|
it "#kind_of? Array" do
|
||||||
|
subject.should be_kind_of Array
|
||||||
|
end
|
||||||
|
|
||||||
|
it "#is_a? Array" do
|
||||||
|
subject.is_a?(Array).should be_true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context '#all' do
|
context '#all' do
|
||||||
it "should return a decorated collection" do
|
it "should return a decorated collection" do
|
||||||
ProductDecorator.all.first.should be_instance_of ProductDecorator
|
ProductDecorator.all.first.should be_instance_of ProductDecorator
|
||||||
|
|
Loading…
Reference in New Issue