lhs 7.2.0 → 7.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lhs/errors.rb +4 -2
- data/lib/lhs/version.rb +1 -1
- data/spec/item/errors_spec.rb +17 -0
- 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: 438db5368d4104d56de30c647d820ed788cecdcf
|
4
|
+
data.tar.gz: c1fa77d04b224f5abb3761ef0999559d4afde596
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea1065bb1fca7054692d37d2ce43e0f12f4cd27536cf4f9f386d579460541856afdfce3b811b87efbe821c24b23eff3f8c2b5e3016ed493a58ade79464a0b6f6
|
7
|
+
data.tar.gz: 254cea22f98f880082a51f83987ee0cf419d20475d4c51aacd796ef9982f6183f61645d0bc04b133419c212167697d3f241bfee58dbda840711ebff5e63561a7
|
data/lib/lhs/errors.rb
CHANGED
@@ -5,11 +5,13 @@ class LHS::Errors
|
|
5
5
|
attr_reader :messages, :message, :raw
|
6
6
|
|
7
7
|
def initialize(response = nil)
|
8
|
+
@raw = response.body if response
|
8
9
|
@messages = messages_from_response(response)
|
9
10
|
@message = message_from_response(response)
|
10
|
-
@raw = response.body if response
|
11
11
|
rescue JSON::ParserError
|
12
|
-
|
12
|
+
@messages = messages || {}
|
13
|
+
@message = 'parse error'
|
14
|
+
add_error(@messages, 'body', 'parse error')
|
13
15
|
end
|
14
16
|
|
15
17
|
def include?(attribute)
|
data/lib/lhs/version.rb
CHANGED
data/spec/item/errors_spec.rb
CHANGED
@@ -46,6 +46,10 @@ describe LHS::Item do
|
|
46
46
|
}
|
47
47
|
end
|
48
48
|
|
49
|
+
let(:unparsable_error_body) do
|
50
|
+
'<html></html>'
|
51
|
+
end
|
52
|
+
|
49
53
|
before(:each) do
|
50
54
|
LHC.config.placeholder(:datastore, datastore)
|
51
55
|
class Record < LHS::Record
|
@@ -129,4 +133,17 @@ describe LHS::Item do
|
|
129
133
|
expect(record.errors['body']).to eq ['parse error']
|
130
134
|
end
|
131
135
|
end
|
136
|
+
|
137
|
+
context 'unparsable error body' do
|
138
|
+
it 'still tells us that there is an error' do
|
139
|
+
stub_request(:post, "#{datastore}/feedbacks").to_return(status: 400, body: unparsable_error_body)
|
140
|
+
record = Record.build
|
141
|
+
record.name = 'Steve'
|
142
|
+
result = record.save
|
143
|
+
expect(result).to eq false
|
144
|
+
expect(record.errors).to be
|
145
|
+
expect(record.errors.any?).to eq true
|
146
|
+
expect(record.errors['body']).to eq ['parse error']
|
147
|
+
end
|
148
|
+
end
|
132
149
|
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: 7.2.
|
4
|
+
version: 7.2.1
|
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.6.8
|
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
|