finapps 5.0.15 → 5.0.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/finapps.gemspec +1 -1
- data/lib/finapps/rest/orders.rb +8 -2
- data/lib/finapps/version.rb +1 -1
- data/spec/rest/orders_spec.rb +62 -20
- data/spec/support/fake_api.rb +9 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e152bd168f623e4d40787548c86e7c80c056826311cb15c642e1da4930a6312
|
4
|
+
data.tar.gz: 650f2da982b5cddaaa0acebbe83c74cfc9b669a020606f7e542dd6c45760209b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f37c24832dec19af8e3760affb07e6d05a4bbde1916f56025047dbc35fe08d1cbda1032bacb35a2acc1c2622b5b806785a9c8890460a986c281ebaa6dd18703
|
7
|
+
data.tar.gz: 46f124acbba56489d2b83ea411c46250c310a526ef1f8b5e73e916eed31f517a47e3640213b738541a95772056693bd419b413c8e28fb2663e7c45ed1393d749
|
data/finapps.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.test_files = Dir['spec/**/*.rb']
|
21
21
|
spec.require_paths = ['lib']
|
22
22
|
|
23
|
-
spec.add_runtime_dependency 'finapps_core', '~> 5.0', '>= 5.0.
|
23
|
+
spec.add_runtime_dependency 'finapps_core', '~> 5.0', '>= 5.0.6'
|
24
24
|
|
25
25
|
spec.add_development_dependency 'bundler', '~> 2.0', '>= 2.0.2'
|
26
26
|
spec.add_development_dependency 'codeclimate-test-reporter', '~> 1.0', '>= 1.0.9'
|
data/lib/finapps/rest/orders.rb
CHANGED
@@ -33,11 +33,13 @@ module FinApps
|
|
33
33
|
super build_query_path(end_point, params)
|
34
34
|
end
|
35
35
|
|
36
|
-
def update(id)
|
36
|
+
def update(id, params = nil)
|
37
|
+
return super params if params # create&submit
|
38
|
+
|
37
39
|
not_blank(id, :id)
|
38
40
|
path = "#{end_point}/#{ERB::Util.url_encode(id)}"
|
39
41
|
|
40
|
-
super nil, path
|
42
|
+
super nil, path # submit
|
41
43
|
end
|
42
44
|
|
43
45
|
def destroy(id)
|
@@ -47,6 +49,10 @@ module FinApps
|
|
47
49
|
send_request path, :put
|
48
50
|
end
|
49
51
|
|
52
|
+
def create_and_submit(params)
|
53
|
+
update(nil, params)
|
54
|
+
end
|
55
|
+
|
50
56
|
private
|
51
57
|
|
52
58
|
def build_filter(params)
|
data/lib/finapps/version.rb
CHANGED
data/spec/rest/orders_spec.rb
CHANGED
@@ -150,33 +150,75 @@ RSpec.describe FinApps::REST::Orders do
|
|
150
150
|
describe '#update' do
|
151
151
|
subject(:orders) { FinApps::REST::Orders.new(client) }
|
152
152
|
|
153
|
-
context '
|
154
|
-
|
155
|
-
|
156
|
-
|
153
|
+
context 'with nil params' do
|
154
|
+
context 'when missing id' do
|
155
|
+
let(:update) { subject.update(nil) }
|
156
|
+
it('returns missing argument error') do
|
157
|
+
expect { update }.to raise_error(FinAppsCore::MissingArgumentsError)
|
158
|
+
end
|
157
159
|
end
|
158
|
-
end
|
159
160
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
161
|
+
context 'when valid id is provided' do
|
162
|
+
let(:update) { subject.update('valid_id') } # how to stub params
|
163
|
+
let(:results) { update[RESULTS] }
|
164
|
+
let(:error_messages) { update[ERROR_MESSAGES] }
|
164
165
|
|
165
|
-
|
166
|
-
|
167
|
-
|
166
|
+
it { expect { update }.not_to raise_error }
|
167
|
+
it('results is nil') { expect(results).to be_nil }
|
168
|
+
it('error_messages array is empty') { expect(error_messages).to eq([]) }
|
169
|
+
end
|
170
|
+
|
171
|
+
context 'when invalid id is provided' do
|
172
|
+
let(:update) { subject.update('invalid_id') }
|
173
|
+
let(:results) { update[RESULTS] }
|
174
|
+
let(:error_messages) { update[ERROR_MESSAGES] }
|
175
|
+
|
176
|
+
it { expect { update }.not_to raise_error }
|
177
|
+
it('results is nil') { expect(results).to be_nil }
|
178
|
+
it('error messages array is populated') do
|
179
|
+
expect(error_messages.first.downcase).to eq('resource not found')
|
180
|
+
end
|
181
|
+
end
|
168
182
|
end
|
169
183
|
|
170
|
-
context '
|
171
|
-
|
172
|
-
|
173
|
-
|
184
|
+
context 'with params' do
|
185
|
+
context 'when missing id' do
|
186
|
+
let(:update) { subject.update(nil, params: 'valid') }
|
187
|
+
it('does not raise error') do
|
188
|
+
expect { update }.not_to raise_error
|
189
|
+
end
|
190
|
+
end
|
174
191
|
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
192
|
+
context 'when valid params are provided' do
|
193
|
+
let(:update) { subject.update(nil, params: 'valid') }
|
194
|
+
let(:results) { update[RESULTS] }
|
195
|
+
let(:error_messages) { update[ERROR_MESSAGES] }
|
196
|
+
|
197
|
+
it { expect { update }.not_to raise_error }
|
198
|
+
it('results is nil') { expect(results).to be_nil }
|
199
|
+
it('error_messages array is empty') { expect(error_messages).to eq([]) }
|
179
200
|
end
|
201
|
+
|
202
|
+
context 'when invalid params are provided' do
|
203
|
+
let(:update) { subject.update(nil, params: 'invalid') }
|
204
|
+
let(:results) { update[RESULTS] }
|
205
|
+
let(:error_messages) { update[ERROR_MESSAGES] }
|
206
|
+
|
207
|
+
it { expect { update }.not_to raise_error }
|
208
|
+
it('results is nil') { expect(results).to be_nil }
|
209
|
+
it('error messages array is populated') do
|
210
|
+
expect(error_messages.first.downcase).to eq('invalid request body')
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
describe '#create_and_submit' do
|
217
|
+
subject(:orders) { FinApps::REST::Orders.new(client) }
|
218
|
+
let(:params) { { params: 'valid' } }
|
219
|
+
it('calls #update') do
|
220
|
+
expect(subject).to receive(:update).with(nil, params)
|
221
|
+
subject.create_and_submit(params)
|
180
222
|
end
|
181
223
|
end
|
182
224
|
|
data/spec/support/fake_api.rb
CHANGED
@@ -148,6 +148,15 @@ class FakeApi < Sinatra::Base
|
|
148
148
|
json_response 404, 'resource_not_found.json'
|
149
149
|
end
|
150
150
|
put("/#{version}/orders/valid_id") { status 204 }
|
151
|
+
put("/#{version}/orders") do
|
152
|
+
request.body.rewind
|
153
|
+
request_payload = JSON.parse request.body.read
|
154
|
+
if request_payload['params'] == 'invalid'
|
155
|
+
json_response 400, 'invalid_request_body.json'
|
156
|
+
else
|
157
|
+
status 204
|
158
|
+
end
|
159
|
+
end
|
151
160
|
post("/#{version}/orders") do
|
152
161
|
request.body.rewind
|
153
162
|
request_payload = JSON.parse request.body.read
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: finapps
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0.
|
4
|
+
version: 5.0.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erich Quintero
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: finapps_core
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: '5.0'
|
20
20
|
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 5.0.
|
22
|
+
version: 5.0.6
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: '5.0'
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 5.0.
|
32
|
+
version: 5.0.6
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: bundler
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|