Skip to content

Commit

Permalink
Merge pull request #674 from neo4jrb/activerel_type_inheritance
Browse files Browse the repository at this point in the history
fix activerel classes not assigning type when inheriting
  • Loading branch information
subvertallchris committed Jan 23, 2015
2 parents 13bd17a + 694df4b commit 530d83e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/neo4j/active_rel/types.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ module Types
module ClassMethods
include Neo4j::Shared::RelTypeConverters

def inherited(other)
other.type other.name, true
end

# @param type [String] sets the relationship type when creating relationships via this class
def type(given_type = self.name, auto = false)
use_type = auto ? decorated_rel_type(given_type) : given_type
Expand Down
6 changes: 6 additions & 0 deletions spec/e2e/active_rel_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ class AutomaticRelType
to_class ToClass
end

class InheritedRelClass < AutomaticRelType; end

it 'allows omission of `type`' do
expect(AutomaticRelType._type).to eq 'AUTOMATIC_REL_TYPE'
end
Expand All @@ -78,6 +80,10 @@ class AutomaticRelType
AutomaticRelType.type 'NEW_TYPE'
expect(AutomaticRelType._type).to eq 'NEW_TYPE'
end

it 'uses the defined class name when inheriting' do
expect(InheritedRelClass._type).to eq 'INHERITED_REL_CLASS'
end
end

describe 'associations with rel_class set' do
Expand Down

0 comments on commit 530d83e

Please sign in to comment.