solidus_webhooks 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +20 -3
- data/CHANGELOG.md +14 -0
- data/README.md +5 -11
- data/lib/solidus_webhooks.rb +0 -18
- data/lib/solidus_webhooks/configuration.rb +18 -0
- data/lib/solidus_webhooks/version.rb +1 -1
- data/solidus_webhooks.gemspec +4 -4
- data/spec/features/can_register_a_handler_and_receive_webhooks_spec.rb +9 -9
- data/spec/solidus_webhooks/configuration_spec.rb +1 -1
- metadata +9 -11
- data/.rubocop_todo.yml +0 -107
- data/bin/sandbox_rails +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f94eb7d8c956dd983b90ff8ab0d14fde3fbad148400e29222c8be84d403c1baa
|
4
|
+
data.tar.gz: fd828061690984b542190754621d8d9b86ba34ae89070f25db9f838a0de22c78
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37142b4bd06257070f31083a3a99a8594654c626e52e21d41b95f075c4f3a3adc2064cd9831f2c36de5500fa91805d763e5913ea07b9b7c184ac11f6bb6755a8
|
7
|
+
data.tar.gz: f4cb38e4f31a7e7e1c60603c79ccc96b35365b5309b35cd959ff29175f7368ca1f95cd16be32ebdd00a8eeeb92cde2c8d1f00287f2f3e6bab42d0a65987e482a
|
data/.rubocop.yml
CHANGED
@@ -1,11 +1,28 @@
|
|
1
|
-
inherit_from: .rubocop_todo.yml
|
2
|
-
|
3
1
|
require:
|
4
2
|
- solidus_dev_support/rubocop
|
5
3
|
|
6
4
|
AllCops:
|
7
|
-
NewCops:
|
5
|
+
NewCops: disable
|
8
6
|
Exclude:
|
9
7
|
- sandbox/**/*
|
10
8
|
- spec/dummy/**/*
|
11
9
|
- vendor/bundle/**/*
|
10
|
+
|
11
|
+
|
12
|
+
# This guys are troublemakers
|
13
|
+
RSpec/FactoryBot/CreateList:
|
14
|
+
Enabled: false
|
15
|
+
RSpec/Rails/HttpStatus:
|
16
|
+
Enabled: false
|
17
|
+
|
18
|
+
# Deviations from the standard
|
19
|
+
Style/ClassAndModuleChildren:
|
20
|
+
Enabled: false
|
21
|
+
Style/FrozenStringLiteralComment:
|
22
|
+
Enabled: false
|
23
|
+
RSpec/Capybara/FeatureMethods:
|
24
|
+
Enabled: false
|
25
|
+
RSpec/MultipleExpectations:
|
26
|
+
Enabled: false
|
27
|
+
RSpec/NamedSubject:
|
28
|
+
Enabled: false
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [v0.3.0](https://github.com/solidusio-contrib/solidus_webhooks/tree/v0.3.0) (2021-04-20)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/solidusio-contrib/solidus_webhooks/compare/v0.3.0...v0.3.0)
|
6
|
+
|
7
|
+
**Closed issues:**
|
8
|
+
|
9
|
+
- Prepare Solidus Webhooks for Solidus 3.0 [\#8](https://github.com/solidusio-contrib/solidus_webhooks/issues/8)
|
10
|
+
|
11
|
+
**Merged pull requests:**
|
12
|
+
|
13
|
+
- Allow Solidus 3 [\#10](https://github.com/solidusio-contrib/solidus_webhooks/pull/10) ([kennyadsl](https://github.com/kennyadsl))
|
14
|
+
- Reconcile master and v0.3.0 [\#7](https://github.com/solidusio-contrib/solidus_webhooks/pull/7) ([elia](https://github.com/elia))
|
15
|
+
- Bump solidus\_support to ~\> 0.6 [\#6](https://github.com/solidusio-contrib/solidus_webhooks/pull/6) ([peterberkenbosch](https://github.com/peterberkenbosch))
|
16
|
+
|
3
17
|
## [v0.3.0](https://github.com/solidusio-contrib/solidus_webhooks/tree/v0.3.0) (2020-10-20)
|
4
18
|
|
5
19
|
[Full Changelog](https://github.com/solidusio-contrib/solidus_webhooks/compare/v0.2.0...v0.3.0)
|
data/README.md
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
[](https://circleci.com/gh/solidusio-contrib/solidus_webhooks)
|
4
4
|
[](https://codecov.io/gh/solidusio-contrib/solidus_webhooks)
|
5
5
|
|
6
|
+
<!-- Explain what your extension does. -->
|
7
|
+
|
6
8
|
## Installation
|
7
9
|
|
8
10
|
Add solidus_webhooks to your Gemfile:
|
@@ -19,6 +21,8 @@ bin/rails generate solidus_webhooks:install
|
|
19
21
|
|
20
22
|
## Usage
|
21
23
|
|
24
|
+
<!-- Explain how to use your extension once it's been installed. -->
|
25
|
+
|
22
26
|
A Webhook receiver is just a callable and can be registered in the Solidus configuration as follows:
|
23
27
|
|
24
28
|
```ruby
|
@@ -188,17 +192,7 @@ git commit -m "Update the changelog"
|
|
188
192
|
|
189
193
|
### Releasing new versions
|
190
194
|
|
191
|
-
|
192
|
-
|
193
|
-
```shell
|
194
|
-
bundle exec gem bump -v 1.6.0
|
195
|
-
bin/rake changelog
|
196
|
-
git add CHANGELOG.md
|
197
|
-
git commit --amend --no-edit
|
198
|
-
gem tag
|
199
|
-
git push --tags
|
200
|
-
bundle exec gem release
|
201
|
-
```
|
195
|
+
Please refer to the dedicated [page](https://github.com/solidusio/solidus/wiki/How-to-release-extensions) on Solidus wiki.
|
202
196
|
|
203
197
|
## License
|
204
198
|
|
data/lib/solidus_webhooks.rb
CHANGED
@@ -6,21 +6,3 @@ require 'solidus_support'
|
|
6
6
|
require 'solidus_webhooks/configuration'
|
7
7
|
require 'solidus_webhooks/version'
|
8
8
|
require 'solidus_webhooks/engine'
|
9
|
-
|
10
|
-
module SolidusWebhooks
|
11
|
-
class << self
|
12
|
-
def configuration
|
13
|
-
@configuration ||= Configuration.new
|
14
|
-
end
|
15
|
-
|
16
|
-
alias config configuration
|
17
|
-
|
18
|
-
def reset_config!
|
19
|
-
@configuration = nil
|
20
|
-
end
|
21
|
-
|
22
|
-
def configure
|
23
|
-
yield configuration
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'solidus_webhooks/errors'
|
2
4
|
|
3
5
|
module SolidusWebhooks
|
@@ -19,4 +21,20 @@ module SolidusWebhooks
|
|
19
21
|
@handlers[id.to_sym]
|
20
22
|
end
|
21
23
|
end
|
24
|
+
|
25
|
+
class << self
|
26
|
+
def configuration
|
27
|
+
@configuration ||= Configuration.new
|
28
|
+
end
|
29
|
+
|
30
|
+
alias config configuration
|
31
|
+
|
32
|
+
def reset_config!
|
33
|
+
@configuration = nil
|
34
|
+
end
|
35
|
+
|
36
|
+
def configure
|
37
|
+
yield configuration
|
38
|
+
end
|
39
|
+
end
|
22
40
|
end
|
data/solidus_webhooks.gemspec
CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.metadata['source_code_uri'] = 'https://github.com/solidusio-contrib/solidus_webhooks'
|
17
17
|
spec.metadata['changelog_uri'] = 'https://github.com/solidusio-contrib/solidus_webhooks/releases'
|
18
18
|
|
19
|
-
spec.required_ruby_version = Gem::Requirement.new('
|
19
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.5')
|
20
20
|
|
21
21
|
# Specify which files should be added to the gem when it is released.
|
22
22
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
@@ -28,8 +28,8 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.executables = files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
29
|
spec.require_paths = ["lib"]
|
30
30
|
|
31
|
-
spec.add_dependency 'solidus_core', ['>= 2.0.0', '<
|
32
|
-
spec.add_dependency 'solidus_support', '~> 0.
|
31
|
+
spec.add_dependency 'solidus_core', ['>= 2.0.0', '< 4']
|
32
|
+
spec.add_dependency 'solidus_support', '~> 0.6'
|
33
33
|
|
34
|
-
spec.add_development_dependency 'solidus_dev_support', '~> 2.
|
34
|
+
spec.add_development_dependency 'solidus_dev_support', '~> 2.2'
|
35
35
|
end
|
@@ -16,14 +16,14 @@ RSpec.feature "Can register a handler and receive Webhooks", type: :request do
|
|
16
16
|
let(:method_and_user_payloads) { [] }
|
17
17
|
|
18
18
|
let(:proc_handler) { ->(payload) { proc_payloads << payload } }
|
19
|
-
let(:method_handler) {
|
20
|
-
def call(payload) payloads << payload end
|
21
|
-
|
19
|
+
let(:method_handler) {
|
20
|
+
Struct.new(:payloads) { def call(payload) payloads << payload end }.new(method_payloads)
|
21
|
+
}
|
22
22
|
let(:user_handler) { ->(payload, user) { user_payloads << [payload, user] } }
|
23
23
|
let(:splat_handler) { ->(*args) { splat_payloads << args } }
|
24
|
-
let(:method_and_user_handler) {
|
25
|
-
def call(payload, user) payloads << payload end
|
26
|
-
|
24
|
+
let(:method_and_user_handler) {
|
25
|
+
Struct.new(:payloads) { def call(payload, user) payloads << [payload, user] end }.new(method_and_user_payloads)
|
26
|
+
}
|
27
27
|
|
28
28
|
let(:authorized_user) { create(:admin_user, spree_api_key: "123") }
|
29
29
|
let(:authorized_token) { authorized_user.spree_api_key }
|
@@ -41,7 +41,7 @@ RSpec.feature "Can register a handler and receive Webhooks", type: :request do
|
|
41
41
|
post "/webhooks/method?token=#{authorized_token}", as: :json, params: { c: 789 }
|
42
42
|
expect(response).to have_http_status(:ok)
|
43
43
|
|
44
|
-
post "/webhooks/user?token=#{authorized_token}", as: :json, params: { d:
|
44
|
+
post "/webhooks/user?token=#{authorized_token}", as: :json, params: { d: 12 }
|
45
45
|
expect(response).to have_http_status(:ok)
|
46
46
|
|
47
47
|
post "/webhooks/splat?token=#{authorized_token}", as: :json, params: { e: 345 }
|
@@ -52,9 +52,9 @@ RSpec.feature "Can register a handler and receive Webhooks", type: :request do
|
|
52
52
|
|
53
53
|
expect(proc_payloads).to eq([{ 'a' => 123 }, { 'b' => 456 }])
|
54
54
|
expect(method_payloads).to eq([{ 'c' => 789 }])
|
55
|
-
expect(user_payloads).to eq([[{ 'd' =>
|
55
|
+
expect(user_payloads).to eq([[{ 'd' => 12 }, authorized_user]])
|
56
56
|
expect(splat_payloads).to eq([[{ 'e' => 345 }, authorized_user]])
|
57
|
-
expect(method_and_user_payloads).to eq([{ 'f' => 678 }])
|
57
|
+
expect(method_and_user_payloads).to eq([[{ 'f' => 678 }, authorized_user]])
|
58
58
|
end
|
59
59
|
|
60
60
|
scenario "receives a bad handler id" do
|
@@ -4,7 +4,7 @@ RSpec.describe SolidusWebhooks::Configuration do
|
|
4
4
|
describe '#register_webhook_handler' do
|
5
5
|
it 'only accepts callable' do
|
6
6
|
expect{ subject.register_webhook_handler(:foo, Object.new) }.to raise_error(SolidusWebhooks::InvalidHandler)
|
7
|
-
expect{ subject.register_webhook_handler(:bar,
|
7
|
+
expect{ subject.register_webhook_handler(:bar, proc {}) }.not_to raise_error
|
8
8
|
end
|
9
9
|
end
|
10
10
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solidus_webhooks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elia Schito
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: solidus_core
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: 2.0.0
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '4'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,35 +29,35 @@ dependencies:
|
|
29
29
|
version: 2.0.0
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '4'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: solidus_support
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: '0.
|
39
|
+
version: '0.6'
|
40
40
|
type: :runtime
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: '0.
|
46
|
+
version: '0.6'
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: solidus_dev_support
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '2.
|
53
|
+
version: '2.2'
|
54
54
|
type: :development
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: '2.
|
60
|
+
version: '2.2'
|
61
61
|
description:
|
62
62
|
email: contact@solidus.io
|
63
63
|
executables: []
|
@@ -71,7 +71,6 @@ files:
|
|
71
71
|
- ".gitignore"
|
72
72
|
- ".rspec"
|
73
73
|
- ".rubocop.yml"
|
74
|
-
- ".rubocop_todo.yml"
|
75
74
|
- CHANGELOG.md
|
76
75
|
- Gemfile
|
77
76
|
- LICENSE
|
@@ -89,7 +88,6 @@ files:
|
|
89
88
|
- bin/rails-sandbox
|
90
89
|
- bin/rake
|
91
90
|
- bin/sandbox
|
92
|
-
- bin/sandbox_rails
|
93
91
|
- bin/setup
|
94
92
|
- config/locales/en.yml
|
95
93
|
- config/routes.rb
|
@@ -121,7 +119,7 @@ require_paths:
|
|
121
119
|
- lib
|
122
120
|
required_ruby_version: !ruby/object:Gem::Requirement
|
123
121
|
requirements:
|
124
|
-
- - "
|
122
|
+
- - ">="
|
125
123
|
- !ruby/object:Gem::Version
|
126
124
|
version: '2.5'
|
127
125
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
data/.rubocop_todo.yml
DELETED
@@ -1,107 +0,0 @@
|
|
1
|
-
# This configuration was generated by
|
2
|
-
# `rubocop --auto-gen-config`
|
3
|
-
# on 2020-10-19 16:38:34 UTC using RuboCop version 0.93.1.
|
4
|
-
# The point is for the user to remove these configuration records
|
5
|
-
# one by one as the offenses are removed from the code base.
|
6
|
-
# Note that changes in the inspected code, or installation of new
|
7
|
-
# versions of RuboCop, may require this file to be generated again.
|
8
|
-
|
9
|
-
# Offense count: 6
|
10
|
-
# Cop supports --auto-correct.
|
11
|
-
# Configuration parameters: EnabledMethods.
|
12
|
-
Capybara/FeatureMethods:
|
13
|
-
Exclude:
|
14
|
-
- 'spec/features/can_register_a_handler_and_receive_webhooks_spec.rb'
|
15
|
-
|
16
|
-
# Offense count: 2
|
17
|
-
# Cop supports --auto-correct.
|
18
|
-
Layout/BlockEndNewline:
|
19
|
-
Exclude:
|
20
|
-
- 'spec/features/can_register_a_handler_and_receive_webhooks_spec.rb'
|
21
|
-
|
22
|
-
# Offense count: 2
|
23
|
-
# Cop supports --auto-correct.
|
24
|
-
Layout/MultilineBlockLayout:
|
25
|
-
Exclude:
|
26
|
-
- 'spec/features/can_register_a_handler_and_receive_webhooks_spec.rb'
|
27
|
-
|
28
|
-
# Offense count: 2
|
29
|
-
# Cop supports --auto-correct.
|
30
|
-
# Configuration parameters: EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
|
31
|
-
# SupportedStyles: space, no_space
|
32
|
-
# SupportedStylesForEmptyBraces: space, no_space
|
33
|
-
Layout/SpaceInsideBlockBraces:
|
34
|
-
EnforcedStyle: space
|
35
|
-
|
36
|
-
# Offense count: 30
|
37
|
-
# Cop supports --auto-correct.
|
38
|
-
# Configuration parameters: EnforcedStyleForEmptyBraces.
|
39
|
-
# SupportedStyles: space, no_space, compact
|
40
|
-
# SupportedStylesForEmptyBraces: space, no_space
|
41
|
-
Layout/SpaceInsideHashLiteralBraces:
|
42
|
-
EnforcedStyle: space
|
43
|
-
|
44
|
-
# Offense count: 1
|
45
|
-
# Cop supports --auto-correct.
|
46
|
-
Lint/RedundantCopDisableDirective:
|
47
|
-
Exclude:
|
48
|
-
- 'bin/sandbox_rails'
|
49
|
-
|
50
|
-
# Offense count: 1
|
51
|
-
# Cop supports --auto-correct.
|
52
|
-
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods.
|
53
|
-
Lint/UnusedMethodArgument:
|
54
|
-
Exclude:
|
55
|
-
- 'spec/features/can_register_a_handler_and_receive_webhooks_spec.rb'
|
56
|
-
|
57
|
-
# Offense count: 3
|
58
|
-
RSpec/MultipleExpectations:
|
59
|
-
Max: 11
|
60
|
-
|
61
|
-
# Offense count: 1
|
62
|
-
# Configuration parameters: AllowSubject.
|
63
|
-
RSpec/MultipleMemoizedHelpers:
|
64
|
-
Max: 14
|
65
|
-
|
66
|
-
# Offense count: 2
|
67
|
-
# Configuration parameters: IgnoreSharedExamples.
|
68
|
-
RSpec/NamedSubject:
|
69
|
-
Exclude:
|
70
|
-
- 'spec/solidus_webhooks/configuration_spec.rb'
|
71
|
-
|
72
|
-
# Offense count: 2
|
73
|
-
# Cop supports --auto-correct.
|
74
|
-
# Configuration parameters: EnforcedStyle.
|
75
|
-
# SupportedStyles: nested, compact
|
76
|
-
Style/ClassAndModuleChildren:
|
77
|
-
Exclude:
|
78
|
-
- 'app/controllers/spree/webhooks_controller.rb'
|
79
|
-
- 'app/models/spree/webhook.rb'
|
80
|
-
|
81
|
-
# Offense count: 4
|
82
|
-
# Cop supports --auto-correct.
|
83
|
-
# Configuration parameters: EnforcedStyle.
|
84
|
-
# SupportedStyles: always, always_true, never
|
85
|
-
Style/FrozenStringLiteralComment:
|
86
|
-
Exclude:
|
87
|
-
- 'spec/**/*'
|
88
|
-
- 'db/migrate/**/*'
|
89
|
-
- 'bin/**/*'
|
90
|
-
- 'app/controllers/spree/webhooks_controller.rb'
|
91
|
-
- 'app/models/spree/webhook.rb'
|
92
|
-
- 'lib/solidus_webhooks/configuration.rb'
|
93
|
-
- 'lib/solidus_webhooks/errors.rb'
|
94
|
-
|
95
|
-
# Offense count: 2
|
96
|
-
# Cop supports --auto-correct.
|
97
|
-
# Configuration parameters: EnforcedOctalStyle.
|
98
|
-
# SupportedOctalStyles: zero_with_o, zero_only
|
99
|
-
Style/NumericLiteralPrefix:
|
100
|
-
Exclude:
|
101
|
-
- 'spec/features/can_register_a_handler_and_receive_webhooks_spec.rb'
|
102
|
-
|
103
|
-
# Offense count: 1
|
104
|
-
# Cop supports --auto-correct.
|
105
|
-
Style/Proc:
|
106
|
-
Exclude:
|
107
|
-
- 'spec/solidus_webhooks/configuration_spec.rb'
|
data/bin/sandbox_rails
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# frozen_string_literal: true
|
4
|
-
|
5
|
-
app_root = 'sandbox'
|
6
|
-
|
7
|
-
unless File.exist? "#{app_root}/bin/rails"
|
8
|
-
warn 'Creating the sandbox app...'
|
9
|
-
Dir.chdir "#{__dir__}/.." do
|
10
|
-
system "#{__dir__}/sandbox" or begin # rubocop:disable Style/AndOr
|
11
|
-
warn 'Automatic creation of the sandbox app failed'
|
12
|
-
exit 1
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
Dir.chdir app_root
|
18
|
-
exec 'bin/rails', *ARGV
|