/
transaction_spec.rb
46 lines (41 loc) · 1.13 KB
/
transaction_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
require 'spec_helper'
describe 'Neo4j::Transaction' do
context 'reading has_one relationships for Neo4j::Server' do
let(:clazz) do
UniqueClass.create do
include Neo4j::ActiveNode
property :name
has_one :out, :thing, model_class: self
end
end
#:nocov:
it 'returns hash values inside but outside it has the node value after commit' do
i = 0
SecureRandom.stub(:uuid) do
i += 1
"secure1234_#{i}"
end
if Neo4j::Session.current.db_type == :server_db
clazz
tx = Neo4j::Transaction.new
a = clazz.create name: 'a'
b = clazz.create name: 'b'
a.thing = b
expect(a.thing).to eq("name"=>"b", "_classname"=>clazz.to_s, "uuid" => "secure1234_2")
tx.close
expect(a.thing).to eq(b)
end
if Neo4j::Session.current.db_type == :embedded_db
clazz
tx = Neo4j::Transaction.new
a = clazz.create name: 'a'
b = clazz.create name: 'b'
a.thing = b
expect(a.thing).to eq(b)
tx.close
expect(a.thing).to eq(b)
end
end
#:nocov:
end
end