Use `self == other.source` in Decoratable#==

Apparently AR::Base does something tricky with #== which causes
`super(other.source)` to break

Closes #391
This commit is contained in:
Andrew Haines 2012-12-28 12:52:45 +00:00
parent 9eb9fc909c
commit b83a95f0f0
2 changed files with 15 additions and 1 deletions

View File

@ -22,7 +22,7 @@ module Draper::Decoratable
end
def ==(other)
super || (other.respond_to?(:source) && super(other.source))
super || (other.respond_to?(:source) && self == other.source)
end
module ClassMethods

View File

@ -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