Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

The relationship other_node method should return wrapped node, closes #…

  • Loading branch information...
commit f6b40a954458f58f3446f4adbfed5b55b4507b58 1 parent 7fb58a7
@andreasronge andreasronge authored
View
11 lib/neo4j/rails/relationship_persistence.rb
@@ -41,11 +41,12 @@ def rel_type
# @see http://rdoc.info/github/andreasronge/neo4j-core/Neo4j/Core/Relationship#other_node-instance_method
def other_node(node)
- if persisted?
- _java_rel._other_node(node._java_entity)
- else
- @_start_node == node ? @_end_node : @_start_node
- end
+ n = if persisted?
+ _java_rel._other_node(node._java_entity)
+ else
+ @_start_node == node ? @_end_node : @_start_node
+ end
+ n && n.wrapper
end
# Returns the start node which can be unpersisted
View
23 spec/regressions/issue_226_spec.rb
@@ -0,0 +1,23 @@
+module Regressions
+ require 'spec_helper'
+
+ class Issue226 < Neo4j::Rails::Model
+ has_one :thing
+ end
+
+ describe "Issue 226, make sure other_node returns a wrapped node" do
+ it "has a correct count" do
+ a = Issue226.create
+ b = Issue226.create
+ a.thing = b
+ a.save!
+
+ rel = a.thing_rel
+ rel.start_node.should == a
+ rel.end_node.should == b
+ rel.other_node(a).neo_id.should == b.neo_id
+ rel.other_node(a).class.should == Issue226
+ rel.other_node(a).should == b
+ end
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.