lhs 14.0.1 → 14.0.2

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
  SHA1:
3
- metadata.gz: 726e88dd1603afc34575f3ca68bbf387a89b3530
4
- data.tar.gz: 5f42ac2b71bc70c99551699fd76dc3b004e8f65d
3
+ metadata.gz: 7522953bf45a34511846a1b84fb66d60afb359ef
4
+ data.tar.gz: 1cc7f7f9efda635f6421370dce4f9701d2ff5bbf
5
5
  SHA512:
6
- metadata.gz: a781414e59d524e1e84e75a3c0e11814fabf798f16386cbe97f61f6477bef81773db14d7803468fad704c3dde268fd233395255438addd662d779abb4b70dbd9
7
- data.tar.gz: 604b34609d75eec04bfdd7c874f9e8139eb21ee74466fd0db108f5c131c8b17eb314325a5726a3d26b3662301559a80472250bd2b3844d0fcf0e7c61ebffae34
6
+ metadata.gz: 85a6f023c1e558947992ba04f93a37dac7fb9d7465cf4aafa1c5d92d4b950205cf227c56af63cd20f7545cdf2ce20c7a15d1ee51ff5998e603a2d9f02626f7f8
7
+ data.tar.gz: 74dcce5b6bc450bb9d2791c91b4b3b15171db2226b89b8d7b296746eff53640c7c5e73da516d9fc8a4bd0f39a6cb4b7a964f7e71475746606bf221b4a0d637a3
@@ -29,3 +29,6 @@ Rails/DynamicFindBy:
29
29
 
30
30
  Metrics/BlockLength:
31
31
  Enabled: false
32
+
33
+ Style/EmptyLinesAroundBlockBody:
34
+ Enabled: false
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
20
20
  s.requirements << 'Ruby >= 2.3.0'
21
21
  s.required_ruby_version = '>= 2.3.0'
22
22
 
23
- s.add_dependency 'lhc', '>= 6.3.1'
23
+ s.add_dependency 'lhc', '>= 6.4.0'
24
24
  s.add_dependency 'activesupport', '> 4.2'
25
25
  s.add_dependency 'activemodel'
26
26
 
@@ -311,9 +311,9 @@ class LHS::Record
311
311
  end
312
312
 
313
313
  def resolve
314
- @resolved ||= @record_class.new(
315
- @record_class.request(resolved_options)
316
- )
314
+ return @resolved if defined?(@resolved)
315
+ response_data = @record_class.request(resolved_options)
316
+ @resolved = response_data ? @record_class.new(response_data) : nil
317
317
  end
318
318
 
319
319
  def resolved_options
@@ -17,8 +17,8 @@ class LHS::Record
17
17
  else
18
18
  find_by_id(args, options)
19
19
  end
20
- return data if data.is_a?(Array) || !data._record
21
- data._record.new(data)
20
+ return data if data && (data.is_a?(Array) || !data._record)
21
+ data ? data._record.new(data) : nil
22
22
  end
23
23
 
24
24
  private
@@ -24,9 +24,9 @@ class LHS::Record
24
24
  options ||= {}
25
25
  params = params.dup.merge(limit: 1).merge(options.fetch(:params, {}))
26
26
  data = request(options.merge(params: params))
27
- if data._proxy.is_a?(LHS::Collection)
27
+ if data && data._proxy.is_a?(LHS::Collection)
28
28
  data.first || raise(LHC::NotFound.new('No item was found.', data._request.response))
29
- else
29
+ elsif data
30
30
  data._record.new(data)
31
31
  end
32
32
  end
@@ -495,6 +495,7 @@ class LHS::Record
495
495
  endpoint = find_endpoint(options[:params], options.fetch(:url, nil))
496
496
  apply_limit!(options) if options[:all]
497
497
  response = LHC.request(process_options(options, endpoint))
498
+ return nil if response.error_ignored?
498
499
  data = LHS::Data.new(response.body, nil, self, response.request, endpoint)
499
500
  single_request_load_and_merge_remaining_objects!(data, options, endpoint)
500
501
  expand_items(data, options[:expanded]) if data.collection? && options[:expanded]
@@ -1,3 +1,3 @@
1
1
  module LHS
2
- VERSION = "14.0.1"
2
+ VERSION = "14.0.2"
3
3
  end
@@ -78,4 +78,34 @@ describe LHS::Record do
78
78
  .fetch
79
79
  expect(record).to eq nil
80
80
  end
81
+
82
+ context 'response body' do
83
+
84
+ let(:body) { { error_message: 'you are not worthy' }.to_json }
85
+
86
+ it 'returns nil also when ignoring errors on find' do
87
+ stub_request(:get, "http://local.ch/v2/records/1").to_return(status: 500, body: body)
88
+ record = Record
89
+ .ignore(LHC::Error)
90
+ .find(1)
91
+ expect(record).to eq nil
92
+ end
93
+
94
+ it 'returns nil also when ignoring errors on find' do
95
+ stub_request(:get, "http://local.ch/v2/records?color=blue").to_return(status: 500, body: body)
96
+ record = Record
97
+ .ignore(LHC::Error)
98
+ .where(color: 'blue')
99
+ .fetch
100
+ expect(record).to eq nil
101
+ end
102
+
103
+ it 'returns nil also when ignoring errors on find' do
104
+ stub_request(:get, "http://local.ch/v2/records?color=blue&limit=1").to_return(status: 500, body: body)
105
+ record = Record
106
+ .ignore(LHC::Error)
107
+ .find_by(color: 'blue')
108
+ expect(record).to eq nil
109
+ end
110
+ end
81
111
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lhs
3
3
  version: !ruby/object:Gem::Version
4
- version: 14.0.1
4
+ version: 14.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - https://github.com/local-ch/lhs/graphs/contributors
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 6.3.1
19
+ version: 6.4.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 6.3.1
26
+ version: 6.4.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activesupport
29
29
  requirement: !ruby/object:Gem::Requirement