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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f34e507fa4a0cf5496d1993d7b064512f1a2237d8bcf79a6c566d15391575881
4
- data.tar.gz: 3a021151ddf042be1deb2e372df83cc296e1aa88f8d283a9c0bd68b76d44b815
3
+ metadata.gz: 5e152bd168f623e4d40787548c86e7c80c056826311cb15c642e1da4930a6312
4
+ data.tar.gz: 650f2da982b5cddaaa0acebbe83c74cfc9b669a020606f7e542dd6c45760209b
5
5
  SHA512:
6
- metadata.gz: 0ac04e060de22bb5daed4c8002a23ae7a7e992886b519b553ab7f220c26c2d3066b6cff8d7a7d0fbe52b3f9f76c35ddb1bc73438feaab84fc280d28f1a4c7c7e
7
- data.tar.gz: 22198e41021ba24d43ee6a7feacdf3e1298b2747181f5d310a77f91657d23537937b3af22966b84a6cbb481d7d4706ce181f71e576b0208fcf99cfb8e6c085f2
6
+ metadata.gz: 6f37c24832dec19af8e3760affb07e6d05a4bbde1916f56025047dbc35fe08d1cbda1032bacb35a2acc1c2622b5b806785a9c8890460a986c281ebaa6dd18703
7
+ data.tar.gz: 46f124acbba56489d2b83ea411c46250c310a526ef1f8b5e73e916eed31f517a47e3640213b738541a95772056693bd419b413c8e28fb2663e7c45ed1393d749
@@ -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.5'
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'
@@ -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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FinApps
4
- VERSION = '5.0.15'
4
+ VERSION = '5.0.16'
5
5
  end
@@ -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 'when missing id' do
154
- let(:update) { subject.update(nil) }
155
- it('returns missing argument error') do
156
- expect { update }.to raise_error(FinAppsCore::MissingArgumentsError)
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
- context 'when valid id is provided' do
161
- let(:update) { subject.update('valid_id') } # how to stub params
162
- let(:results) { update[RESULTS] }
163
- let(:error_messages) { update[ERROR_MESSAGES] }
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
- it { expect { update }.not_to raise_error }
166
- it('results is nil') { expect(results).to be_nil }
167
- it('error_messages array is empty') { expect(error_messages).to eq([]) }
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 'when invalid id is provided' do
171
- let(:update) { subject.update('invalid_id') }
172
- let(:results) { update[RESULTS] }
173
- let(:error_messages) { update[ERROR_MESSAGES] }
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
- it { expect { update }.not_to raise_error }
176
- it('results is nil') { expect(results).to be_nil }
177
- it('error messages array is populated') do
178
- expect(error_messages.first.downcase).to eq('resource not found')
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
 
@@ -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.15
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-09-27 00:00:00.000000000 Z
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.5
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.5
32
+ version: 5.0.6
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: bundler
35
35
  requirement: !ruby/object:Gem::Requirement