From cfa968bca556a29892537d34c1ff73af64627b03 Mon Sep 17 00:00:00 2001 From: Chris Grigg Date: Wed, 19 Aug 2015 20:09:03 -0400 Subject: [PATCH] fixes incorrect type when association type: false && model_class set --- lib/neo4j/active_node/has_n/association.rb | 2 +- spec/unit/association_spec.rb | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/neo4j/active_node/has_n/association.rb b/lib/neo4j/active_node/has_n/association.rb index 8ba25ac37..5f2169916 100644 --- a/lib/neo4j/active_node/has_n/association.rb +++ b/lib/neo4j/active_node/has_n/association.rb @@ -109,7 +109,7 @@ def relationship_type(create = false) case when relationship_class relationship_class_type - when @relationship_type + when !@relationship_type.nil? @relationship_type when @origin origin_type diff --git a/spec/unit/association_spec.rb b/spec/unit/association_spec.rb index 1f2e24c05..59ceb677d 100644 --- a/spec/unit/association_spec.rb +++ b/spec/unit/association_spec.rb @@ -44,6 +44,16 @@ class Default it { expect { subject }.to raise_error(ArgumentError) } end + context 'type and model_class specified' do + context 'with type: false' do + before do + stub_const('FooClass', Class.new) + end + let(:options) { {type: false, model_class: FooClass} } + it { expect(subject.relationship_type).to be_falsey } + end + end + context 'origin and rel_class specified' do let(:options) { {origin: :foo, rel_class: :bar} }