Skip to content

Commit

Permalink
include? bug fix for multiple rels to the same object
Browse files Browse the repository at this point in the history
  • Loading branch information
subvertallchris committed Aug 21, 2014
1 parent 638cf58 commit 0b9653b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/neo4j/active_node/labels.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def count
end

def include?(other)
self.query_as(:n).limit(1).where("ID(n) = #{other.neo_id}").return("count(n) AS count").first.count == 1
self.query_as(:n).where("ID(n) = #{other.neo_id}").return("count(n) AS count").first.count > 0
end

def exists?(node_id=nil)
Expand Down
6 changes: 6 additions & 0 deletions spec/e2e/active_model_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,12 @@ class IncludeTeacher
expect(IncludeTeacher.include?(mr_jones)).to be_truthy
expect(IncludeTeacher.include?(math)).to be_falsey
end

it 'works with multiple relationships to the same object' do
jimmy.lessons << science
jimmy.lessons << science
expect(jimmy.lessons.include?(science)).to be_truthy
end
end

describe 'exists?' do
Expand Down

0 comments on commit 0b9653b

Please sign in to comment.