From f12c5585fb57e8ef9d714bba88a6678b557a0496 Mon Sep 17 00:00:00 2001 From: Andreas Ronge Date: Tue, 26 Aug 2014 15:30:01 +0200 Subject: [PATCH] id and == was broken and add error when no session is available #422 --- CHANGELOG | 3 +++ lib/neo4j/active_node.rb | 1 + lib/neo4j/active_rel.rb | 1 + lib/neo4j/shared.rb | 4 +--- spec/e2e/id_property_spec.rb | 2 ++ 5 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index f053aebb0..62a2d0635 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +* Warn if no session is available +* Fix broken == and equality + == 3.0.0.alpha.11 * Bug fixes diff --git a/lib/neo4j/active_node.rb b/lib/neo4j/active_node.rb index 3a9edb35a..fff75c246 100644 --- a/lib/neo4j/active_node.rb +++ b/lib/neo4j/active_node.rb @@ -25,6 +25,7 @@ module ActiveNode extend ActiveSupport::Concern include Neo4j::Shared + include Neo4j::Shared::Identity include Neo4j::ActiveNode::Initialize include Neo4j::ActiveNode::IdProperty include Neo4j::ActiveNode::SerializedProperties diff --git a/lib/neo4j/active_rel.rb b/lib/neo4j/active_rel.rb index 0c92603d9..98d71cb9a 100644 --- a/lib/neo4j/active_rel.rb +++ b/lib/neo4j/active_rel.rb @@ -6,6 +6,7 @@ module ActiveRel include Neo4j::Shared include Neo4j::ActiveRel::Initialize + include Neo4j::Shared::Identity include Neo4j::ActiveRel::Property include Neo4j::ActiveRel::Persistence include Neo4j::ActiveRel::Validations diff --git a/lib/neo4j/shared.rb b/lib/neo4j/shared.rb index f1a7d006c..d1e1a1def 100644 --- a/lib/neo4j/shared.rb +++ b/lib/neo4j/shared.rb @@ -7,8 +7,6 @@ module Shared include ActiveModel::Serializers::Xml include ActiveModel::Serializers::JSON - include Neo4j::Shared::Identity - module ClassMethods def neo4j_session_name (name) @neo4j_session_name = name @@ -18,7 +16,7 @@ def neo4j_session if @neo4j_session_name Neo4j::Session.named(@neo4j_session_name) || raise("#{self.name} is configured to use a neo4j session named #{@neo4j_session_name}, but no such session is registered with Neo4j::Session") else - Neo4j::Session.current + Neo4j::Session.current! end end end diff --git a/spec/e2e/id_property_spec.rb b/spec/e2e/id_property_spec.rb index ccb6eb4ca..411fdbbb7 100644 --- a/spec/e2e/id_property_spec.rb +++ b/spec/e2e/id_property_spec.rb @@ -46,6 +46,7 @@ let(:clazz) do UniqueClass.create do include Neo4j::ActiveNode + property :name end end @@ -58,6 +59,7 @@ it 'can find by id uses the neo_id' do node = clazz.create! + node.name = 'kalle' expect(clazz.find_by_id(node.id)).to eq(node) end