Permalink
Browse files

Merge pull request #404 from haines/equality

Use `self == other.source` in Decoratable#==
  • Loading branch information...
steveklabnik committed Dec 28, 2012
2 parents 9eb9fc9 + b83a95f commit e4fa239d84e8e9d6a490d785abb3953acc28fa65
Showing with 15 additions and 1 deletion.
  1. +1 −1 lib/draper/decoratable.rb
  2. +14 −0 spec/dummy/spec/models/post_spec.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
@@ -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

0 comments on commit e4fa239

Please sign in to comment.