dm-persevere-adapter 0.26.0 → 0.27.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/persevere_adapter.rb +3 -2
- data/spec/persevere_adapter_spec.rb +20 -5
- data/spec/persevere_spec.rb +5 -5
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.27.0
|
data/lib/persevere_adapter.rb
CHANGED
@@ -175,7 +175,7 @@ module DataMapper
|
|
175
175
|
extend Chainable
|
176
176
|
extend Deprecate
|
177
177
|
|
178
|
-
RESERVED_CLASSNAMES = ['User','Transaction','Capability','File','Class']
|
178
|
+
RESERVED_CLASSNAMES = ['User','Transaction','Capability','File','Class', 'Object']
|
179
179
|
|
180
180
|
include Migrations::PersevereAdapter
|
181
181
|
|
@@ -419,6 +419,7 @@ module DataMapper
|
|
419
419
|
##
|
420
420
|
def get_schema(name = nil, project = nil)
|
421
421
|
path = nil
|
422
|
+
single = false
|
422
423
|
if name.nil? & project.nil?
|
423
424
|
path = "/Class/"
|
424
425
|
elsif project.nil?
|
@@ -434,7 +435,7 @@ module DataMapper
|
|
434
435
|
schemas.each do |schema|
|
435
436
|
schema['properties']['id'] = { 'type' => Types::Serial}
|
436
437
|
end
|
437
|
-
return
|
438
|
+
return name.nil? ? schemas : schemas[0..0]
|
438
439
|
else
|
439
440
|
return false
|
440
441
|
end
|
@@ -26,6 +26,16 @@ describe DataMapper::Adapters::PersevereAdapter do
|
|
26
26
|
property :title, String
|
27
27
|
end
|
28
28
|
|
29
|
+
class ::Dataino
|
30
|
+
include DataMapper::Resource
|
31
|
+
|
32
|
+
# Persevere only does id's as strings.
|
33
|
+
property :id, String, :serial => true
|
34
|
+
property :author, String
|
35
|
+
property :created_at, DateTime
|
36
|
+
property :title, String
|
37
|
+
end
|
38
|
+
|
29
39
|
@test_schema_hash = {
|
30
40
|
'id' => 'Vanilla',
|
31
41
|
'properties' => {
|
@@ -90,18 +100,23 @@ describe DataMapper::Adapters::PersevereAdapter do
|
|
90
100
|
end
|
91
101
|
end
|
92
102
|
|
93
|
-
describe '#get_schema' do
|
103
|
+
describe '#get_schema' do
|
94
104
|
it 'should return all of the schemas (in json) if no name is provided' do
|
95
|
-
|
96
|
-
|
105
|
+
Bozon.auto_migrate!
|
106
|
+
Dataino.auto_migrate!
|
107
|
+
result = @adapter.get_schema
|
97
108
|
result.should_not == false
|
98
109
|
result.class.should == Array
|
110
|
+
Bozon.auto_migrate_down!
|
111
|
+
Dataino.auto_migrate_down!
|
99
112
|
end
|
100
113
|
|
101
114
|
it 'should return the json schema of the class specified' do
|
102
|
-
|
115
|
+
Bozon.auto_migrate!
|
116
|
+
result = @adapter.get_schema("bozon")
|
103
117
|
result.should_not == false
|
104
|
-
result["id"].should == "
|
118
|
+
result[0]["id"].should == "bozon"
|
119
|
+
Bozon.auto_migrate_down!
|
105
120
|
end
|
106
121
|
end
|
107
122
|
|
data/spec/persevere_spec.rb
CHANGED
@@ -54,11 +54,11 @@ describe Persevere do
|
|
54
54
|
JSON.parse(result.body).should == @mockObj
|
55
55
|
end
|
56
56
|
|
57
|
-
it 'should not allow posting with a bad object' do
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
end
|
57
|
+
# it 'should not allow posting with a bad object' do
|
58
|
+
# result = @p.create('/Class/', @corruptObj)
|
59
|
+
# result.code.should == "500"
|
60
|
+
# result.body.should == "\"Can not modify queries\""
|
61
|
+
# end
|
62
62
|
|
63
63
|
it 'should not allow posting to an existing object/id/path' do
|
64
64
|
result = @p.create('/Class/', @blobObj)
|