Skip to content

Commit

Permalink
Use self == other.source in Decoratable#==
Browse files Browse the repository at this point in the history
Apparently AR::Base does something tricky with #== which causes
`super(other.source)` to break

Closes #391
  • Loading branch information
haines committed Dec 28, 2012
1 parent 9eb9fc9 commit b83a95f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/draper/decoratable.rb
Expand Up @@ -22,7 +22,7 @@ def decorated?
end end


def ==(other) def ==(other)
super || (other.respond_to?(:source) && super(other.source)) super || (other.respond_to?(:source) && self == other.source)
end end


module ClassMethods module ClassMethods
Expand Down
14 changes: 14 additions & 0 deletions 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

0 comments on commit b83a95f

Please sign in to comment.