dm-persevere-adapter 0.71.4 → 0.72.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/Gemfile +16 -0
- data/README.txt +1 -1
- data/Rakefile +17 -3
- data/VERSION +1 -1
- data/lib/persevere_adapter.rb +13 -778
- data/lib/persevere_adapter/adapter.rb +544 -0
- data/lib/persevere_adapter/aggregates.rb +75 -0
- data/lib/persevere_adapter/enhance.rb +49 -0
- data/lib/persevere_adapter/json_support.rb +6 -0
- data/lib/persevere_adapter/json_support/core.rb +17 -0
- data/lib/persevere_adapter/json_support/model.rb +22 -0
- data/lib/persevere_adapter/json_support/model/properties.rb +23 -0
- data/lib/persevere_adapter/json_support/property.rb +23 -0
- data/lib/persevere_adapter/json_support/resource.rb +37 -0
- data/lib/persevere_adapter/migrations.rb +104 -0
- data/lib/persevere_adapter/query.rb +208 -0
- data/lib/persevere_adapter/support/big_decimal.rb +10 -0
- data/lib/{persevere.rb → persevere_client.rb} +2 -2
- data/spec/persevere_adapter_spec.rb +508 -488
- data/spec/persevere_client_spec.rb +202 -0
- data/spec/spec_helper.rb +12 -3
- data/tasks/spec.rake +0 -1
- metadata +159 -24
- data/lib/dm/associations/many_to_many.rb +0 -278
- data/lib/dm/associations/relationship.rb +0 -57
- data/lib/dm/model.rb +0 -29
- data/lib/dm/property.rb +0 -25
- data/lib/dm/query.rb +0 -174
- data/lib/dm/resource.rb +0 -102
- data/spec/persevere_spec.rb +0 -201
@@ -49,7 +49,7 @@ class PersevereResult
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
class
|
52
|
+
class PersevereClient
|
53
53
|
HEADERS = { 'Accept' => 'application/json',
|
54
54
|
'Content-Type' => 'application/json'
|
55
55
|
} unless defined?(HEADERS)
|
@@ -135,4 +135,4 @@ class Persevere
|
|
135
135
|
HEADERS.merge( {'Seq-Id' => @sequence_id.to_s, 'Client-Id' => @client_id } )
|
136
136
|
end
|
137
137
|
|
138
|
-
end # class
|
138
|
+
end # class PersevereClient
|
@@ -1,583 +1,603 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
-
gem 'rspec'
|
3
|
-
require 'spec'
|
4
|
-
|
5
|
-
require DataMapper.root / 'lib' / 'dm-core' / 'spec' / 'adapter_shared_spec'
|
6
|
-
|
7
|
-
agg_dir = path_to("dm-aggregates", "0.10.2")[0]
|
8
|
-
require agg_dir / 'spec' / 'public' / 'shared' / 'aggregate_shared_spec'
|
9
|
-
|
10
2
|
require Pathname(__FILE__).dirname.expand_path.parent + 'lib/persevere_adapter'
|
3
|
+
require 'dm-core' / 'spec' / 'shared' / 'adapter_spec'
|
4
|
+
#require path_to("dm-aggregates", "1.0.0")[0] / 'spec' / 'spec_helper'
|
5
|
+
require path_in_gem("dm-aggregates", 'spec', 'public', 'shared', 'aggregate_shared_spec')
|
11
6
|
|
12
7
|
describe DataMapper::Adapters::PersevereAdapter do
|
8
|
+
|
13
9
|
before :all do
|
14
|
-
#
|
15
|
-
|
10
|
+
# DataMapper::Logger.new(STDOUT, :debug)
|
11
|
+
|
12
|
+
@adapter = DataMapper.setup(:default, {
|
16
13
|
:adapter => 'persevere',
|
17
14
|
:host => 'localhost',
|
18
15
|
:port => 8080,
|
19
|
-
:versioned => true
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
before :each do
|
26
|
-
class ::Bozon
|
27
|
-
include DataMapper::Resource
|
28
|
-
|
29
|
-
property :id, Serial
|
30
|
-
property :author, String
|
31
|
-
property :created_at, DateTime
|
32
|
-
property :title, String
|
33
|
-
end
|
34
|
-
|
35
|
-
class ::Dataino
|
36
|
-
include DataMapper::Resource
|
37
|
-
property :id, Serial
|
38
|
-
property :author, String
|
39
|
-
property :created_at, DateTime
|
40
|
-
property :title, String
|
41
|
-
end
|
42
|
-
|
43
|
-
class ::Nugaton
|
44
|
-
include DataMapper::Resource
|
45
|
-
|
46
|
-
property :id, Serial
|
47
|
-
property :name, String
|
48
|
-
end
|
49
|
-
|
50
|
-
class ::Mukatron
|
51
|
-
include DataMapper::Resource
|
52
|
-
|
53
|
-
property :id, Serial
|
54
|
-
property :street1, String
|
55
|
-
property :street12, String
|
56
|
-
property :b8te, String
|
57
|
-
property :name, String
|
58
|
-
end
|
59
|
-
|
60
|
-
class ::Pantsarator
|
61
|
-
include DataMapper::Resource
|
62
|
-
|
63
|
-
property :id, String, :key => true
|
64
|
-
property :pants, Boolean, :field => 'trousers'
|
65
|
-
end
|
66
|
-
|
67
|
-
@test_schema_hash = {
|
68
|
-
'id' => 'Vanilla',
|
69
|
-
'properties' => {
|
70
|
-
'cid' => {'type' => 'string' },
|
71
|
-
'parent' => { 'type' => 'string'},
|
72
|
-
'data' => { 'type' => 'string'}
|
73
|
-
}
|
74
|
-
}
|
16
|
+
:versioned => true
|
17
|
+
})
|
18
|
+
@repository = DataMapper.repository(@adapter.name)
|
19
|
+
end
|
75
20
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
21
|
+
before(:each) do
|
22
|
+
class ::Bozon
|
23
|
+
include DataMapper::Resource
|
24
|
+
|
25
|
+
property :id, Serial
|
26
|
+
property :author, String
|
27
|
+
property :created_at, DateTime
|
28
|
+
property :title, String
|
29
|
+
end
|
30
|
+
|
31
|
+
class ::Dataino
|
32
|
+
include DataMapper::Resource
|
33
|
+
property :id, Serial
|
34
|
+
property :author, String
|
35
|
+
property :created_at, DateTime
|
36
|
+
property :title, String
|
37
|
+
end
|
38
|
+
|
39
|
+
class ::Nugaton
|
40
|
+
include DataMapper::Resource
|
41
|
+
|
42
|
+
property :id, Serial
|
43
|
+
property :name, String
|
44
|
+
end
|
45
|
+
|
46
|
+
class ::Mukatron
|
47
|
+
include DataMapper::Resource
|
48
|
+
|
49
|
+
property :id, Serial
|
50
|
+
property :street1, String
|
51
|
+
property :street12, String
|
52
|
+
property :b8te, String
|
53
|
+
property :name, String
|
54
|
+
end
|
55
|
+
|
56
|
+
class ::Pantsarator
|
57
|
+
include DataMapper::Resource
|
58
|
+
|
59
|
+
property :id, String, :key => true
|
60
|
+
property :pants, Boolean, :field => 'trousers'
|
61
|
+
end
|
62
|
+
|
63
|
+
@test_schema_hash = {
|
64
|
+
'id' => 'Vanilla',
|
65
|
+
'properties' => {
|
66
|
+
'cid' => {'type' => 'string' },
|
67
|
+
'parent' => { 'type' => 'string'},
|
68
|
+
'data' => { 'type' => 'string'}
|
69
|
+
}
|
70
|
+
}
|
71
|
+
|
72
|
+
@test_schema_hash_alt = {
|
73
|
+
'id' => 'test1/Vanilla',
|
74
|
+
'properties' => {
|
75
|
+
'cid' => {'type' => 'string' },
|
76
|
+
'parent' => { 'type' => 'string'},
|
77
|
+
'data' => { 'type' => 'string'}
|
78
|
+
}
|
79
|
+
}
|
80
|
+
|
81
|
+
@test_schema_hash_mod = {
|
82
|
+
'id' => 'Vanilla',
|
83
|
+
'properties' => {
|
84
|
+
'cid' => {'type' => 'string' },
|
85
|
+
'newdata' => { 'type' => 'any'}
|
86
|
+
}
|
87
|
+
}
|
88
|
+
|
89
|
+
@test_schema_hash_alt_mod = {
|
90
|
+
'id' => 'test1/Vanilla',
|
91
|
+
'properties' => {
|
92
|
+
'cid' => {'type' => 'string' },
|
93
|
+
'newdata' => { 'type' => 'any'}
|
94
|
+
}
|
95
|
+
}
|
96
|
+
end
|
97
|
+
|
98
|
+
after(:each) do
|
99
|
+
[::Bozon, ::Nugaton, ::Dataino, ::Mukatron, ::Pantsarator].each do |o|
|
100
|
+
o.auto_migrate_down!
|
101
|
+
DataMapper::Model.descendants.delete(o)
|
102
|
+
Object.send(:remove_const, o.name.to_sym)
|
103
|
+
end
|
104
|
+
end
|
91
105
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
106
|
+
it_should_behave_like 'An Adapter'
|
107
|
+
|
108
|
+
describe 'migrations' do
|
109
|
+
|
110
|
+
it 'should create the Bozon storage' do
|
111
|
+
Bozon.auto_migrate!
|
112
|
+
Bozon.auto_migrate_down!
|
99
113
|
end
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
114
|
+
|
115
|
+
it "should destroy Create then Remove the Bozon Storage" do
|
116
|
+
@adapter.get_schema(Bozon.storage_name).should == false
|
117
|
+
Bozon.auto_migrate_up!
|
118
|
+
@adapter.get_schema(Bozon.storage_name).should_not == false
|
119
|
+
Bozon.auto_migrate_down!
|
120
|
+
@adapter.get_schema(Bozon.storage_name).should == false
|
107
121
|
end
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
122
|
+
|
123
|
+
describe '#put_schema' do
|
124
|
+
|
125
|
+
it 'should create the json schema for the hash' do
|
126
|
+
@adapter.put_schema(@test_schema_hash).should_not == false
|
127
|
+
end
|
128
|
+
|
129
|
+
it 'should create the schema as an extension of the Versioned schema' do
|
130
|
+
@adapter.put_schema(@test_schema_hash).should_not == false
|
131
|
+
test_result = @adapter.get_schema(@test_schema_hash['id'])
|
132
|
+
test_result[0]['extends']['$ref'].should eql "Versioned"
|
133
|
+
end
|
134
|
+
|
135
|
+
it 'should create the json schema for the hash under the specified project' do
|
136
|
+
@adapter.put_schema(@test_schema_hash, "test").should_not == false
|
137
|
+
end
|
138
|
+
|
139
|
+
it 'should create the json schema for the hash under the specified project' do
|
140
|
+
@adapter.put_schema(@test_schema_hash_alt).should_not == false
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
describe '#get_schema' do
|
145
|
+
|
146
|
+
it 'should return all of the schemas (in json) if no name is provided' do
|
114
147
|
Bozon.auto_migrate!
|
148
|
+
Dataino.auto_migrate!
|
149
|
+
result = @adapter.get_schema
|
150
|
+
result.should_not == false
|
151
|
+
result.class.should == Array
|
115
152
|
Bozon.auto_migrate_down!
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
Bozon.auto_migrate_up!
|
121
|
-
@adapter.get_schema(Bozon.storage_name).should_not == false
|
122
|
-
Bozon.auto_migrate_down!
|
123
|
-
@adapter.get_schema(Bozon.storage_name).should == false
|
124
|
-
end
|
125
|
-
|
126
|
-
describe '#put_schema' do
|
127
|
-
|
128
|
-
it 'should create the json schema for the hash' do
|
129
|
-
@adapter.put_schema(@test_schema_hash).should_not == false
|
130
|
-
end
|
131
|
-
|
132
|
-
it 'should create the schema as an extension of the Versioned schema' do
|
133
|
-
@adapter.put_schema(@test_schema_hash).should_not == false
|
134
|
-
test_result = @adapter.get_schema(@test_schema_hash['id'])
|
135
|
-
test_result[0]['extends']['$ref'].should eql "Versioned"
|
136
|
-
end
|
137
|
-
|
138
|
-
it 'should create the json schema for the hash under the specified project' do
|
139
|
-
@adapter.put_schema(@test_schema_hash, "test").should_not == false
|
140
|
-
end
|
141
|
-
|
142
|
-
it 'should create the json schema for the hash under the specified project' do
|
143
|
-
@adapter.put_schema(@test_schema_hash_alt).should_not == false
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
describe '#get_schema' do
|
148
|
-
|
149
|
-
it 'should return all of the schemas (in json) if no name is provided' do
|
150
|
-
Bozon.auto_migrate!
|
151
|
-
Dataino.auto_migrate!
|
152
|
-
result = @adapter.get_schema
|
153
|
-
result.should_not == false
|
154
|
-
result.class.should == Array
|
155
|
-
Bozon.auto_migrate_down!
|
156
|
-
Dataino.auto_migrate_down!
|
157
|
-
end
|
158
|
-
|
159
|
-
it 'should return the json schema of the class specified' do
|
160
|
-
Bozon.auto_migrate!
|
161
|
-
result = @adapter.get_schema("bozon")
|
162
|
-
result.should_not == false
|
163
|
-
result[0]["id"].should == "bozon"
|
164
|
-
Bozon.auto_migrate_down!
|
165
|
-
end
|
166
|
-
|
167
|
-
end
|
168
|
-
|
169
|
-
describe '#update_schema' do
|
170
|
-
|
171
|
-
it 'should update a previously existing schema' do
|
172
|
-
result = @adapter.update_schema(@test_schema_hash_mod)
|
173
|
-
result.should_not == false
|
174
|
-
@test_schema_hash_mod['id'].should match(JSON.parse(result)['id'])
|
175
|
-
end
|
176
|
-
|
177
|
-
it 'should update a previously created schema under the specified project' do
|
178
|
-
result = @adapter.update_schema(@test_schema_hash_mod, "test")
|
179
|
-
result.should_not == false
|
180
|
-
@test_schema_hash_mod['id'].should match(JSON.parse(result)['id'])
|
181
|
-
end
|
182
|
-
|
183
|
-
it 'should update a previously created schema under the specified project' do
|
184
|
-
result = @adapter.update_schema(@test_schema_hash_alt_mod)
|
185
|
-
result.should_not == false
|
186
|
-
@test_schema_hash_alt_mod['id'].should match(JSON.parse(result)['id'])
|
187
|
-
end
|
188
|
-
|
189
|
-
end
|
190
|
-
|
191
|
-
describe '#delete_schema' do
|
192
|
-
it 'should delete the specified schema' do
|
193
|
-
@adapter.delete_schema(@test_schema_hash).should == true
|
194
|
-
end
|
195
|
-
|
196
|
-
it 'should delete the specified schema in the specified project' do
|
197
|
-
@adapter.delete_schema(@test_schema_hash, "test").should == true
|
198
|
-
end
|
199
|
-
|
200
|
-
it 'should delete the specified schema in the specified project' do
|
201
|
-
@adapter.delete_schema(@test_schema_hash_alt).should == true
|
202
|
-
end
|
203
|
-
|
204
|
-
end
|
205
|
-
|
206
|
-
end
|
207
|
-
|
208
|
-
describe 'aggregates' do
|
209
|
-
|
210
|
-
it_should_behave_like 'It Has Setup Resources'
|
211
|
-
|
212
|
-
before :all do
|
213
|
-
@dragons = Dragon.all
|
214
|
-
@countries = Country.all
|
215
|
-
end
|
216
|
-
|
217
|
-
it_should_behave_like 'An Aggregatable Class'
|
218
|
-
|
219
|
-
it "should be able to get a count of objects within a range of dates" do
|
153
|
+
Dataino.auto_migrate_down!
|
154
|
+
end
|
155
|
+
|
156
|
+
it 'should return the json schema of the class specified' do
|
220
157
|
Bozon.auto_migrate!
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
Bozon.create(:author => 'Sean', :created_at => DateTime.now + 7, :title => 'Sometime later')
|
225
|
-
|
226
|
-
Bozon.count.should eql(3)
|
227
|
-
Bozon.count(:created_at => orig_date).should eql(1)
|
228
|
-
Bozon.count(:created_at.gt => orig_date).should eql(2)
|
158
|
+
result = @adapter.get_schema("bozon")
|
159
|
+
result.should_not == false
|
160
|
+
result[0]["id"].should == "bozon"
|
229
161
|
Bozon.auto_migrate_down!
|
230
162
|
end
|
231
|
-
|
232
|
-
it "should count with like conditions" do
|
233
|
-
Country.count(:name.like => '%n%').should == 4
|
234
|
-
end
|
163
|
+
|
235
164
|
end
|
236
|
-
|
237
|
-
describe '
|
238
|
-
|
239
|
-
|
240
|
-
|
165
|
+
|
166
|
+
describe '#update_schema' do
|
167
|
+
|
168
|
+
it 'should update a previously existing schema' do
|
169
|
+
result = @adapter.update_schema(@test_schema_hash_mod)
|
170
|
+
result.should_not == false
|
171
|
+
@test_schema_hash_mod['id'].should match(JSON.parse(result)['id'])
|
172
|
+
end
|
173
|
+
|
174
|
+
it 'should update a previously created schema under the specified project' do
|
175
|
+
result = @adapter.update_schema(@test_schema_hash_mod, "test")
|
176
|
+
result.should_not == false
|
177
|
+
@test_schema_hash_mod['id'].should match(JSON.parse(result)['id'])
|
178
|
+
end
|
179
|
+
|
180
|
+
it 'should update a previously created schema under the specified project' do
|
181
|
+
result = @adapter.update_schema(@test_schema_hash_alt_mod)
|
182
|
+
result.should_not == false
|
183
|
+
@test_schema_hash_alt_mod['id'].should match(JSON.parse(result)['id'])
|
184
|
+
end
|
185
|
+
|
186
|
+
end
|
187
|
+
|
188
|
+
describe '#delete_schema' do
|
189
|
+
it 'should delete the specified schema' do
|
190
|
+
@adapter.delete_schema(@test_schema_hash).should == true
|
241
191
|
end
|
242
|
-
|
243
|
-
it
|
244
|
-
|
245
|
-
result.length.should == 2
|
192
|
+
|
193
|
+
it 'should delete the specified schema in the specified project' do
|
194
|
+
@adapter.delete_schema(@test_schema_hash, "test").should == true
|
246
195
|
end
|
247
|
-
|
248
|
-
it
|
249
|
-
|
250
|
-
result.length.should == 5
|
251
|
-
result.map { |item| item.id }.should == [11, 12, 13, 14, 15]
|
196
|
+
|
197
|
+
it 'should delete the specified schema in the specified project' do
|
198
|
+
@adapter.delete_schema(@test_schema_hash_alt).should == true
|
252
199
|
end
|
200
|
+
|
253
201
|
end
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
202
|
+
|
203
|
+
end
|
204
|
+
|
205
|
+
describe 'aggregates' do
|
206
|
+
before(:all) do
|
207
|
+
# A simplistic example, using with an Integer property
|
208
|
+
class ::Knight
|
209
|
+
include DataMapper::Resource
|
210
|
+
|
211
|
+
property :id, Serial
|
212
|
+
property :name, String
|
258
213
|
end
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
214
|
+
|
215
|
+
class ::Dragon
|
216
|
+
include DataMapper::Resource
|
217
|
+
|
218
|
+
property :id, Serial
|
219
|
+
property :name, String
|
220
|
+
property :is_fire_breathing, Boolean
|
221
|
+
property :toes_on_claw, Integer
|
222
|
+
property :birth_at, DateTime
|
223
|
+
property :birth_on, Date
|
224
|
+
property :birth_time, Time
|
225
|
+
|
226
|
+
belongs_to :knight, :required => false
|
227
|
+
end
|
228
|
+
|
229
|
+
# A more complex example, with BigDecimal and Float properties
|
230
|
+
# Statistics taken from CIA World Factbook:
|
231
|
+
# https://www.cia.gov/library/publications/the-world-factbook/
|
232
|
+
class ::Country
|
233
|
+
include DataMapper::Resource
|
234
|
+
|
235
|
+
property :id, Serial
|
236
|
+
property :name, String, :required => true
|
237
|
+
property :population, Integer
|
238
|
+
property :birth_rate, Float, :precision => 4, :scale => 2
|
239
|
+
property :gold_reserve_tonnes, Float, :precision => 6, :scale => 2
|
240
|
+
property :gold_reserve_value, Decimal, :precision => 15, :scale => 1 # approx. value in USD
|
269
241
|
end
|
270
242
|
end
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
it "should store all the versions of the data element" do
|
278
|
-
version = 1
|
279
|
-
|
280
|
-
# Create the first version
|
281
|
-
nugat = Nugaton.create(:name => "version #{version}")
|
282
|
-
|
283
|
-
# Create a second version
|
284
|
-
nugat.name = "version #{version += 1}"
|
285
|
-
nugat.save
|
286
|
-
|
287
|
-
# Create a third version
|
288
|
-
nugat.name = "version #{version += 1}"
|
289
|
-
nugat.save
|
290
|
-
|
291
|
-
# Retrieve all versions and see if there are three
|
292
|
-
raw_result = @adapter.persevere.retrieve("/nugaton/1", { "Accept" => "application/json+versioned" })
|
293
|
-
results = JSON.parse( raw_result.body )
|
294
|
-
results['current']['name'].should eql "version #{version}"
|
295
|
-
results['versions'].length.should eql 2
|
296
|
-
end
|
297
|
-
|
298
|
-
after(:each) do
|
299
|
-
Nugaton.auto_migrate_down!
|
300
|
-
end
|
243
|
+
|
244
|
+
it_should_behave_like 'It Has Setup Resources'
|
245
|
+
|
246
|
+
before :all do
|
247
|
+
@dragons = Dragon.all
|
248
|
+
@countries = Country.all
|
301
249
|
end
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
Bozon.create(:title => "Name with Space", :author => "Mr. Bean")
|
318
|
-
# [?(title = "Name with Space")][/id]
|
319
|
-
Bozon.all(:title => "Name with Space").length.should eql(1)
|
320
|
-
end
|
321
|
-
|
322
|
-
it "should find by DateTime" do
|
323
|
-
time = Time.now
|
324
|
-
b = Bozon.create(:title => "To Search with Date Time", :author => 'Bloo Reguard', :created_at => time)
|
325
|
-
Bozon.all(:created_at => time).length.should eql(1)
|
326
|
-
end
|
327
|
-
|
328
|
-
it "should be able to pull one field" do
|
329
|
-
Bozon.create(:title => 'Story')
|
330
|
-
Bozon.create(:title => 'Tail')
|
331
|
-
|
332
|
-
# /bozon/[/id][={'title':title}]
|
333
|
-
|
334
|
-
Bozon.all(:fields => [:title]).length.should == 2
|
335
|
-
end
|
336
|
-
|
337
|
-
it "should retrieve properties that end in a number" do
|
338
|
-
Mukatron.create(:street1 => "11th", :b8te => 'true', :name => 'Porky')
|
339
|
-
Mukatron.create(:street1 => "12th", :b8te => 'false', :name => 'Porky')
|
340
|
-
|
341
|
-
# /mukatron/[/id][={id:id,'street1':street1,'b8te':b8te,name:name}]
|
342
|
-
Mukatron.all(:fields => [:id,:street1]).length.should == 2
|
343
|
-
Mukatron.first(:fields => [:id,:street1]).street1.should == "11th"
|
344
|
-
end
|
345
|
-
|
346
|
-
it "should retrieve properties that have a number in the middle" do
|
347
|
-
Mukatron.create(:street1 => "11th", :b8te => 'true', :street12 => "irj", :name => 'Porky')
|
348
|
-
Mukatron.create(:street1 => "12th", :b8te => 'false', :street12 => "ams", :name => 'Porky')
|
349
|
-
# /mukatron/[/id][={'b8te':'b8te'}]
|
350
|
-
Mukatron.all(:fields => [:id,:b8te]).length.should == 2
|
351
|
-
end
|
352
|
-
|
353
|
-
it "should works with fields and properties that have different names" do
|
354
|
-
Pantsarator.create(:id => 'pants', :pants => true)
|
355
|
-
Pantsarator.create(:id => 'underware', :pants => false)
|
356
|
-
|
357
|
-
result = @adapter.get_schema("pantsarator")
|
358
|
-
result.should_not be_false
|
359
|
-
result[0]['properties'].keys.should include('trousers')
|
360
|
-
|
361
|
-
Pantsarator.all(:pants => true).length.should eql 1
|
362
|
-
|
363
|
-
end
|
250
|
+
|
251
|
+
it_should_behave_like 'An Aggregatable Class'
|
252
|
+
|
253
|
+
it "should be able to get a count of objects within a range of dates" do
|
254
|
+
Bozon.auto_migrate!
|
255
|
+
orig_date = DateTime.now - 7
|
256
|
+
Bozon.create(:author => 'Robbie', :created_at => orig_date, :title => '1 week ago')
|
257
|
+
Bozon.create(:author => 'Ivan', :created_at => DateTime.now, :title => 'About Now')
|
258
|
+
Bozon.create(:author => 'Sean', :created_at => DateTime.now + 7, :title => 'Sometime later')
|
259
|
+
|
260
|
+
Bozon.count.should eql(3)
|
261
|
+
Bozon.count(:created_at => orig_date).should eql(1)
|
262
|
+
Bozon.count(:created_at.gt => orig_date).should eql(2)
|
263
|
+
Bozon.auto_migrate_down!
|
364
264
|
end
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
265
|
+
|
266
|
+
it "should count with like conditions" do
|
267
|
+
Country.count(:name.like => '%n%').should == 4
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
describe 'limiting and offsets' do
|
272
|
+
before(:each) do
|
273
|
+
Bozon.auto_migrate!
|
274
|
+
(0..99).each{|i| Bozon.create!(:author => i, :title => i)}
|
275
|
+
end
|
276
|
+
|
277
|
+
it "should limit" do
|
278
|
+
result = Bozon.all(:limit => 2)
|
279
|
+
result.length.should == 2
|
280
|
+
end
|
281
|
+
|
282
|
+
it "should return data from an offset" do
|
283
|
+
result = Bozon.all(:limit => 5, :offset => 10)
|
284
|
+
result.length.should == 5
|
285
|
+
result.map { |item| item.id }.should == [11, 12, 13, 14, 15]
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
289
|
+
describe 'auto updating models' do
|
290
|
+
before :each do
|
291
|
+
Nugaton.auto_migrate!
|
292
|
+
end
|
293
|
+
|
294
|
+
it "should auto upgrade correctly" do
|
295
|
+
before_schema = @adapter.get_schema('nugaton')[0]
|
296
|
+
before_schema['properties'].should have_key('name')
|
297
|
+
before_schema['properties'].should_not have_key('big_value')
|
298
|
+
Nugaton.send(:property, :big_value, Integer)
|
299
|
+
Nugaton.auto_upgrade!
|
300
|
+
before_schema = @adapter.get_schema('nugaton')[0]
|
301
|
+
before_schema['properties'].should have_key('name')
|
302
|
+
before_schema['properties'].should have_key('big_value')
|
303
|
+
end
|
304
|
+
end
|
305
|
+
|
306
|
+
describe 'when using versioned data' do
|
307
|
+
before(:each) do
|
308
|
+
Nugaton.auto_migrate!
|
309
|
+
end
|
310
|
+
|
311
|
+
it "should store all the versions of the data element" do
|
312
|
+
version = 1
|
313
|
+
|
314
|
+
# Create the first version
|
315
|
+
nugat = Nugaton.create(:name => "version #{version}")
|
316
|
+
|
317
|
+
# Create a second version
|
318
|
+
nugat.name = "version #{version += 1}"
|
319
|
+
nugat.save
|
320
|
+
|
321
|
+
# Create a third version
|
322
|
+
nugat.name = "version #{version += 1}"
|
323
|
+
nugat.save
|
324
|
+
|
325
|
+
# Retrieve all versions and see if there are three
|
326
|
+
raw_result = @adapter.persevere.retrieve("/nugaton/1", { "Accept" => "application/json+versioned" })
|
327
|
+
results = JSON.parse( raw_result.body )
|
328
|
+
results['current']['name'].should eql "version #{version}"
|
329
|
+
results['versions'].length.should eql 2
|
330
|
+
end
|
331
|
+
|
332
|
+
after(:each) do
|
333
|
+
Nugaton.auto_migrate_down!
|
334
|
+
end
|
335
|
+
end
|
336
|
+
|
337
|
+
describe 'when finding models,' do
|
338
|
+
before(:each) do
|
339
|
+
Bozon.auto_migrate!
|
340
|
+
Mukatron.auto_migrate!
|
341
|
+
Pantsarator.auto_migrate!
|
342
|
+
end
|
343
|
+
|
344
|
+
it "should find simple strings" do
|
345
|
+
Bozon.create(:title => "Story")
|
346
|
+
Bozon.all(:title => "Story").length.should eql(1)
|
347
|
+
end
|
348
|
+
|
349
|
+
it "should find strings containing spaces" do
|
350
|
+
|
351
|
+
Bozon.create(:title => "Name with Space", :author => "Mr. Bean")
|
352
|
+
# [?(title = "Name with Space")][/id]
|
353
|
+
Bozon.all(:title => "Name with Space").length.should eql(1)
|
354
|
+
end
|
355
|
+
|
356
|
+
it "should find by DateTime" do
|
357
|
+
time = Time.now
|
358
|
+
b = Bozon.create(:title => "To Search with Date Time", :author => 'Bloo Reguard', :created_at => time)
|
359
|
+
Bozon.all(:created_at => time).length.should eql(1)
|
360
|
+
end
|
361
|
+
|
362
|
+
it "should be able to pull one field" do
|
363
|
+
Bozon.create(:title => 'Story')
|
364
|
+
Bozon.create(:title => 'Tail')
|
365
|
+
|
366
|
+
# /bozon/[/id][={'title':title}]
|
367
|
+
|
368
|
+
Bozon.all(:fields => [:title]).length.should == 2
|
369
|
+
end
|
370
|
+
|
371
|
+
it "should retrieve properties that end in a number" do
|
372
|
+
Mukatron.create(:street1 => "11th", :b8te => 'true', :name => 'Porky')
|
373
|
+
Mukatron.create(:street1 => "12th", :b8te => 'false', :name => 'Porky')
|
374
|
+
|
375
|
+
# /mukatron/[/id][={id:id,'street1':street1,'b8te':b8te,name:name}]
|
376
|
+
Mukatron.all(:fields => [:id,:street1]).length.should == 2
|
377
|
+
Mukatron.first(:fields => [:id,:street1]).street1.should == "11th"
|
378
|
+
end
|
379
|
+
|
380
|
+
it "should retrieve properties that have a number in the middle" do
|
381
|
+
Mukatron.create(:street1 => "11th", :b8te => 'true', :street12 => "irj", :name => 'Porky')
|
382
|
+
Mukatron.create(:street1 => "12th", :b8te => 'false', :street12 => "ams", :name => 'Porky')
|
383
|
+
# /mukatron/[/id][={'b8te':'b8te'}]
|
384
|
+
Mukatron.all(:fields => [:id,:b8te]).length.should == 2
|
385
|
+
end
|
386
|
+
|
387
|
+
it "should works with fields and properties that have different names" do
|
388
|
+
Pantsarator.create(:id => 'pants', :pants => true)
|
389
|
+
Pantsarator.create(:id => 'underware', :pants => false)
|
390
|
+
|
391
|
+
result = @adapter.get_schema("pantsarator")
|
392
|
+
result.should_not be_false
|
393
|
+
result[0]['properties'].keys.should include('trousers')
|
394
|
+
|
395
|
+
Pantsarator.all(:pants => true).length.should eql 1
|
396
|
+
|
397
|
+
end
|
398
|
+
end
|
399
|
+
|
400
|
+
describe 'associations' do
|
401
|
+
|
402
|
+
before(:each) do
|
403
|
+
Bozon.auto_migrate!
|
404
|
+
Nugaton.auto_migrate!
|
405
|
+
end
|
406
|
+
|
407
|
+
it "should create one to one (has 1) associations between models" do
|
408
|
+
# Add the relationships
|
409
|
+
Bozon.has(1, :nugaton)
|
410
|
+
Nugaton.belongs_to(:bozon)
|
411
|
+
|
412
|
+
# Push them to the repository
|
413
|
+
Bozon.auto_upgrade!
|
414
|
+
Nugaton.auto_upgrade!
|
415
|
+
|
416
|
+
# Create a couple to make sure they are working
|
417
|
+
bozon = Bozon.new(:author => 'Robbie', :created_at => DateTime.now - 7, :title => '1 week ago')
|
418
|
+
nugat = Nugaton.new(:name => "numero uno")
|
419
|
+
|
420
|
+
bozon.nugaton = nugat
|
421
|
+
bozon.save
|
422
|
+
|
423
|
+
# This is where we're getting what we want, but have to cope with it in the adapter.
|
424
|
+
# As in Nugaton => Bozon is a real bozon, not just a reference...
|
425
|
+
Bozon.first.nugaton.id.should eql nugat.id
|
426
|
+
Nugaton.first.bozon.id.should eql bozon.id
|
427
|
+
end
|
428
|
+
|
429
|
+
it "should not be required to be in a relationship" do
|
430
|
+
Bozon.has(Infinity, :nugatons)
|
431
|
+
Nugaton.belongs_to(:bozon, :required => false)
|
432
|
+
|
433
|
+
Bozon.auto_upgrade!
|
434
|
+
Nugaton.auto_upgrade!
|
435
|
+
|
436
|
+
bozon = Bozon.create(:author => 'Jade', :title => "Jade's the author")
|
437
|
+
|
438
|
+
nugat1 = Nugaton.new(:name => "numero uno")
|
439
|
+
nugat2 = Nugaton.new(:name => "numero duo")
|
440
|
+
|
441
|
+
bozon.nugatons.push( nugat1 )
|
442
|
+
bozon.save
|
443
|
+
|
444
|
+
nugat2.save
|
445
|
+
|
446
|
+
Nugaton.all(:bozon => bozon).length.should eql 1
|
447
|
+
Nugaton.all(:bozon => nil).length.should eql 1
|
448
|
+
|
449
|
+
end
|
450
|
+
|
451
|
+
it "should create one to many (has n) associations between models" do
|
452
|
+
Bozon.has(Infinity, :nugatons)
|
453
|
+
Nugaton.belongs_to(:bozon)
|
454
|
+
Bozon.auto_upgrade!
|
455
|
+
Nugaton.auto_upgrade!
|
456
|
+
|
457
|
+
bozon = Bozon.new(:author => 'Robbie', :created_at => DateTime.now - 7, :title => '1 week ago')
|
458
|
+
nugat1 = Nugaton.new(:name => "numero uno")
|
459
|
+
nugat2 = Nugaton.new(:name => "numero duo")
|
460
|
+
|
461
|
+
bozon.nugatons.push(nugat1, nugat2)
|
462
|
+
bozon.save
|
463
|
+
|
464
|
+
Bozon.first.nugatons.length.should eql 2
|
465
|
+
end
|
466
|
+
|
467
|
+
it "should create many to one (belongs_to) associations between models" do
|
468
|
+
# Add the relationships
|
469
|
+
Nugaton.belongs_to(:bozon)
|
409
470
|
|
410
|
-
|
471
|
+
# Push them to the repository
|
472
|
+
Nugaton.auto_upgrade!
|
411
473
|
|
412
|
-
|
413
|
-
|
474
|
+
# Create a couple to make sure they are working
|
475
|
+
bozon = Bozon.new(:author => 'Robbie', :created_at => DateTime.now - 7, :title => '1 week ago')
|
476
|
+
nugat1 = Nugaton.new(:name => "numero uno")
|
477
|
+
nugat2 = Nugaton.new(:name => "numero duo")
|
414
478
|
|
479
|
+
nugat1.bozon = bozon
|
480
|
+
nugat1.save
|
481
|
+
nugat2.bozon = bozon
|
482
|
+
nugat2.save
|
483
|
+
|
484
|
+
Nugaton.first.bozon.should be_kind_of(Bozon)
|
485
|
+
Nugaton[1].bozon.should be_kind_of(Bozon)
|
486
|
+
end
|
487
|
+
|
488
|
+
describe 'many to many relationships' do
|
489
|
+
before(:all) do
|
490
|
+
@associations_added = false
|
415
491
|
end
|
492
|
+
before(:each) do
|
493
|
+
if(not @associations_added)
|
494
|
+
Bozon.has(Infinity, :nugatons, {:through => DataMapper::Resource})
|
495
|
+
Nugaton.has(Infinity, :bozons, {:through => DataMapper::Resource})
|
496
|
+
Bozon.auto_migrate!
|
497
|
+
Nugaton.auto_migrate!
|
498
|
+
BozonNugaton.auto_migrate!
|
499
|
+
@associations_added = true
|
500
|
+
end
|
416
501
|
|
417
|
-
it "should create one to many (has n) associations between models" do
|
418
|
-
Bozon.has(Infinity, :nugatons)
|
419
|
-
Nugaton.belongs_to(:bozon)
|
420
|
-
Bozon.auto_upgrade!
|
421
|
-
Nugaton.auto_upgrade!
|
422
|
-
|
423
|
-
bozon = Bozon.new(:author => 'Robbie', :created_at => DateTime.now - 7, :title => '1 week ago')
|
424
|
-
nugat1 = Nugaton.new(:name => "numero uno")
|
425
|
-
nugat2 = Nugaton.new(:name => "numero duo")
|
426
|
-
|
427
|
-
bozon.nugatons.push(nugat1, nugat2)
|
428
|
-
bozon.save
|
429
|
-
|
430
|
-
Bozon.first.nugatons.length.should eql 2
|
431
502
|
end
|
432
503
|
|
433
|
-
|
434
|
-
|
435
|
-
Nugaton.
|
436
|
-
|
437
|
-
# Push them to the repository
|
438
|
-
Nugaton.auto_upgrade!
|
439
|
-
|
440
|
-
# Create a couple to make sure they are working
|
441
|
-
bozon = Bozon.new(:author => 'Robbie', :created_at => DateTime.now - 7, :title => '1 week ago')
|
442
|
-
nugat1 = Nugaton.new(:name => "numero uno")
|
443
|
-
nugat2 = Nugaton.new(:name => "numero duo")
|
444
|
-
|
445
|
-
nugat1.bozon = bozon
|
446
|
-
nugat1.save
|
447
|
-
nugat2.bozon = bozon
|
448
|
-
nugat2.save
|
449
|
-
|
450
|
-
Nugaton.first.bozon.should be_kind_of(Bozon)
|
451
|
-
Nugaton[1].bozon.should be_kind_of(Bozon)
|
504
|
+
after(:each) do
|
505
|
+
Bozon.auto_migrate!
|
506
|
+
Nugaton.auto_migrate!
|
507
|
+
BozonNugaton.auto_migrate!
|
452
508
|
end
|
453
|
-
|
454
|
-
it "should
|
455
|
-
Bozon.has(Infinity, :nugatons, {:through => DataMapper::Resource})
|
456
|
-
Nugaton.has(Infinity, :bozons, {:through => DataMapper::Resource})
|
457
|
-
Bozon.auto_upgrade!
|
458
|
-
Nugaton.auto_upgrade!
|
459
|
-
|
509
|
+
|
510
|
+
it "should be able to be created between models" do
|
460
511
|
bozon1 = Bozon.new(:author => 'Robbie', :created_at => DateTime.now - 7, :title => '1 week ago')
|
461
512
|
bozon2 = Bozon.new(:author => 'Ivan', :created_at => DateTime.now - 5, :title => '5 days ago')
|
462
|
-
|
513
|
+
|
463
514
|
nugat1 = Nugaton.new(:name => "numero uno")
|
464
515
|
nugat2 = Nugaton.new(:name => "numero duo")
|
465
|
-
|
516
|
+
|
466
517
|
bozon1.nugatons << nugat1
|
467
518
|
bozon1.nugatons << nugat2
|
468
|
-
|
519
|
+
|
469
520
|
bozon1.save
|
470
|
-
|
521
|
+
|
471
522
|
bozon2.nugatons.push(nugat1,nugat2)
|
472
523
|
bozon2.save
|
473
|
-
|
524
|
+
|
474
525
|
Bozon.first.nugatons.length.should eql 2
|
475
526
|
Nugaton.first.bozons.length.should eql 2
|
476
|
-
end
|
477
|
-
|
478
|
-
it "should
|
479
|
-
Bozon.has(Infinity, :nugatons, {:through => DataMapper::Resource})
|
480
|
-
Nugaton.has(Infinity, :bozons, {:through => DataMapper::Resource})
|
481
|
-
Bozon.auto_upgrade!
|
482
|
-
Nugaton.auto_upgrade!
|
483
|
-
|
484
|
-
bozon1 = Bozon.new(:author => 'Robbie', :created_at => DateTime.now - 7, :title => '1 week ago')
|
485
|
-
bozon2 = Bozon.new(:author => 'Ivan', :created_at => DateTime.now - 5, :title => '5 days ago')
|
486
|
-
|
487
|
-
nugat1 = Nugaton.new(:name => "numero uno")
|
488
|
-
nugat2 = Nugaton.new(:name => "numero duo")
|
489
|
-
|
490
|
-
bozon1.nugatons << nugat1
|
491
|
-
bozon1.nugatons << nugat2
|
492
|
-
bozon1.save
|
493
|
-
|
494
|
-
bozon2.nugatons.push(nugat1,nugat2)
|
495
|
-
bozon2.save
|
496
|
-
end
|
497
|
-
|
498
|
-
it "should remove resources from both sides of the relationship" do
|
499
|
-
Bozon.has(Infinity, :nugatons, {:through => DataMapper::Resource})
|
500
|
-
Nugaton.has(Infinity, :bozons, {:through => DataMapper::Resource})
|
501
|
-
Bozon.auto_upgrade!
|
502
|
-
Nugaton.auto_upgrade!
|
503
|
-
|
527
|
+
# end
|
528
|
+
|
529
|
+
# it "should remove resources from both sides of the relationship" do
|
504
530
|
bozon = Bozon.create(:author => 'Jade', :title => "Jade's the author")
|
505
|
-
|
531
|
+
|
506
532
|
nugat1 = Nugaton.new(:name => "numero uno")
|
507
533
|
nugat2 = Nugaton.new(:name => "numero duo")
|
508
|
-
|
534
|
+
|
509
535
|
bozon.nugatons.push(nugat1, nugat2)
|
510
536
|
bozon.save
|
511
|
-
|
537
|
+
|
512
538
|
bozon.nugatons.delete(nugat1)
|
513
539
|
bozon.save
|
514
540
|
nugat1.save
|
515
|
-
|
541
|
+
|
516
542
|
bozon.nugatons.should_not include(nugat1)
|
543
|
+
|
517
544
|
nugat1.bozons.should be_empty
|
518
|
-
|
519
|
-
Bozon.first.nugatons.length.should be(1)
|
520
|
-
end
|
521
545
|
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
546
|
+
Bozon.get(bozon.id).nugatons.length.should be(1)
|
547
|
+
# end
|
548
|
+
|
549
|
+
# it "should not remove the remaining resources from both sides of the relationship when a single resource is removed" do
|
526
550
|
bozon1 = Bozon.create(:author => 'Jade', :title => "Jade's the author")
|
527
551
|
bozon2 = Bozon.create(:author => 'Ivan', :title => "Blow up the world!")
|
528
552
|
nugat1 = Nugaton.new(:name => "numero uno")
|
529
553
|
nugat2 = Nugaton.new(:name => "numero duo")
|
530
|
-
|
554
|
+
|
531
555
|
bozon1.nugatons.push(nugat1, nugat2)
|
532
|
-
bozon2.nugatons = [nugat1,nugat2]
|
533
556
|
bozon1.save
|
557
|
+
bozon2.nugatons = [nugat1,nugat2]
|
534
558
|
bozon2.save
|
535
|
-
|
559
|
+
|
536
560
|
bozon1.nugatons.delete(nugat1)
|
537
561
|
bozon1.save
|
538
|
-
|
539
|
-
# Bozon1 should have only nugaton2
|
562
|
+
|
563
|
+
# Bozon1 should have only nugaton2
|
540
564
|
Bozon.get(bozon1.id).nugatons.length.should eql 1
|
541
565
|
Bozon.get(bozon1.id).nugatons.should_not include(nugat1)
|
542
566
|
Bozon.get(bozon1.id).nugatons.should include(nugat2)
|
543
|
-
|
567
|
+
|
544
568
|
# Bozon2 should have both nugatons
|
545
569
|
Bozon.get(bozon2.id).nugatons.length.should eql 2
|
546
570
|
Bozon.get(bozon2.id).nugatons.should include(nugat1)
|
547
571
|
Bozon.get(bozon2.id).nugatons.should include(nugat2)
|
548
|
-
|
572
|
+
|
549
573
|
# Nugaton1 should have Bozon2
|
550
574
|
Nugaton.get(nugat1.id).bozons.length.should eql 1
|
551
575
|
Nugaton.get(nugat1.id).bozons.should_not include(bozon1)
|
552
576
|
Nugaton.get(nugat1.id).bozons.should include(bozon2)
|
553
|
-
|
577
|
+
|
554
578
|
# Nugaton2 should have both bozons
|
555
579
|
Nugaton.get(nugat2.id).bozons.length.should eql 2
|
556
580
|
Nugaton.get(nugat2.id).bozons.should include(bozon1)
|
557
581
|
Nugaton.get(nugat2.id).bozons.should include(bozon2)
|
582
|
+
|
583
|
+
::BozonNugaton.auto_migrate_down!
|
558
584
|
end
|
559
|
-
|
560
|
-
it "should
|
561
|
-
Bozon.has(Infinity, :nugatons, {:through => DataMapper::Resource})
|
562
|
-
Nugaton.has(Infinity, :bozons, {:through => DataMapper::Resource})
|
563
|
-
Bozon.auto_upgrade!
|
564
|
-
Nugaton.auto_upgrade!
|
565
|
-
|
585
|
+
|
586
|
+
it "should non-destructively add a second resource" do
|
566
587
|
bozon = Bozon.create(:author => 'Jade', :title => "Jade's the author")
|
567
|
-
|
588
|
+
|
568
589
|
nugat1 = Nugaton.create(:name => "numero uno")
|
569
590
|
nugat2 = Nugaton.create(:name => "numero duo")
|
570
591
|
|
571
592
|
nugat1.bozons << bozon
|
572
593
|
nugat1.save
|
573
|
-
|
574
594
|
n = Nugaton.get(nugat2.id)
|
575
|
-
n.bozons << Bozon.
|
595
|
+
n.bozons << Bozon.get(bozon.id)
|
576
596
|
n.save
|
577
|
-
|
578
597
|
Bozon.get(bozon.id).nugatons.length.should eql 2
|
579
598
|
|
599
|
+
::BozonNugaton.auto_migrate_down!
|
580
600
|
end
|
581
|
-
|
582
601
|
end
|
583
602
|
end
|
603
|
+
end
|