stripe_webhooks 0.4 → 0.5

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: f069c998280e950ef58ee9cf8e78bf94f44cc458
4
- data.tar.gz: 3fabcf9db7389bb00ebfce7cbbd689094b78c949
3
+ metadata.gz: 875ebd1e32a486916b294c0a3f43398dec7b1a1b
4
+ data.tar.gz: ddb4f90b4b5269baf2166a5f3118cc01b1b4e329
5
5
  SHA512:
6
- metadata.gz: 261e7691366f50ae94e5a8613ef18ebd685c66a6c37136cbf71ca29a31c9a2975a3dc4ec1f574d0ba6211f89989d5390b15c4546e957956fee25f9aebfcc9fe4
7
- data.tar.gz: 1cdeb62697cbfa7765dbddc14eae12252c5aed2bdcc3f3dff4acdcb7e52cd316d32b020b6fb906f03d24151ce47585955b276ea7a427a6ecd0242e865bca82e3
6
+ metadata.gz: 970d4f72394fe277a154445e9b5a156e1351c5e2684108c6293f122ebf233c453150e9cc2da4dc6be9421b134ecc39158ead487e0bcf16fbcdca42b83354e5f7
7
+ data.tar.gz: 6df198d3e6430ffcd5f524bb4f3a0887793b3b20ffca2e1ee8ec67cbe807a97b493821e6b0f65c3bbcc8f062622665b6b06a7d1e69dc6fdb3adc91981529f60c
@@ -14,17 +14,15 @@ module StripeWebhooks
14
14
 
15
15
  def validate!
16
16
  return true if is_authentic
17
- begin
18
- event = stripe_event()
19
- update_attributes(is_processed: true,
20
- is_authentic: true,
21
- stripe_event_type: event.type,
22
- stripe_created_at: Time.zone.at(event.created).to_datetime)
23
- return true
24
- rescue Stripe::InvalidRequestError
25
- update_attributes(is_processed: true, is_authentic: false)
26
- return false
27
- end
17
+ event = stripe_event()
18
+ update_attributes(is_processed: true,
19
+ is_authentic: true,
20
+ stripe_event_type: event.type,
21
+ stripe_created_at: Time.zone.at(event.created).to_datetime)
22
+ return true
23
+ rescue Stripe::InvalidRequestError, Stripe::PermissionError
24
+ update_attributes(is_processed: true, is_authentic: false)
25
+ return false
28
26
  end
29
27
 
30
28
  def run_callbacks!
@@ -1,3 +1,3 @@
1
1
  module StripeWebhooks
2
- VERSION = '0.4'.freeze
2
+ VERSION = '0.5'.freeze
3
3
  end
@@ -39,6 +39,14 @@ module StripeWebhooks
39
39
  expect(event.is_authentic).to eq(false)
40
40
  expect(event.is_processed).to eq(true)
41
41
  end
42
+
43
+ it 'catches a permission error' do
44
+ event = StripeWebhooks::Event.create(stripe_event_id: 'test')
45
+ allow(event).to receive(:stripe_event) { raise Stripe::PermissionError }
46
+ expect do
47
+ event.validate!
48
+ end.to change(event, :is_processed).to(true)
49
+ end
42
50
  end
43
51
 
44
52
  describe '#run_callbacks!' do
data/spec/rails_helper.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  # This file is copied to spec/ when you run 'rails generate rspec:install'
2
2
  ENV['RAILS_ENV'] ||= 'test'
3
+ require 'simplecov'
4
+ SimpleCov.start 'rails'
3
5
  require 'spec_helper'
4
6
  require File.expand_path('../dummy/config/environment.rb', __FILE__)
5
7
  require 'rspec/rails'
@@ -8,8 +10,6 @@ require 'rspec/rails'
8
10
  require 'database_cleaner'
9
11
  require 'factory_girl_rails'
10
12
  require 'stripe_mock'
11
- require 'simplecov'
12
- SimpleCov.start 'rails'
13
13
 
14
14
  # Requires supporting ruby files with custom matchers and macros, etc, in
15
15
  # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stripe_webhooks
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.4'
4
+ version: '0.5'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Moser Consulting
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-02 00:00:00.000000000 Z
11
+ date: 2017-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails