marty 1.0.33 → 1.0.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/components/marty/config_view.rb +1 -1
- data/app/controllers/marty/rpc_controller.rb +10 -4
- data/lib/marty/data_conversion.rb +1 -1
- data/lib/marty/json_schema.rb +4 -19
- data/lib/marty/version.rb +1 -1
- data/spec/controllers/rpc_controller_spec.rb +136 -1
- data/spec/dummy/app/models/gemini/mi_duration_type.rb +12 -0
- data/spec/dummy/db/migrate/20170725160000_add_misc_arrays_to_lp.rb +8 -0
- data/spec/lib/data_importer_spec.rb +23 -14
- data/spec/lib/json_schema_spec.rb +92 -20
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 751328c7a7c786984962edb15f66a8aa2fa680ce
|
|
4
|
+
data.tar.gz: 08d5426a9b837d2f4da1f759c6e27c0a9f7c1c5a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: af123dfccdbd3a075eb489979afa78ffd21bbcfd3615ddcc6b5f764be76d61394e1aab0d853f35f17c327effd9298f0c293c946962ea52fdec764e137dd57713
|
|
7
|
+
data.tar.gz: 40ab7f6dfa2987c2c580a3c5cd4dd0f6baee3b48eb3225572c4ce17dfa6d58df591fe74db745daf421b8e511eff2df0e1fbf47c865daa28114a24c382a2be66d
|
|
@@ -83,10 +83,16 @@ class Marty::RpcController < ActionController::Base
|
|
|
83
83
|
:errors_as_objects => true,
|
|
84
84
|
:version => Marty::JsonSchema::RAW_URI }
|
|
85
85
|
to_append = {"\$schema" => Marty::JsonSchema::RAW_URI}
|
|
86
|
-
schemas.each do |attr,
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
86
|
+
schemas.each do |attr, sch|
|
|
87
|
+
begin
|
|
88
|
+
er = JSON::Validator.fully_validate(sch.merge(to_append), params, opt)
|
|
89
|
+
rescue NameError
|
|
90
|
+
return {error: "Unrecognized PgEnum for attribute #{attr}"}
|
|
91
|
+
rescue => ex
|
|
92
|
+
return {error: ex.message}
|
|
93
|
+
end
|
|
94
|
+
validation_error[attr] = er.map{ |e| e[:message] } if er.size > 0
|
|
95
|
+
err_count += er.size
|
|
90
96
|
end
|
|
91
97
|
end
|
|
92
98
|
return {error: "Error(s) validating: #{validation_error}"} if err_count > 0
|
data/lib/marty/json_schema.rb
CHANGED
|
@@ -19,31 +19,16 @@ module Marty
|
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
class DateTimeFormatAttribute < JSON::Schema::Attribute
|
|
23
|
-
def self.validate(curr_schema, data, frag, processor, validator, options={})
|
|
24
|
-
begin
|
|
25
|
-
DateTime.parse(data).in_time_zone(Rails.configuration.time_zone)
|
|
26
|
-
rescue
|
|
27
|
-
msg = "#{self.class.name} error: Can't parse '#{data}' into a DateTime"
|
|
28
|
-
validation_error( processor,
|
|
29
|
-
msg,
|
|
30
|
-
frag,
|
|
31
|
-
curr_schema,
|
|
32
|
-
self,
|
|
33
|
-
options[:record_errors])
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
22
|
class JsonSchema < JSON::Schema::Draft4
|
|
39
23
|
RAW_URI = "http://json-schema.org/marty-draft/schema#"
|
|
40
24
|
|
|
41
25
|
def initialize
|
|
42
26
|
super
|
|
43
27
|
@attributes["pg_enum"] = PgEnumAttribute
|
|
44
|
-
@
|
|
45
|
-
@
|
|
46
|
-
@
|
|
28
|
+
@formats["date-time"] = JSON::Schema::DateTimeFormat
|
|
29
|
+
@formats["date"] = JSON::Schema::DateFormat
|
|
30
|
+
@uri = JSON::Util::URI.parse(RAW_URI)
|
|
31
|
+
@names = ["marty-draft", RAW_URI]
|
|
47
32
|
end
|
|
48
33
|
|
|
49
34
|
JSON::Validator.register_validator(self.new)
|
data/lib/marty/version.rb
CHANGED
|
@@ -62,6 +62,24 @@ A:
|
|
|
62
62
|
else 9
|
|
63
63
|
eof
|
|
64
64
|
|
|
65
|
+
sample_script6 = <<eof
|
|
66
|
+
A:
|
|
67
|
+
b =?
|
|
68
|
+
res = b + 1
|
|
69
|
+
eof
|
|
70
|
+
|
|
71
|
+
sample_script7 = <<eof
|
|
72
|
+
A:
|
|
73
|
+
b =?
|
|
74
|
+
res = b
|
|
75
|
+
eof
|
|
76
|
+
|
|
77
|
+
sample_script8 = <<eof
|
|
78
|
+
A:
|
|
79
|
+
b =?
|
|
80
|
+
res = 123
|
|
81
|
+
eof
|
|
82
|
+
|
|
65
83
|
script3_schema = <<eof
|
|
66
84
|
A:
|
|
67
85
|
pc = { "properties : {
|
|
@@ -97,6 +115,30 @@ A:
|
|
|
97
115
|
}
|
|
98
116
|
eof
|
|
99
117
|
|
|
118
|
+
script6_schema = <<eof
|
|
119
|
+
A:
|
|
120
|
+
res = { "properties" : {
|
|
121
|
+
"b" : { "type" : "float" },
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
eof
|
|
125
|
+
|
|
126
|
+
script7_schema = <<eof
|
|
127
|
+
A:
|
|
128
|
+
res = { "properties" : {
|
|
129
|
+
"b" : { "pg_enum" : "NonExistantEnum" },
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
eof
|
|
133
|
+
|
|
134
|
+
script8_schema = <<eof
|
|
135
|
+
A:
|
|
136
|
+
res = { "properties" : {
|
|
137
|
+
"b" : { "pg_enum" : "Gemini::MiDurationType" },
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
eof
|
|
141
|
+
|
|
100
142
|
|
|
101
143
|
describe Marty::RpcController do
|
|
102
144
|
before(:each) {
|
|
@@ -117,9 +159,15 @@ describe Marty::RpcController do
|
|
|
117
159
|
"M3" => sample_script3,
|
|
118
160
|
"M4" => sample_script4,
|
|
119
161
|
"M5" => sample_script5,
|
|
162
|
+
"M6" => sample_script6,
|
|
163
|
+
"M7" => sample_script7,
|
|
164
|
+
"M8" => sample_script8,
|
|
120
165
|
"M3Schemas" => script3_schema,
|
|
121
166
|
"M4Schemas" => script4_schema,
|
|
122
167
|
"M5Schemas" => script5_schema,
|
|
168
|
+
"M6Schemas" => script6_schema,
|
|
169
|
+
"M7Schemas" => script7_schema,
|
|
170
|
+
"M8Schemas" => script8_schema,
|
|
123
171
|
}, Date.today + 1.minute)
|
|
124
172
|
|
|
125
173
|
@p1 = Marty::Posting.do_create("BASE", Date.today + 2.minute, 'a comment')
|
|
@@ -370,7 +418,7 @@ describe Marty::RpcController do
|
|
|
370
418
|
expect(response.body).to eq("a,b\r\n123,456\r\n789,101112\r\n")
|
|
371
419
|
end
|
|
372
420
|
|
|
373
|
-
it "returns an error message on missing schema script" do
|
|
421
|
+
it "returns an error message on missing schema script (csv)" do
|
|
374
422
|
Marty::ApiConfig.create!(script: "M1",
|
|
375
423
|
node: "A",
|
|
376
424
|
attr: nil,
|
|
@@ -389,6 +437,28 @@ describe Marty::RpcController do
|
|
|
389
437
|
expect(response.body).to eq("error,#{expect}")
|
|
390
438
|
end
|
|
391
439
|
|
|
440
|
+
it "returns an error message on missing schema script (json)" do
|
|
441
|
+
Marty::ApiConfig.create!(script: "M1",
|
|
442
|
+
node: "A",
|
|
443
|
+
attr: nil,
|
|
444
|
+
logged: false,
|
|
445
|
+
validated: true)
|
|
446
|
+
attrs = ["b"].to_json
|
|
447
|
+
params = {"a" => 5}.to_json
|
|
448
|
+
get 'evaluate', {
|
|
449
|
+
format: :json,
|
|
450
|
+
script: "M1",
|
|
451
|
+
node: "A",
|
|
452
|
+
attrs: attrs,
|
|
453
|
+
params: params
|
|
454
|
+
}
|
|
455
|
+
expect = "Schema error for M1/A attrs=b: Schema not defined"
|
|
456
|
+
res_hsh = JSON.parse(response.body)
|
|
457
|
+
expect(res_hsh.keys.size).to eq(1)
|
|
458
|
+
expect(res_hsh.keys[0]).to eq("error")
|
|
459
|
+
expect(res_hsh.values[0]).to eq(expect)
|
|
460
|
+
end
|
|
461
|
+
|
|
392
462
|
it "returns an error message on missing attributes in schema script" do
|
|
393
463
|
Marty::ApiConfig.create!(script: "M4",
|
|
394
464
|
node: "A",
|
|
@@ -491,6 +561,30 @@ describe Marty::RpcController do
|
|
|
491
561
|
expect(response.body).to eq("9\r\n9\r\n")
|
|
492
562
|
end
|
|
493
563
|
|
|
564
|
+
it "catches JSON::Validator exceptions" do
|
|
565
|
+
Marty::ApiConfig.create!(script: "M6",
|
|
566
|
+
node: "A",
|
|
567
|
+
attr: nil,
|
|
568
|
+
logged: false,
|
|
569
|
+
validated: true)
|
|
570
|
+
attrs = ["res"].to_json
|
|
571
|
+
params = {"b" => 5.22}.to_json
|
|
572
|
+
get 'evaluate', {
|
|
573
|
+
format: :json,
|
|
574
|
+
script: "M6",
|
|
575
|
+
node: "A",
|
|
576
|
+
attrs: attrs,
|
|
577
|
+
params: params
|
|
578
|
+
}
|
|
579
|
+
expect = 'The property \'#/properties/b/type\' of type string '\
|
|
580
|
+
'did not match one or more of the required schemas'
|
|
581
|
+
res_hsh = JSON.parse(response.body)
|
|
582
|
+
expect(res_hsh.keys.size).to eq(1)
|
|
583
|
+
expect(res_hsh.keys[0]).to eq("error")
|
|
584
|
+
expect(res_hsh.values[0]).to eq(expect)
|
|
585
|
+
end
|
|
586
|
+
|
|
587
|
+
|
|
494
588
|
class FruitsEnum
|
|
495
589
|
VALUES=Set['Apple', 'Banana', 'Orange']
|
|
496
590
|
end
|
|
@@ -532,6 +626,47 @@ describe Marty::RpcController do
|
|
|
532
626
|
expect(response.body).to include(expect)
|
|
533
627
|
end
|
|
534
628
|
|
|
629
|
+
it "validates schema with a non-existant enum" do
|
|
630
|
+
Marty::ApiConfig.create!(script: "M7",
|
|
631
|
+
node: "A",
|
|
632
|
+
attr: nil,
|
|
633
|
+
logged: false,
|
|
634
|
+
validated: true)
|
|
635
|
+
attrs = ["res"].to_json
|
|
636
|
+
params = {"b" => "MemberOfANonExistantEnum"}.to_json
|
|
637
|
+
get 'evaluate', {
|
|
638
|
+
format: :json,
|
|
639
|
+
script: "M7",
|
|
640
|
+
node: "A",
|
|
641
|
+
attrs: attrs,
|
|
642
|
+
params: params
|
|
643
|
+
}
|
|
644
|
+
expect = "Unrecognized PgEnum for attribute res"
|
|
645
|
+
res_hsh = JSON.parse(response.body)
|
|
646
|
+
expect(res_hsh.keys.size).to eq(1)
|
|
647
|
+
expect(res_hsh.keys[0]).to eq("error")
|
|
648
|
+
expect(res_hsh.values[0]).to include(expect)
|
|
649
|
+
end
|
|
650
|
+
|
|
651
|
+
it "validates pgenum with capitalization issues" do
|
|
652
|
+
Marty::ApiConfig.create!(script: "M8",
|
|
653
|
+
node: "A",
|
|
654
|
+
attr: nil,
|
|
655
|
+
logged: false,
|
|
656
|
+
validated: true)
|
|
657
|
+
skip "pending until a solution is found that handles "\
|
|
658
|
+
"autoload issues involving constantize"
|
|
659
|
+
attrs = ["res"].to_json
|
|
660
|
+
params = {"b" => "Annual"}.to_json
|
|
661
|
+
get 'evaluate', {
|
|
662
|
+
format: :json,
|
|
663
|
+
script: "M8",
|
|
664
|
+
node: "A",
|
|
665
|
+
attrs: attrs,
|
|
666
|
+
params: params
|
|
667
|
+
}
|
|
668
|
+
end
|
|
669
|
+
|
|
535
670
|
it "should log good req" do
|
|
536
671
|
Marty::ApiConfig.create!(script: "M3",
|
|
537
672
|
node: "A",
|
|
@@ -53,16 +53,17 @@ Conv Fixed 30 2.250 1.123 2.345 12 2012
|
|
|
53
53
|
EOF
|
|
54
54
|
|
|
55
55
|
loan_programs =<<EOF
|
|
56
|
-
name amortization_type mortgage_type streamline_type high_balance_indicator state_array
|
|
57
|
-
Conv Fixed 30 Year Fixed Conventional Not Streamlined false
|
|
58
|
-
Conv Fixed 30 Year HB Fixed Conventional Not Streamlined true TN
|
|
59
|
-
Conv Fixed 30 Year DURP <=80 Fixed Conventional DURP false TN,CT
|
|
60
|
-
Conv Fixed 30 Year DURP <=80 HB Fixed Conventional DURP true "CA,NY"
|
|
56
|
+
name amortization_type mortgage_type streamline_type high_balance_indicator state_array test_int_array test_string_array
|
|
57
|
+
Conv Fixed 30 Year Fixed Conventional Not Streamlined false 1 foo
|
|
58
|
+
Conv Fixed 30 Year HB Fixed Conventional Not Streamlined true TN "1,2" foo,bar
|
|
59
|
+
Conv Fixed 30 Year DURP <=80 Fixed Conventional DURP false TN,CT 1,2,3 "foo,bar"
|
|
60
|
+
Conv Fixed 30 Year DURP <=80 HB Fixed Conventional DURP true "CA,NY" foo,hi mom
|
|
61
61
|
EOF
|
|
62
62
|
|
|
63
63
|
loan_programs_comma =<<EOF
|
|
64
|
-
name,amortization_type,mortgage_type,state_array,streamline_type,high_balance_indicator
|
|
65
|
-
FHA Fixed 15 Year,Fixed,FHA,"FL,NV,ME",Not Streamlined,false
|
|
64
|
+
name,amortization_type,mortgage_type,state_array,test_string_array,streamline_type,high_balance_indicator
|
|
65
|
+
FHA Fixed 15 Year,Fixed,FHA,"FL,NV,ME","ABC,DEF",Not Streamlined,false
|
|
66
|
+
FHA Fixed 100 Year,Fixed,FHA,"FL,NV,ME","XYZ,""hi mom""",Not Streamlined,false
|
|
66
67
|
EOF
|
|
67
68
|
|
|
68
69
|
fannie_bup4 =<<EOF
|
|
@@ -347,16 +348,24 @@ EOF
|
|
|
347
348
|
end
|
|
348
349
|
end
|
|
349
350
|
|
|
350
|
-
it "should load
|
|
351
|
+
it "should load array types" do
|
|
351
352
|
Marty::DataImporter.do_import(Gemini::LoanProgram, loan_programs)
|
|
352
353
|
Marty::DataImporter.do_import(Gemini::LoanProgram, loan_programs_comma,
|
|
353
354
|
'infinity', nil, nil, ',')
|
|
354
|
-
lpset = Gemini::LoanProgram.all.pluck(:name, :state_array
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
["Conv Fixed 30 Year
|
|
359
|
-
|
|
355
|
+
lpset = Gemini::LoanProgram.all.pluck(:name, :state_array,
|
|
356
|
+
:test_int_array,
|
|
357
|
+
:test_string_array).to_set
|
|
358
|
+
expect(lpset).to eq([["Conv Fixed 30 Year", nil, [1], ['foo']],
|
|
359
|
+
["Conv Fixed 30 Year HB", ["TN"], [1, 2],
|
|
360
|
+
['foo', 'bar']],
|
|
361
|
+
["Conv Fixed 30 Year DURP <=80", ["TN", "CT"],
|
|
362
|
+
[1, 2, 3], ['foo', 'bar']],
|
|
363
|
+
["Conv Fixed 30 Year DURP <=80 HB", ["CA", "NY"],
|
|
364
|
+
nil, ['foo', 'hi mom']],
|
|
365
|
+
["FHA Fixed 15 Year", ["FL","NV","ME"], nil,
|
|
366
|
+
['ABC', 'DEF']],
|
|
367
|
+
["FHA Fixed 100 Year", ["FL","NV","ME"], nil,
|
|
368
|
+
['XYZ', 'hi mom']]
|
|
360
369
|
].to_set)
|
|
361
370
|
|
|
362
371
|
end
|
|
@@ -98,64 +98,135 @@ module Marty
|
|
|
98
98
|
expect(JSON::Validator.validate(pg_schema_req, data)).to be false
|
|
99
99
|
end
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
|
|
102
|
+
### Date Format ###
|
|
103
|
+
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
|
|
104
|
+
|
|
105
|
+
date_schema_opt = {
|
|
102
106
|
"$schema" => "http://json-schema.org/marty-draft/schema#",
|
|
103
107
|
"properties" => {
|
|
104
108
|
"a" => {
|
|
105
|
-
"
|
|
109
|
+
"type" => "string",
|
|
110
|
+
"format" => "date"
|
|
106
111
|
}
|
|
107
112
|
}
|
|
108
113
|
}
|
|
109
114
|
|
|
115
|
+
it "returns true on a properly formatted date" do
|
|
116
|
+
data = {"a" => '2017-05-22'}
|
|
117
|
+
expect(JSON::Validator.validate(date_schema_opt, data)).to be true
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
it "vacuously returns true on a field not validated" do
|
|
121
|
+
data = {"b" => 'Today is May 22nd'}
|
|
122
|
+
expect(JSON::Validator.validate(date_schema_opt, data)).to be true
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
it "returns false on an improperly formatted date" do
|
|
126
|
+
data = {"a" => '2017-05-32'}
|
|
127
|
+
expect(JSON::Validator.validate(date_schema_opt, data)).to be false
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
it "returns false on an properly formatted datetime" do
|
|
131
|
+
data = {"a" => '2017-05-22T14:51:44Z'}
|
|
132
|
+
expect(JSON::Validator.validate(date_schema_opt, data)).to be false
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
it "returns true when an optional date is not supplied" do
|
|
136
|
+
data = {}
|
|
137
|
+
expect(JSON::Validator.validate(date_schema_opt, data)).to be true
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
it "returns false when a nil date is passed even when date is optional" do
|
|
141
|
+
data = {"a" => nil}
|
|
142
|
+
expect(JSON::Validator.validate(date_schema_opt, data)).to be false
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
date_schema_req = {
|
|
146
|
+
"$schema" => "http://json-schema.org/marty-draft/schema#",
|
|
147
|
+
"required" => ["a"],
|
|
148
|
+
"properties" => {
|
|
149
|
+
"a" => {
|
|
150
|
+
"type" => "string",
|
|
151
|
+
"format" => "date"
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
it "returns false when a required date field is not supplied" do
|
|
157
|
+
data = {}
|
|
158
|
+
expect(JSON::Validator.validate(date_schema_req, data)).to be false
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
it "returns false when a nil date is passed when date is required" do
|
|
162
|
+
data = {"a" => nil}
|
|
163
|
+
expect(JSON::Validator.validate(date_schema_req, data)).to be false
|
|
164
|
+
end
|
|
165
|
+
|
|
110
166
|
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
|
|
111
167
|
### DateTime Format ###
|
|
112
168
|
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
|
|
113
169
|
|
|
170
|
+
datetime_schema_opt = {
|
|
171
|
+
"$schema" => "http://json-schema.org/marty-draft/schema#",
|
|
172
|
+
"properties" => {
|
|
173
|
+
"a" => {
|
|
174
|
+
"type" => "string",
|
|
175
|
+
"format" => "date-time"
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
114
180
|
it "returns true on a properly formatted datetime" do
|
|
115
181
|
data = {"a" => '2017-05-22T14:51:44Z'}
|
|
116
|
-
expect(JSON::Validator.validate(
|
|
182
|
+
expect(JSON::Validator.validate(datetime_schema_opt, data)).to be true
|
|
117
183
|
end
|
|
118
184
|
|
|
119
185
|
it "vacuously returns true on a field not validated" do
|
|
120
186
|
data = {"b" => 'Today is May 22nd'}
|
|
121
|
-
expect(JSON::Validator.validate(
|
|
187
|
+
expect(JSON::Validator.validate(datetime_schema_opt, data)).to be true
|
|
122
188
|
end
|
|
123
189
|
|
|
124
190
|
it "returns false on an improperly formatted datetime" do
|
|
125
191
|
data = {"a" => '2017-30-22T14:51:44Z'}
|
|
126
|
-
expect(JSON::Validator.validate(
|
|
192
|
+
expect(JSON::Validator.validate(datetime_schema_opt, data)).to be false
|
|
127
193
|
end
|
|
128
194
|
|
|
129
195
|
it "returns true when an opt field is not supplied" do
|
|
130
196
|
data = {}
|
|
131
|
-
expect(JSON::Validator.validate(
|
|
197
|
+
expect(JSON::Validator.validate(datetime_schema_opt, data)).to be true
|
|
132
198
|
end
|
|
133
199
|
|
|
134
200
|
it "returns false when a nil dt is passed even when dt is opt" do
|
|
135
201
|
data = {"a" => nil}
|
|
136
|
-
expect(JSON::Validator.validate(
|
|
202
|
+
expect(JSON::Validator.validate(datetime_schema_opt, data)).to be false
|
|
137
203
|
end
|
|
138
204
|
|
|
139
|
-
|
|
205
|
+
datetime_schema_req = {
|
|
140
206
|
"$schema" => "http://json-schema.org/marty-draft/schema#",
|
|
141
207
|
"required" => ["a"],
|
|
142
208
|
"properties" => {
|
|
143
209
|
"a" => {
|
|
144
|
-
"
|
|
210
|
+
"type" => "string",
|
|
211
|
+
"format" => "date-time"
|
|
145
212
|
}
|
|
146
213
|
}
|
|
147
214
|
}
|
|
148
215
|
|
|
149
216
|
it "returns false when a required field is not supplied" do
|
|
150
217
|
data = {}
|
|
151
|
-
expect(JSON::Validator.validate(
|
|
218
|
+
expect(JSON::Validator.validate(datetime_schema_req, data)).to be false
|
|
152
219
|
end
|
|
153
220
|
|
|
154
221
|
it "returns false when a nil dt is passed when dt is required" do
|
|
155
222
|
data = {"a" => nil}
|
|
156
|
-
expect(JSON::Validator.validate(
|
|
223
|
+
expect(JSON::Validator.validate(datetime_schema_req, data)).to be false
|
|
157
224
|
end
|
|
158
225
|
|
|
226
|
+
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
|
|
227
|
+
### PgEnum & DateTime Format ###
|
|
228
|
+
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
|
|
229
|
+
|
|
159
230
|
pg_dt_schema = {
|
|
160
231
|
"$schema" => "http://json-schema.org/marty-draft/schema#",
|
|
161
232
|
"properties" => {
|
|
@@ -163,15 +234,12 @@ module Marty
|
|
|
163
234
|
"pg_enum" => "MammalEnum"
|
|
164
235
|
},
|
|
165
236
|
"b" => {
|
|
166
|
-
"
|
|
237
|
+
"type" => "string",
|
|
238
|
+
"format" => "date-time"
|
|
167
239
|
},
|
|
168
240
|
}
|
|
169
241
|
}
|
|
170
242
|
|
|
171
|
-
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
|
|
172
|
-
### PgEnum & DateTime Format ###
|
|
173
|
-
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
|
|
174
|
-
|
|
175
243
|
it "validates both pg_enum and dt format when both are correct" do
|
|
176
244
|
data = {"a" => 'Dog', "b" => '2017-05-22T14:51:44Z'}
|
|
177
245
|
expect(JSON::Validator.validate(pg_dt_schema, data)).to be true
|
|
@@ -199,7 +267,8 @@ module Marty
|
|
|
199
267
|
"pg_enum" => "MammalEnum"
|
|
200
268
|
},
|
|
201
269
|
"b" => {
|
|
202
|
-
"
|
|
270
|
+
"type" => "string",
|
|
271
|
+
"format" => "date-time"
|
|
203
272
|
},
|
|
204
273
|
"c" => {
|
|
205
274
|
"type" => "integer"
|
|
@@ -225,7 +294,8 @@ module Marty
|
|
|
225
294
|
"pg_enum" => "MammalEnum"
|
|
226
295
|
},
|
|
227
296
|
"b" => {
|
|
228
|
-
"
|
|
297
|
+
"type" => "string",
|
|
298
|
+
"format" => "date-time"
|
|
229
299
|
},
|
|
230
300
|
"c" => {
|
|
231
301
|
"type" => "integer"
|
|
@@ -246,7 +316,8 @@ module Marty
|
|
|
246
316
|
"pg_enum" => "MammalEnum"
|
|
247
317
|
},
|
|
248
318
|
"b" => {
|
|
249
|
-
"
|
|
319
|
+
"type" => "string",
|
|
320
|
+
"format" => "date-time"
|
|
250
321
|
},
|
|
251
322
|
"c" => {
|
|
252
323
|
"pg_enum" => "ElectronicsEnum"
|
|
@@ -285,7 +356,8 @@ module Marty
|
|
|
285
356
|
"pg_enum" => "MammalEnum"
|
|
286
357
|
},
|
|
287
358
|
"b" => {
|
|
288
|
-
"
|
|
359
|
+
"type" => "string",
|
|
360
|
+
"format" => "date-time"
|
|
289
361
|
},
|
|
290
362
|
"c" => {
|
|
291
363
|
"pg_enum" => "ElectronicsEnum"
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: marty
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.34
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Arman Bostani
|
|
@@ -14,7 +14,7 @@ authors:
|
|
|
14
14
|
autorequire:
|
|
15
15
|
bindir: bin
|
|
16
16
|
cert_chain: []
|
|
17
|
-
date: 2017-07-
|
|
17
|
+
date: 2017-07-26 00:00:00.000000000 Z
|
|
18
18
|
dependencies:
|
|
19
19
|
- !ruby/object:Gem::Dependency
|
|
20
20
|
name: pg
|
|
@@ -537,6 +537,7 @@ files:
|
|
|
537
537
|
- spec/dummy/app/models/gemini/head_version.rb
|
|
538
538
|
- spec/dummy/app/models/gemini/helper.rb
|
|
539
539
|
- spec/dummy/app/models/gemini/loan_program.rb
|
|
540
|
+
- spec/dummy/app/models/gemini/mi_duration_type.rb
|
|
540
541
|
- spec/dummy/app/models/gemini/mortgage_type.rb
|
|
541
542
|
- spec/dummy/app/models/gemini/simple.rb
|
|
542
543
|
- spec/dummy/app/models/gemini/state.rb
|
|
@@ -571,6 +572,7 @@ files:
|
|
|
571
572
|
- spec/dummy/db/migrate/20160100000038_create_gemini_states.rb
|
|
572
573
|
- spec/dummy/db/migrate/20160923183516_add_bulk_pricing_event_ops.rb
|
|
573
574
|
- spec/dummy/db/migrate/20170706081300_add_state_array_to_lp.rb
|
|
575
|
+
- spec/dummy/db/migrate/20170725160000_add_misc_arrays_to_lp.rb
|
|
574
576
|
- spec/dummy/db/seeds.rb
|
|
575
577
|
- spec/dummy/delorean/blame_report.dl
|
|
576
578
|
- spec/dummy/delorean/data_report.dl
|