lhs 7.2.1 → 7.2.2
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/lib/lhs/concerns/item/save.rb +4 -2
- data/lib/lhs/version.rb +1 -1
- data/spec/item/errors_spec.rb +15 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 362edc3fc0fc431ab0a20d6579d13098ad00f06a
|
4
|
+
data.tar.gz: 9505d7594bbdc3a073796407c257a979df0b8bcb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c14a4998fcbeabf8a2e0f843e72e3afea543bcfe2489b8ce37587f9ced6b7bc98f2bf9dc7fcc07da82d283d87e4600ac313bc573c6a82518cc5e5785fd26c0b
|
7
|
+
data.tar.gz: 5ddebec7d8435c702ed31d157d83027a332c73fad654ec40cf281b7aca098f84f3a5af8c10ae2160a46920f50336c87310fd0ec205236bb3c4b2589789d8d805
|
@@ -8,8 +8,7 @@ class LHS::Item < LHS::Proxy
|
|
8
8
|
|
9
9
|
def save(options = nil)
|
10
10
|
save!(options)
|
11
|
-
rescue LHC::Error
|
12
|
-
self.errors = LHS::Errors.new(e.response)
|
11
|
+
rescue LHC::Error
|
13
12
|
false
|
14
13
|
end
|
15
14
|
|
@@ -33,6 +32,9 @@ class LHS::Item < LHS::Proxy
|
|
33
32
|
data = record_for_persistance.request(options)
|
34
33
|
_data.merge_raw!(data)
|
35
34
|
true
|
35
|
+
rescue LHC::Error => e
|
36
|
+
self.errors = LHS::Errors.new(e.response)
|
37
|
+
raise e
|
36
38
|
end
|
37
39
|
|
38
40
|
private
|
data/lib/lhs/version.rb
CHANGED
data/spec/item/errors_spec.rb
CHANGED
@@ -59,11 +59,11 @@ describe LHS::Item do
|
|
59
59
|
end
|
60
60
|
|
61
61
|
context 'save failed' do
|
62
|
+
let(:record) { Record.build(name: 'Steve') }
|
63
|
+
|
62
64
|
it 'parses fields correctly when creation failed' do
|
63
65
|
stub_request(:post, "#{datastore}/feedbacks")
|
64
66
|
.to_return(status: 400, body: error_format_fields.to_json)
|
65
|
-
record = Record.build
|
66
|
-
record.name = 'Steve'
|
67
67
|
result = record.save
|
68
68
|
expect(result).to eq false
|
69
69
|
expect(record.errors).to be
|
@@ -78,8 +78,6 @@ describe LHS::Item do
|
|
78
78
|
it 'parses field errors correctly when creation failed' do
|
79
79
|
stub_request(:post, "#{datastore}/feedbacks")
|
80
80
|
.to_return(status: 400, body: error_format_field_errors.to_json)
|
81
|
-
record = Record.build
|
82
|
-
record.name = 'Steve'
|
83
81
|
result = record.save
|
84
82
|
expect(result).to eq false
|
85
83
|
expect(record.errors).to be
|
@@ -89,6 +87,19 @@ describe LHS::Item do
|
|
89
87
|
expect(record.errors[:gender]).to eq ['UNSUPPORTED_PROPERTY_VALUE', 'INCOMPLETE_PROPERTY_VALUE']
|
90
88
|
expect(record.errors[:"contract.entry_id"]).to eq ['INCOMPLETE_PROPERTY_VALUE']
|
91
89
|
end
|
90
|
+
|
91
|
+
it 'parses field errors correctly when exception in raised' do
|
92
|
+
stub_request(:post, "#{datastore}/feedbacks")
|
93
|
+
.to_return(status: 400, body: error_format_fields.to_json)
|
94
|
+
expect { record.save! }.to raise_error(LHC::BadRequest)
|
95
|
+
expect(record.errors).to be
|
96
|
+
expect(record.errors.any?).to eq true
|
97
|
+
expect(record.name).to eq 'Steve'
|
98
|
+
expect(record.errors.include?(:ratings)).to eq true
|
99
|
+
expect(record.errors.include?(:recommended)).to eq true
|
100
|
+
expect(record.errors[:ratings]).to eq ['REQUIRED_PROPERTY_VALUE', 'UNSUPPORTED_PROPERTY_VALUE']
|
101
|
+
expect(record.errors[:recommended]).to eq ['REQUIRED_PROPERTY_VALUE']
|
102
|
+
end
|
92
103
|
end
|
93
104
|
|
94
105
|
context 'raw error data' do
|
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: 7.2.
|
4
|
+
version: 7.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- https://github.com/local-ch/lhs/graphs/contributors
|
@@ -376,7 +376,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
376
376
|
requirements:
|
377
377
|
- Ruby >= 2.0.0
|
378
378
|
rubyforge_project:
|
379
|
-
rubygems_version: 2.
|
379
|
+
rubygems_version: 2.5.2
|
380
380
|
signing_key:
|
381
381
|
specification_version: 4
|
382
382
|
summary: Rails gem providing an easy, active-record-like interface for http json services
|