Skip to content

Commit 18b8841

Browse files
committed
fix error checking for InvalidAkidError when response has no "errors" key
1 parent 213030f commit 18b8841

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/action_kit_rest/response/validation_error.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class InvalidAkidError < ValidationError
2727
'לא הצלחנו לקשר בין מספר הזיהוי של רשימת הדיוור הזו לבין החשבון.'].freeze
2828

2929
def self.matches?(errors)
30-
return false unless errors.keys == ['mailing_id']
30+
return false unless errors&.keys == ['mailing_id']
3131

3232
mailing_id_errors = errors['mailing_id']
3333
return false unless mailing_id_errors.size == 1

spec/lib/action_kit_rest/api_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@
5252
expect{ subject.post_request('something/', request_body) }.to raise_error(ActionKitRest::Response::ValidationError)
5353
end
5454
end
55+
56+
context 'no errors key in response' do
57+
let(:response_body) { '{"strange": "things are happening here"}' }
58+
59+
it 'sould raise a ValidationError' do
60+
expect{ subject.post_request('something/', request_body) }.to raise_error(ActionKitRest::Response::ValidationError)
61+
end
62+
end
5563
end
5664

5765
context '401 response' do

0 commit comments

Comments
 (0)