active_node 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -4,4 +4,5 @@ Gemfile.lock
4
4
  pkg/*
5
5
  *.iml
6
6
  .idea/*
7
- neo4j
7
+ neo4j
8
+ coverage
@@ -2,7 +2,7 @@ module ActiveNode
2
2
  module Associations
3
3
  class SingularAssociation < Association #:nodoc:
4
4
  def load_target
5
- super.first
5
+ super.try :first
6
6
  end
7
7
 
8
8
  def target_each
@@ -1,3 +1,3 @@
1
1
  module ActiveNode
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -37,6 +37,16 @@ describe ActiveNode::Associations do
37
37
  client.user_ids.should be_empty
38
38
  end
39
39
 
40
+ it "returns nil on a has_one association for a brand spanking new model object" do
41
+ person = Person.new
42
+ person.father.should be_nil
43
+ end
44
+
45
+ it "returns nil on a has_one association where nothing is associated" do
46
+ person = Person.create!
47
+ person.father.should be_nil
48
+ end
49
+
40
50
  it "can remove some of the associated objects" do
41
51
  child1 = Person.create!
42
52
  child2 = Person.create!
@@ -82,9 +92,16 @@ describe ActiveNode::Associations do
82
92
  father.children.should == [child]
83
93
  end
84
94
 
95
+ it "can access new association without being saved" do
96
+ father = Person.create!
97
+ child = Person.new
98
+ child.father = father
99
+ child.father.should == father
100
+ end
101
+
85
102
  it 'can handle has_one reverse relationship' do
86
103
  father = Person.create!(children: [Person.create!])
87
104
  father.children.first.father.should == father
88
105
  end
89
106
  end
90
- end
107
+ end
@@ -31,6 +31,11 @@ describe ActiveNode::Persistence do
31
31
  it "should persist attributes" do
32
32
  Person.create!(name: 'abc').name.should == 'abc'
33
33
  end
34
+
35
+ it "should persist array properties" do
36
+ person = Person.create!(multi: [1, 2, 3])
37
+ Person.find(person.id).multi.should == [1, 2, 3]
38
+ end
34
39
  end
35
40
 
36
41
  describe "#attributes" do
@@ -1,5 +1,6 @@
1
1
  class Person < ActiveNode::Base
2
2
  attribute :name, type: String
3
+ attribute :multi
3
4
  has_many :people
4
5
  has_many :children, class_name: "Person"
5
6
  has_one :father, type: :child, direction: :incoming, class_name: "Person"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_node
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-10-13 00:00:00.000000000 Z
12
+ date: 2013-10-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: active_attr