Skip to content

Commit

Permalink
associations_keys should inherit, fixes #763
Browse files Browse the repository at this point in the history
  • Loading branch information
subvertallchris committed Apr 20, 2015
1 parent ab2c261 commit 8e0153e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/neo4j/active_node/has_n.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,13 @@ def associations
end

def associations_keys
@associations_keys ||= []
@associations_keys ||= associations.keys
end

# make sure the inherited classes inherit the <tt>_decl_rels</tt> hash
def inherited(klass)
klass.instance_variable_set(:@associations, associations.clone)
@associations_keys = klass.associations_keys.clone
super
end

Expand Down
9 changes: 9 additions & 0 deletions spec/e2e/inheritance_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
property :specs # Hash
index :name
serialize :specs
has_many :out, :models, model_class: false
end

stub_named_class('Car', Vehicle) do
Expand Down Expand Up @@ -71,4 +72,12 @@
expect(toyota.specs.class).to eq Hash
end
end

describe 'associations' do
it 'are inherited' do
expect(Car.new).to respond_to(:models)
expect(Vehicle.associations_keys).to include(:models)
expect(Car.associations_keys).to include(:models)
end
end
end

0 comments on commit 8e0153e

Please sign in to comment.