diff --git a/lib/draper/decoratable.rb b/lib/draper/decoratable.rb index 4f97f2fd..a8e71b77 100644 --- a/lib/draper/decoratable.rb +++ b/lib/draper/decoratable.rb @@ -22,7 +22,7 @@ def decorated? end def ==(other) - super || (other.respond_to?(:source) && super(other.source)) + super || (other.respond_to?(:source) && self == other.source) end module ClassMethods diff --git a/spec/dummy/spec/models/post_spec.rb b/spec/dummy/spec/models/post_spec.rb new file mode 100644 index 00000000..7533f040 --- /dev/null +++ b/spec/dummy/spec/models/post_spec.rb @@ -0,0 +1,14 @@ +require 'spec_helper' + +describe Post do + describe "#==" do + before { Post.create } + subject { Post.first } + + it "is true for other instances' decorators" do + other = Post.first + subject.should_not be other + (subject == other.decorate).should be_true + end + end +end