og 0.23.0 → 0.24.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ProjectInfo +58 -0
- data/README +5 -4
- data/Rakefile +2 -2
- data/doc/AUTHORS +10 -7
- data/doc/RELEASES +108 -0
- data/lib/og.rb +1 -3
- data/lib/og/collection.rb +4 -4
- data/lib/og/entity.rb +96 -27
- data/lib/og/evolution.rb +78 -0
- data/lib/og/manager.rb +29 -32
- data/lib/og/mixin/hierarchical.rb +1 -1
- data/lib/og/mixin/optimistic_locking.rb +5 -8
- data/lib/og/mixin/orderable.rb +15 -2
- data/lib/og/mixin/schema_inheritance_base.rb +12 -0
- data/lib/og/mixin/taggable.rb +29 -25
- data/lib/og/mixin/timestamped.rb +4 -2
- data/lib/og/mixin/tree.rb +0 -1
- data/lib/og/relation.rb +161 -116
- data/lib/og/relation/all.rb +6 -0
- data/lib/og/relation/belongs_to.rb +4 -1
- data/lib/og/relation/has_many.rb +6 -5
- data/lib/og/relation/joins_many.rb +13 -12
- data/lib/og/relation/refers_to.rb +3 -3
- data/lib/og/store.rb +9 -9
- data/lib/og/store/{filesys.rb → alpha/filesys.rb} +0 -0
- data/lib/og/store/alpha/kirby.rb +284 -0
- data/lib/og/store/{memory.rb → alpha/memory.rb} +2 -0
- data/lib/og/store/{sqlserver.rb → alpha/sqlserver.rb} +6 -6
- data/lib/og/store/kirby.rb +145 -162
- data/lib/og/store/mysql.rb +58 -27
- data/lib/og/store/psql.rb +15 -13
- data/lib/og/store/sql.rb +136 -135
- data/lib/og/store/sqlite.rb +13 -12
- data/lib/og/validation.rb +2 -2
- data/lib/vendor/kbserver.rb +20 -0
- data/lib/vendor/kirbybase.rb +2790 -1601
- data/test/og/CONFIG.rb +79 -0
- data/test/og/mixin/tc_hierarchical.rb +1 -1
- data/test/og/mixin/tc_optimistic_locking.rb +1 -3
- data/test/og/mixin/tc_orderable.rb +42 -1
- data/test/og/mixin/tc_taggable.rb +1 -1
- data/test/og/mixin/tc_timestamped.rb +1 -1
- data/test/og/store/tc_filesys.rb +1 -2
- data/test/og/tc_delete_all.rb +45 -0
- data/test/og/tc_inheritance.rb +10 -38
- data/test/og/tc_join.rb +2 -11
- data/test/og/tc_multiple.rb +3 -16
- data/test/og/tc_override.rb +3 -3
- data/test/og/tc_polymorphic.rb +3 -13
- data/test/og/tc_relation.rb +8 -6
- data/test/og/tc_reverse.rb +2 -11
- data/test/og/tc_select.rb +2 -15
- data/test/og/tc_store.rb +4 -63
- data/test/og/tc_types.rb +1 -2
- metadata +80 -77
data/test/og/CONFIG.rb
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
# This file contains og initialization code for all tests.
|
2
|
+
# This way you only change the parameters in one file in
|
3
|
+
# order to run all the tests for many stores.
|
4
|
+
#
|
5
|
+
# Current store choices are
|
6
|
+
# :mysql :psql :sqlite :kirby :memory
|
7
|
+
|
8
|
+
# CHANGE THIS TO SETUP MOST TESTS
|
9
|
+
|
10
|
+
configA = :sqlite
|
11
|
+
|
12
|
+
# FOR MULTI-TESTS
|
13
|
+
|
14
|
+
configB = :mysql
|
15
|
+
|
16
|
+
# SET THIS TO true TO ENABLE EXTRA DEBUG CODE
|
17
|
+
|
18
|
+
debug = true
|
19
|
+
|
20
|
+
# TO TEST AGAINST AN INSTALLATION OF OG INSTEAD THIS LOCAL
|
21
|
+
# DISTRIBUTION, SET THE FOLLOWING TO true.
|
22
|
+
|
23
|
+
test_against_installation = false
|
24
|
+
|
25
|
+
|
26
|
+
#--------------------------------------------------------------
|
27
|
+
# DO NOT CHANGE ANYTHING BELOW THIS LINE
|
28
|
+
|
29
|
+
unless test_against_installation
|
30
|
+
$:.unshift File.expand_path( File.join( File.dirname(__FILE__), '..', '..', 'lib' ) )
|
31
|
+
end
|
32
|
+
|
33
|
+
$DBG = debug
|
34
|
+
|
35
|
+
$og_mysql = {
|
36
|
+
:destroy => true,
|
37
|
+
:store => :mysql,
|
38
|
+
:user => 'root',
|
39
|
+
:name => 'test',
|
40
|
+
# :password => 'navelrulez',
|
41
|
+
:socket => '/var/run/mysqld/mysqld.sock'
|
42
|
+
}
|
43
|
+
|
44
|
+
$og_psql = {
|
45
|
+
:destroy => true,
|
46
|
+
:store => :psql,
|
47
|
+
:user => 'postgres',
|
48
|
+
:password => 'postgres',
|
49
|
+
:name => 'test'
|
50
|
+
}
|
51
|
+
|
52
|
+
$og_sqlite = {
|
53
|
+
:destroy => true,
|
54
|
+
:store => :sqlite,
|
55
|
+
:name => 'test'
|
56
|
+
}
|
57
|
+
|
58
|
+
$og_kirby = {
|
59
|
+
:destroy => true,
|
60
|
+
:store => :kirby,
|
61
|
+
:name => 'test',
|
62
|
+
:embedded => true
|
63
|
+
}
|
64
|
+
|
65
|
+
$og_memory = {
|
66
|
+
:store => :memory,
|
67
|
+
:name => :test,
|
68
|
+
:destroy => true
|
69
|
+
}
|
70
|
+
|
71
|
+
# This sets the common global vars to be used by the tests.
|
72
|
+
|
73
|
+
eval %{
|
74
|
+
$og_config1 = $og_config = $og_#{configA}
|
75
|
+
$og_config2 = $og_#{configB}
|
76
|
+
}
|
77
|
+
|
78
|
+
# * Tom Sawyer <transfire@gmail.com>
|
79
|
+
# * George Moschovitis <gm@navel.gr>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'CONFIG.rb')
|
2
2
|
|
3
3
|
require 'test/unit'
|
4
4
|
require 'ostruct'
|
@@ -6,6 +6,23 @@ require 'ostruct'
|
|
6
6
|
require 'og'
|
7
7
|
require 'og/mixin/orderable'
|
8
8
|
|
9
|
+
class Playlist
|
10
|
+
prop :name, String
|
11
|
+
has_many Track
|
12
|
+
end
|
13
|
+
|
14
|
+
class Track
|
15
|
+
include Og::Orderable, :scope => :playlist
|
16
|
+
|
17
|
+
belongs_to Playlist
|
18
|
+
prop :name, String
|
19
|
+
|
20
|
+
def initialize(name, playlist)
|
21
|
+
@name = name
|
22
|
+
self.playlist = playlist
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
9
26
|
$og = Og.setup(
|
10
27
|
:store => 'psql',
|
11
28
|
# :store => :memory,
|
@@ -103,5 +120,29 @@ class TestCaseOgOrderable < Test::Unit::TestCase # :nodoc: all
|
|
103
120
|
|
104
121
|
c1.delete!
|
105
122
|
end
|
123
|
+
|
124
|
+
def track_list
|
125
|
+
Track.find(:order => "position").collect { |t| t.name }
|
126
|
+
end
|
127
|
+
|
128
|
+
def test_orderable
|
129
|
+
pl = Playlist.create
|
130
|
+
|
131
|
+
%w{one two three four five six}.each do |n|
|
132
|
+
Track.create(n, pl)
|
133
|
+
end
|
134
|
+
|
135
|
+
tr = Track.one(:condition => 'position = 1')
|
136
|
+
tr.move_to(4)
|
137
|
+
assert_equal(4, tr.position)
|
138
|
+
|
139
|
+
assert_equal(%w{two three four one five six}, track_list() )
|
140
|
+
|
141
|
+
tr = Track.one(:condition => 'position = 5')
|
142
|
+
tr.move_to(3)
|
143
|
+
assert_equal(3, tr.position)
|
144
|
+
|
145
|
+
assert_equal(%w{two three five four one six}, track_list() )
|
146
|
+
end
|
106
147
|
|
107
148
|
end
|
data/test/og/store/tc_filesys.rb
CHANGED
@@ -0,0 +1,45 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'CONFIG.rb')
|
2
|
+
|
3
|
+
require "og"
|
4
|
+
require "pp"
|
5
|
+
require "test/unit"
|
6
|
+
|
7
|
+
$DBG = true
|
8
|
+
|
9
|
+
class Playlist
|
10
|
+
property :name, String
|
11
|
+
has_many :tracks
|
12
|
+
end
|
13
|
+
|
14
|
+
class Track
|
15
|
+
property :name, String
|
16
|
+
belongs_to Playlist
|
17
|
+
|
18
|
+
def initialize(playlist)
|
19
|
+
self.playlist = playlist
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
class OgDeleteAll < Test::Unit::TestCase
|
25
|
+
def setup
|
26
|
+
Og.setup($og_config)
|
27
|
+
end
|
28
|
+
|
29
|
+
def pop
|
30
|
+
@pl = Playlist.create
|
31
|
+
5.times do |i|
|
32
|
+
Track.create(@pl)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def test1
|
37
|
+
pop()
|
38
|
+
@pl.tracks.delete_all
|
39
|
+
assert(Track.all.empty?)
|
40
|
+
|
41
|
+
pop()
|
42
|
+
@pl.tracks.each { |obj| obj.delete }
|
43
|
+
assert(Track.all.empty?)
|
44
|
+
end
|
45
|
+
end
|
data/test/og/tc_inheritance.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require File.join(File.dirname(__FILE__), 'CONFIG.rb')
|
2
2
|
|
3
3
|
$DBG = true
|
4
4
|
|
@@ -36,6 +36,7 @@ class TC_OgInheritance < Test::Unit::TestCase # :nodoc: all
|
|
36
36
|
|
37
37
|
class Car
|
38
38
|
property :name
|
39
|
+
belongs_to :admin
|
39
40
|
end
|
40
41
|
|
41
42
|
class User
|
@@ -50,45 +51,16 @@ class TC_OgInheritance < Test::Unit::TestCase # :nodoc: all
|
|
50
51
|
end
|
51
52
|
|
52
53
|
def test_all
|
53
|
-
=
|
54
|
-
@og = Og.setup(
|
55
|
-
:store => :memory,
|
56
|
-
:name => :test
|
57
|
-
)
|
58
|
-
=end
|
59
|
-
=begin
|
60
|
-
@og = Og.setup(
|
61
|
-
:destroy => true,
|
62
|
-
:store => :sqlite,
|
63
|
-
:name => 'test'
|
64
|
-
)
|
65
|
-
=end
|
66
|
-
=begin
|
67
|
-
@og = Og.setup(
|
68
|
-
:destroy => true,
|
69
|
-
:store => :psql,
|
70
|
-
:name => 'test',
|
71
|
-
:user => 'postgres',
|
72
|
-
:password => 'navelrulez'
|
73
|
-
)
|
74
|
-
=end
|
75
|
-
#=begin
|
76
|
-
@og = Og.setup(
|
77
|
-
:destroy => true,
|
78
|
-
:store => :mysql,
|
79
|
-
:name => 'test',
|
80
|
-
:user => 'root',
|
81
|
-
:password => 'navelrulez'
|
82
|
-
)
|
83
|
-
#=end
|
84
|
-
assert_equal [Document], Photo.metadata.superclass
|
85
|
-
assert_equal [Photo, Article], Document.metadata.subclasses
|
54
|
+
@og = Og.setup($og_config)
|
86
55
|
|
87
|
-
|
56
|
+
assert_equal Document, Photo.superclass
|
57
|
+
assert_equal [Photo, Article], Document.descendents
|
58
|
+
|
59
|
+
assert Document.ann.this.schema_inheritance
|
88
60
|
|
89
61
|
# propagate schema_inheritance flag.
|
90
62
|
|
91
|
-
assert Photo.
|
63
|
+
assert Photo.ann.this.schema_inheritance
|
92
64
|
|
93
65
|
# subclasses reuse the same table.
|
94
66
|
|
@@ -123,9 +95,9 @@ class TC_OgInheritance < Test::Unit::TestCase # :nodoc: all
|
|
123
95
|
|
124
96
|
articles = Article.all(:limit => 2)
|
125
97
|
assert_equal 2, articles.size
|
126
|
-
|
98
|
+
|
127
99
|
# Bug report.
|
128
100
|
Admin.create
|
129
|
-
Admin.create.
|
101
|
+
Admin.create.car
|
130
102
|
end
|
131
103
|
end
|
data/test/og/tc_join.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require File.join(File.dirname(__FILE__), 'CONFIG.rb')
|
2
2
|
|
3
3
|
$DBG = true
|
4
4
|
|
@@ -35,16 +35,7 @@ class TC_Join < Test::Unit::TestCase # :nodoc: all
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def setup
|
38
|
-
@og = Og.setup(
|
39
|
-
:destroy => true,
|
40
|
-
:store => :mysql,
|
41
|
-
# :store => :sqlite,
|
42
|
-
# :store => :psql,
|
43
|
-
# :user => 'postgres',
|
44
|
-
:user => 'root',
|
45
|
-
:password => 'navelrulez',
|
46
|
-
:name => 'test'
|
47
|
-
)
|
38
|
+
@og = Og.setup($og_config)
|
48
39
|
end
|
49
40
|
|
50
41
|
def test_all
|
data/test/og/tc_multiple.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require File.join(File.dirname(__FILE__), 'CONFIG.rb')
|
2
2
|
|
3
3
|
$DBG = true
|
4
4
|
|
@@ -6,21 +6,8 @@ require 'test/unit'
|
|
6
6
|
|
7
7
|
require 'og'
|
8
8
|
|
9
|
-
$og1 = Og.setup(
|
10
|
-
|
11
|
-
:store => :mysql,
|
12
|
-
:user => 'root',
|
13
|
-
:password => 'navelrulez',
|
14
|
-
:name => 'test'
|
15
|
-
)
|
16
|
-
|
17
|
-
$og2 = Og.setup(
|
18
|
-
:destroy => true,
|
19
|
-
:store => :psql,
|
20
|
-
:user => 'postgres',
|
21
|
-
:password => 'navelrulez',
|
22
|
-
:name => 'test'
|
23
|
-
)
|
9
|
+
$og1 = Og.setup($og_config1)
|
10
|
+
$og2 = Og.setup($og_config2)
|
24
11
|
|
25
12
|
class TestMultiple < Test::Unit::TestCase # :nodoc: all
|
26
13
|
include Og
|
data/test/og/tc_override.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
|
1
|
+
require File.join(File.dirname(__FILE__), 'CONFIG.rb')
|
2
2
|
|
3
|
-
require 'og'
|
4
3
|
require 'test/unit'
|
4
|
+
require 'og'
|
5
5
|
|
6
6
|
class Book
|
7
7
|
property :title
|
@@ -24,7 +24,7 @@ class TestOg < Test::Unit::TestCase
|
|
24
24
|
|
25
25
|
def setup
|
26
26
|
Og.table_prefix = nil
|
27
|
-
og = Og.setup(
|
27
|
+
og = Og.setup($og_config)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
data/test/og/tc_polymorphic.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
$:.unshift File.join(File.dirname(__FILE__), 'lib')
|
2
1
|
|
3
|
-
require '
|
2
|
+
require File.join(File.dirname(__FILE__), 'CONFIG.rb')
|
4
3
|
|
4
|
+
require 'test/unit'
|
5
5
|
require 'og'
|
6
6
|
|
7
7
|
class TC_OgPolymorphic < Test::Unit::TestCase # :nodoc: all
|
@@ -38,17 +38,7 @@ class TC_OgPolymorphic < Test::Unit::TestCase # :nodoc: all
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def setup
|
41
|
-
@og = Og.setup(
|
42
|
-
=begin
|
43
|
-
:destroy => true,
|
44
|
-
:store => :sqlite,
|
45
|
-
:name => 'test'
|
46
|
-
=end
|
47
|
-
:store => :mysql,
|
48
|
-
:name => 'testreverse',
|
49
|
-
:user => 'root',
|
50
|
-
:password => 'navelrulez'
|
51
|
-
)
|
41
|
+
@og = Og.setup($og_config)
|
52
42
|
end
|
53
43
|
|
54
44
|
def test_all
|
data/test/og/tc_relation.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
-
|
1
|
+
require File.join(File.dirname(__FILE__), 'CONFIG.rb')
|
2
2
|
|
3
3
|
require 'test/unit'
|
4
4
|
|
5
5
|
require 'og'
|
6
6
|
require 'og/relation'
|
7
7
|
|
8
|
+
=begin
|
8
9
|
class TestCaseOgRelation < Test::Unit::TestCase # :nodoc: all
|
9
10
|
include Og
|
10
11
|
|
@@ -25,7 +26,7 @@ class TestCaseOgRelation < Test::Unit::TestCase # :nodoc: all
|
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
28
|
-
def test_all
|
29
|
+
def test_all
|
29
30
|
# no-namespace case.
|
30
31
|
rel = User.relation(:dummers)
|
31
32
|
rel.resolve_target
|
@@ -38,12 +39,12 @@ class TestCaseOgRelation < Test::Unit::TestCase # :nodoc: all
|
|
38
39
|
|
39
40
|
# bug: test the no belongs_to case in Article
|
40
41
|
|
41
|
-
og = Og.setup(
|
42
|
+
og = Og.setup($og_config)
|
42
43
|
og.manage_classes
|
43
44
|
end
|
44
45
|
|
45
46
|
def test_refers_to
|
46
|
-
og = Og.setup(
|
47
|
+
og = Og.setup($og_config)
|
47
48
|
og.manage_classes
|
48
49
|
|
49
50
|
# test refers_to accessor is correctly updated
|
@@ -54,7 +55,7 @@ class TestCaseOgRelation < Test::Unit::TestCase # :nodoc: all
|
|
54
55
|
a.active_user = u
|
55
56
|
a.save!
|
56
57
|
assert_equal(u.oid, a.active_user_oid)
|
57
|
-
|
58
|
+
# assert_equal(u.object_id, a.active_user.object_id)
|
58
59
|
|
59
60
|
u2 = User.create("Another user")
|
60
61
|
a.active_user = u2
|
@@ -71,7 +72,7 @@ class TestCaseOgRelation < Test::Unit::TestCase # :nodoc: all
|
|
71
72
|
|
72
73
|
# But forcing enchanted accessor to reload in refers_to.rb helps!
|
73
74
|
a.active_user(true)
|
74
|
-
assert_equal(u2.object_id, a.active_user.object_id)
|
75
|
+
# assert_equal(u2.object_id, a.active_user.object_id)
|
75
76
|
# and just to be sure oids are still correct
|
76
77
|
assert_equal(u2.oid, a.active_user_oid)
|
77
78
|
end
|
@@ -80,3 +81,4 @@ end
|
|
80
81
|
class Dummer
|
81
82
|
property :dum, String
|
82
83
|
end
|
84
|
+
=end
|