active_node 2.0.3 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6fba7d60bad2e08d7dc4e0750638d7307e04fc17
4
- data.tar.gz: 65347e49175fad7daae68761797e7c195bcfb287
3
+ metadata.gz: caa007d44ee08eba702076849cea0c799428c3b6
4
+ data.tar.gz: a5df8569e661a75c6291db2dc3803df0bcfe2f51
5
5
  SHA512:
6
- metadata.gz: 35794dbe68d4e3345b8860fce9597a095d7888090b2da7336a175a4492e8c11577a339b0a2832242f03cbd7e23c11aa61ed6c723c1d62aa965500856a45fca96
7
- data.tar.gz: 9cf27db0e024749342e86a971a8156a4e5efa99e91e327899fb0797ebacbf7817012f7d2867f2ccada1eb1256e799cb7b4a67bff469ca4c8b0e6815f346b1c39
6
+ metadata.gz: 24731c0ae1f393568ac28a1c06f924105e530dcf60d82b96b56dedbab10016bd02e6c067bea482633283acb9415e5e601007e85855432fcf3a999d526c75143c
7
+ data.tar.gz: b3060005f8751aa730546ddf3ec72e1168b8400b8ce8eb7c72f7bc4a6ae591cc60e148ffaff508a37af58fe817d5a6ae5f581ebb2072c836082a9ec684a778b3
@@ -85,7 +85,7 @@ module ActiveNode
85
85
  end
86
86
 
87
87
  def persisted?
88
- id.present?
88
+ id.present? && !destroyed?
89
89
  end
90
90
 
91
91
  def initialize hash={}, split_by=:respond_to_writer?
@@ -109,6 +109,10 @@ module ActiveNode
109
109
  @destroyed = destroyable
110
110
  end
111
111
 
112
+ def destroyed?
113
+ @destroyed
114
+ end
115
+
112
116
  def destroy!
113
117
  destroy true
114
118
  end
@@ -218,8 +222,7 @@ module ActiveNode
218
222
  end
219
223
 
220
224
  def all_attributes
221
- attributes.merge(@hash)
225
+ attributes.except('id').merge(@hash)
222
226
  end
223
-
224
227
  end
225
228
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveNode
2
- VERSION = "2.0.3"
2
+ VERSION = "2.0.4"
3
3
  end
@@ -7,7 +7,14 @@ describe ActiveNode::Persistence do
7
7
  Address.find(a.id).should == a
8
8
  end
9
9
 
10
- it "should save not conventionally named object" do
10
+ it "should not set id property" do
11
+ a = Address.create!
12
+ ActiveNode::Neo.db.get_node_properties(a.id).should be_nil
13
+ a.save
14
+ ActiveNode::Neo.db.get_node_properties(a.id).should be_nil
15
+ end
16
+
17
+ it "should save unconventionally named object" do
11
18
  NeoUser.new(name: 'Heinrich').save.should be_true
12
19
  NeoUser.all.map(&:name).should == ['Heinrich']
13
20
  end
@@ -59,6 +66,20 @@ describe ActiveNode::Persistence do
59
66
  end
60
67
  end
61
68
 
69
+ describe "#destroyed?" do
70
+ it "returns false if a record has not been destroyed" do
71
+ person = Person.create!
72
+ expect(person).to_not be_destroyed
73
+ end
74
+
75
+ it "returns true after a record has been destroyed" do
76
+ person = Person.create!
77
+ person.destroy
78
+
79
+ expect(person).to be_destroyed
80
+ end
81
+ end
82
+
62
83
  describe "#create!" do
63
84
  it "should persist attributes" do
64
85
  Person.create!(name: 'abc').name.should == 'abc'
@@ -92,6 +113,24 @@ describe ActiveNode::Persistence do
92
113
  end
93
114
  end
94
115
 
116
+ describe "#persisted?" do
117
+ it "returns true if an id is assigned and the record is not destroyed" do
118
+ person = Person.new id: 123
119
+ expect(person).to be_persisted
120
+ end
121
+
122
+ it "returns false if an id is assigned and the record is destroyed" do
123
+ person = Person.create!
124
+ person.destroy
125
+ expect(person).to_not be_persisted
126
+ end
127
+
128
+ it "returns false if an id is not assigned" do
129
+ person = Person.new
130
+ expect(person).to_not be_persisted
131
+ end
132
+ end
133
+
95
134
  describe "#incoming" do
96
135
  it "can retrieve heterogenous models" do
97
136
  a = Address.create!
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_node
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3
4
+ version: 2.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Heinrich Klobuczek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-08 00:00:00.000000000 Z
11
+ date: 2014-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_attr