Skip to content

Commit

Permalink
Defining more id_properties
Browse files Browse the repository at this point in the history
  • Loading branch information
cheerfulstoic committed Sep 17, 2014
1 parent bd73090 commit e945101
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
2 changes: 2 additions & 0 deletions spec/e2e/label_spec.rb
Expand Up @@ -146,6 +146,8 @@
it 'has an index on both base and subclass' do
class Foo1
include Neo4j::ActiveNode
id_property :uuid

property :name, index: :exact
end
class Foo2 < Foo1
Expand Down
3 changes: 2 additions & 1 deletion spec/e2e/rels_spec.rb
Expand Up @@ -4,6 +4,7 @@
before(:all) do
clazz = UniqueClass.create do
include Neo4j::ActiveNode
id_property :uuid
end

@n = clazz.create
Expand Down Expand Up @@ -44,4 +45,4 @@
@n.rel?(dir: :outgoing, type: :knows).should be false
end

end
end
8 changes: 8 additions & 0 deletions spec/integration/label_spec.rb
Expand Up @@ -11,12 +11,15 @@

class TestClass
include Neo4j::ActiveNode
id_property :uuid
end

Neo4j::Label.create(:IndexedTestClass).drop_index(:name)

class IndexedTestClass
include Neo4j::ActiveNode
id_property :uuid

property :name
index :name # will index using the IndexedTestClass label
end
Expand All @@ -36,11 +39,13 @@ def self.neo4j_session

class SomeLabelClass
include Neo4j::ActiveNode
id_property :uuid
include SomeLabelMixin
end

class RelationTestClass
include Neo4j::ActiveNode
id_property :uuid

has_one :in, :test_class
end
Expand Down Expand Up @@ -164,11 +169,14 @@ class RelationTestClass

class FirstLastTestClass
include Neo4j::ActiveNode
id_property :uuid

property :name
end

class EmptyTestClass
include Neo4j::ActiveNode
id_property :uuid
end

@jasmine = FirstLastTestClass.create(name: 'jasmine')
Expand Down
7 changes: 4 additions & 3 deletions spec/integration/node_persistence_spec.rb
Expand Up @@ -4,6 +4,7 @@

class MyThing
include Neo4j::ActiveNode
id_property :uuid
property :a
property :x
has_one :out, :parent, model_class: false
Expand All @@ -30,7 +31,7 @@ class MyThing
end

it 'undefined properties are found with the attributes method' do
MyThing.new(a: '4').attributes.should == {'a' => '4', 'x' => nil}
MyThing.new(a: '4').attributes.should == {'a' => '4', 'x' => nil, 'uuid' => nil}
end

end
Expand All @@ -44,10 +45,10 @@ class MyThing
end

it 'stores undefined attributes' do
node = double('unwrapped_node', props: {a: 999})
node = double('unwrapped_node', props: {a: 999, 'uuid' => 'secure1234'})
@session.should_receive(:create_node).with({uuid: 'secure1234', a: 1}, [:MyThing]).and_return(node)
thing = MyThing.create(a: 1)
thing.attributes.should == {"a" => 999, "x" => nil} # always reads the result from the database
thing.attributes.should == {"a" => 999, "x" => nil, 'uuid' => 'secure1234'} # always reads the result from the database
end

it 'does not allow to set undeclared properties using create' do
Expand Down

0 comments on commit e945101

Please sign in to comment.