From 57642193483ad6f234ef3abe9712fe34aa8d6552 Mon Sep 17 00:00:00 2001 From: Chris Grigg Date: Tue, 23 Jun 2015 17:19:25 -0400 Subject: [PATCH] fixes from_node/to_node not being set during init --- lib/neo4j/active_rel/property.rb | 2 +- spec/e2e/active_rel_spec.rb | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/neo4j/active_rel/property.rb b/lib/neo4j/active_rel/property.rb index aa7bbdd5d..154e0d37a 100644 --- a/lib/neo4j/active_rel/property.rb +++ b/lib/neo4j/active_rel/property.rb @@ -21,7 +21,7 @@ def type def initialize(attributes = {}, options = {}) super(attributes, options) - send_props(@relationship_props) if _persisted_obj && !@relationship_props.nil? + send_props(@relationship_props) unless @relationship_props.nil? end module ClassMethods diff --git a/spec/e2e/active_rel_spec.rb b/spec/e2e/active_rel_spec.rb index 7cfd75db7..b835d4c2c 100644 --- a/spec/e2e/active_rel_spec.rb +++ b/spec/e2e/active_rel_spec.rb @@ -163,6 +163,15 @@ class ActiveRelSpecTypesInheritedRelClass < ActiveRelSpecTypesAutomaticRelType end end + describe 'initialize' do + let(:new_rel) { MyRelClass.new(from_node: from_node, to_node: to_node) } + + it 'pulls :from_node and :to_node out of the hash' do + expect(new_rel.from_node).to eq from_node + expect(new_rel.to_node).to eq to_node + end + end + describe 'objects and queries' do before do Neo4j::Config[:cache_class_names] = true