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 +4 -4
- data/app/models/stripe_webhooks/event.rb +9 -11
- data/lib/stripe_webhooks/version.rb +1 -1
- data/spec/models/stripe_webhooks/event_spec.rb +8 -0
- data/spec/rails_helper.rb +2 -2
- 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: 875ebd1e32a486916b294c0a3f43398dec7b1a1b
|
4
|
+
data.tar.gz: ddb4f90b4b5269baf2166a5f3118cc01b1b4e329
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
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!
|
@@ -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
|
+
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-
|
11
|
+
date: 2017-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|