Permalink
Browse files

Don't break when the server does not return a 200 OK.

  • Loading branch information...
Manfred committed Aug 28, 2012
1 parent cf8344b commit fe744f9e71408ec55cb0914c3b0328414d74f462
Showing with 12 additions and 5 deletions.
  1. +6 −5 lib/oja/receipt.rb
  2. +6 −0 spec/oja_spec.rb
View
@@ -37,11 +37,12 @@ def to_json
end
def verify
- response = request(:production)
- if response.sandbox_receipt_in_production?
- request(:sandbox)
- else
- response
+ if response = request(:production)
+ if response.sandbox_receipt_in_production?
+ request(:sandbox)
+ else
+ response
+ end
end
end
View
@@ -13,4 +13,10 @@
response = Oja.verify_filename(receipt_filename('auto_renewable'))
response.should.be.inactive
end
+
+ it "does not return a response when the HTTP request fails" do
+ Oja::Mock.responses << [500, {}]
+ response = Oja.verify_filename(receipt_filename('auto_renewable'))
+ response.should == nil
+ end
end

0 comments on commit fe744f9

Please sign in to comment.