workarea-gift_cards 3.4.10 → 4.0.3
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 +5 -5
- data/{.eslintrc → .eslintrc.json} +12 -1
- data/.github/workflows/ci.yml +10 -8
- data/.rubocop.yml +2 -197
- data/.stylelintrc.json +8 -0
- data/CHANGELOG.md +40 -20
- data/Gemfile +3 -5
- data/README.md +25 -1
- data/app/controllers/workarea/api/admin/gift_cards_controller.rb +309 -0
- data/app/controllers/workarea/api/storefront/checkouts_controller.decorator +6 -0
- data/app/controllers/workarea/api/storefront/gift_cards_controller.rb +2 -8
- data/app/controllers/workarea/storefront/checkout/gift_cards_controller.rb +32 -0
- data/app/controllers/workarea/storefront/gift_cards_controller.rb +15 -16
- data/app/models/workarea/checkout/steps/gift_card.rb +72 -0
- data/app/models/workarea/fulfillment/policies/create_gift_card.rb +30 -0
- data/app/models/workarea/payment.decorator +25 -7
- data/app/models/workarea/payment/authorize/gift_card.rb +7 -20
- data/app/models/workarea/payment/capture/gift_card.rb +5 -7
- data/app/models/workarea/payment/gift_card.rb +1 -1
- data/app/models/workarea/payment/gift_card_operation.rb +9 -0
- data/app/models/workarea/payment/purchase/gift_card.rb +24 -1
- data/app/models/workarea/payment/refund/gift_card.rb +9 -14
- data/app/models/workarea/payment/tender/gift_card.rb +3 -10
- data/app/models/workarea/search/admin/order.decorator +2 -4
- data/app/seeds/workarea/gift_card_seeds.rb +7 -7
- data/app/view_models/workarea/storefront/gift_card_order_pricing.rb +19 -20
- data/app/view_models/workarea/storefront/order_view_model.decorator +2 -22
- data/app/views/workarea/admin/payment_gift_cards/_menu.html.haml +2 -1
- data/app/views/workarea/storefront/checkouts/_gift_card_error.html.haml +8 -6
- data/app/views/workarea/storefront/checkouts/_gift_card_payment.html.haml +20 -12
- data/app/views/workarea/storefront/gift_card_mailer/created.html.haml +1 -1
- data/app/views/workarea/storefront/order_mailer/_gift_card_summary.html.haml +6 -5
- data/app/views/workarea/storefront/orders/_gift_card_summary.html.haml +2 -2
- data/app/views/workarea/storefront/products/templates/_gift_card.html.haml +5 -5
- data/app/workers/workarea/log_gift_card_redemption.rb +16 -9
- data/config/initializers/configuration.rb +7 -4
- data/config/initializers/fields.rb +14 -0
- data/config/locales/en.yml +14 -4
- data/config/routes.rb +9 -2
- data/lib/workarea/gift_cards.rb +9 -0
- data/lib/workarea/gift_cards/gateway.rb +128 -0
- data/lib/workarea/gift_cards/version.rb +1 -1
- data/test/documentation/workarea/api/admin/gift_cards_documentation_test.rb +24 -10
- data/test/documentation/workarea/api/storefront/gift_cards_documentation_test.rb +57 -50
- data/test/dummy/config/initializers/session_store.rb +1 -1
- data/test/integration/workarea/api/admin/gift_card_integration_test.rb +13 -5
- data/test/integration/workarea/api/storefront/checkout_gift_cards_integration_test.rb +120 -0
- data/test/integration/workarea/api/storefront/{balance_integration_test.rb → gift_cards_integration_test.rb} +1 -1
- data/test/integration/workarea/storefront/checkout_gift_cards_integration_test.rb +116 -0
- data/test/integration/workarea/storefront/gift_cards_integration_test.rb +48 -0
- data/test/integration/workarea/storefront/purchase_gift_cards_integration_test.rb +55 -0
- data/test/lib/workarea/gift_cards/gateway_test.rb +131 -0
- data/test/models/workarea/checkout/steps/gift_card_test.rb +104 -0
- data/test/models/workarea/fulfillment/policies/create_gift_card_test.rb +47 -0
- data/test/models/workarea/gift_card_payment_test.rb +15 -3
- data/test/models/workarea/payment/purchase/gift_card_test.rb +11 -8
- data/test/queries/workarea/admin_redemptions_export_test.rb +31 -35
- data/test/system/workarea/storefront/gift_cards_system_test.rb +8 -2
- data/test/view_models/workarea/storefront/gift_card_order_pricing_test.rb +113 -0
- data/test/workers/workarea/log_gift_card_redemption_test.rb +1 -1
- data/workarea-gift_cards.gemspec +4 -4
- metadata +32 -25
- data/.eslintignore +0 -2
- data/.scss-lint.yml +0 -188
- data/app/controllers/workarea/api/admin/payment_gift_cards_controller.rb +0 -49
- data/app/controllers/workarea/storefront/checkouts_controller.decorator +0 -24
- data/app/services/workarea/checkout/steps/gift_card.rb +0 -49
- data/app/view_models/workarea/storefront/checkout/payment_view_model.decorator +0 -32
- data/app/view_models/workarea/storefront/checkout/summary_view_model.decorator +0 -11
- data/app/workers/workarea/create_ordered_gift_cards.rb +0 -47
- data/config/initializers/jump_to_navigation.rb +0 -3
- data/test/integration/workarea/api/storefront/checkout_integration_test.rb +0 -161
- data/test/integration/workarea/storefront/gift_card_integration_test.rb +0 -226
- data/test/services/workarea/checkout/steps/gift_card_test.rb +0 -87
- data/test/view_models/workarea/storefront/checkout/gift_card_payment_view_model_test.rb +0 -65
- data/test/workers/workarea/create_ordered_gift_cards_test.rb +0 -39
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 4640c0b94ade3085580304d3a0220f85cb73a570d93e3a7c945081a1bda0a72f
|
|
4
|
+
data.tar.gz: bcab8a176b67c59e809a89d0b459d3f01dd123d91e05b6aab8f51f3ea13766cd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4f8f96a3442cabeb3cc94aef6fd542b6a77d0c792947cf795edade12f36f6e67ca1ef743632415a2d4d689990e2f70eeefa8a4b28024699f44658851eeb2e18f
|
|
7
|
+
data.tar.gz: 800f842ad499e8adac230b8fabc356ad890d82c38f8269f449baf2e0f5082740e092df674c14c43c3c2b4a038bad49a9b4e7d13897aab24415668232285c5743
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"extends": "eslint:recommended",
|
|
3
3
|
"rules": {
|
|
4
|
-
"semi": [
|
|
4
|
+
"semi": ["error", "always"],
|
|
5
|
+
"eqeqeq": ["error", "always"]
|
|
5
6
|
},
|
|
6
7
|
"globals": {
|
|
7
8
|
"window": true,
|
|
@@ -20,5 +21,15 @@
|
|
|
20
21
|
"Waypoint": true,
|
|
21
22
|
"wysihtml": true,
|
|
22
23
|
"LocalTime": true,
|
|
24
|
+
"describe": true,
|
|
25
|
+
"after": true,
|
|
26
|
+
"afterEach": true,
|
|
27
|
+
"before": true,
|
|
28
|
+
"beforeEach": true,
|
|
29
|
+
"it": true,
|
|
30
|
+
"expect": true,
|
|
31
|
+
"sinon": true,
|
|
32
|
+
"fixture": true,
|
|
33
|
+
"chai": true
|
|
23
34
|
}
|
|
24
35
|
}
|
data/.github/workflows/ci.yml
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
name: CI
|
|
2
2
|
on: [push]
|
|
3
|
-
|
|
4
|
-
BUNDLE_GEMS__WEBLINC__COM: ${{ secrets.BUNDLE_GEMS__WEBLINC__COM }}
|
|
3
|
+
|
|
5
4
|
jobs:
|
|
6
5
|
static_analysis:
|
|
7
6
|
runs-on: ubuntu-latest
|
|
8
7
|
steps:
|
|
9
8
|
- uses: actions/checkout@v1
|
|
10
|
-
- uses: workarea-commerce/ci/bundler-audit@
|
|
11
|
-
- uses: workarea-commerce/ci/rubocop@
|
|
9
|
+
- uses: workarea-commerce/ci/bundler-audit@v1
|
|
10
|
+
- uses: workarea-commerce/ci/rubocop@v1
|
|
11
|
+
- uses: workarea-commerce/ci/eslint@v1
|
|
12
|
+
with:
|
|
13
|
+
args: '**/*.js'
|
|
12
14
|
|
|
13
15
|
admin_tests:
|
|
14
16
|
runs-on: ubuntu-latest
|
|
@@ -16,7 +18,7 @@ jobs:
|
|
|
16
18
|
- uses: actions/checkout@v1
|
|
17
19
|
- uses: actions/setup-ruby@v1
|
|
18
20
|
with:
|
|
19
|
-
ruby-version: 2.
|
|
21
|
+
ruby-version: 2.6.x
|
|
20
22
|
- uses: workarea-commerce/ci/test@v1
|
|
21
23
|
with:
|
|
22
24
|
command: bin/rails app:workarea:test:admin
|
|
@@ -27,7 +29,7 @@ jobs:
|
|
|
27
29
|
- uses: actions/checkout@v1
|
|
28
30
|
- uses: actions/setup-ruby@v1
|
|
29
31
|
with:
|
|
30
|
-
ruby-version: 2.
|
|
32
|
+
ruby-version: 2.6.x
|
|
31
33
|
- uses: workarea-commerce/ci/test@v1
|
|
32
34
|
with:
|
|
33
35
|
command: bin/rails app:workarea:test:core
|
|
@@ -38,7 +40,7 @@ jobs:
|
|
|
38
40
|
- uses: actions/checkout@v1
|
|
39
41
|
- uses: actions/setup-ruby@v1
|
|
40
42
|
with:
|
|
41
|
-
ruby-version: 2.
|
|
43
|
+
ruby-version: 2.6.x
|
|
42
44
|
- uses: workarea-commerce/ci/test@v1
|
|
43
45
|
with:
|
|
44
46
|
command: bin/rails app:workarea:test:storefront
|
|
@@ -49,7 +51,7 @@ jobs:
|
|
|
49
51
|
- uses: actions/checkout@v1
|
|
50
52
|
- uses: actions/setup-ruby@v1
|
|
51
53
|
with:
|
|
52
|
-
ruby-version: 2.
|
|
54
|
+
ruby-version: 2.6.x
|
|
53
55
|
- uses: workarea-commerce/ci/test@v1
|
|
54
56
|
with:
|
|
55
57
|
command: bin/rails app:workarea:test:plugins
|
data/.rubocop.yml
CHANGED
|
@@ -1,197 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
# RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
|
|
4
|
-
# to ignore them, so only the ones explicitly set in this file are enabled.
|
|
5
|
-
DisabledByDefault: true
|
|
6
|
-
|
|
7
|
-
# Prefer &&/|| over and/or.
|
|
8
|
-
Style/AndOr:
|
|
9
|
-
Enabled: true
|
|
10
|
-
Exclude:
|
|
11
|
-
- 'testing/lib/workarea/performance_test.rb'
|
|
12
|
-
- 'admin/app/controllers/workarea/admin/help_authorization.rb'
|
|
13
|
-
- 'admin/app/controllers/workarea/admin/users_controller.rb'
|
|
14
|
-
- 'core/app/controllers/workarea/authorization.rb'
|
|
15
|
-
- 'core/app/models/workarea/analytics/time_series.rb'
|
|
16
|
-
- 'core/app/models/workarea/payment/operation.rb'
|
|
17
|
-
- 'core/lib/workarea/validators/ip_address_validator.rb'
|
|
18
|
-
- 'script/rename'
|
|
19
|
-
- 'storefront/app/controllers/workarea/storefront/checkout/place_order_controller.rb'
|
|
20
|
-
- 'storefront/app/controllers/workarea/storefront/current_checkout.rb'
|
|
21
|
-
- 'storefront/app/controllers/workarea/storefront/searches_controller.rb'
|
|
22
|
-
- 'storefront/app/controllers/workarea/storefront/users/orders_controller.rb'
|
|
23
|
-
- 'storefront/app/controllers/workarea/storefront/users/passwords_controller.rb'
|
|
24
|
-
|
|
25
|
-
# Align `when` with `case`.
|
|
26
|
-
Layout/CaseIndentation:
|
|
27
|
-
Enabled: true
|
|
28
|
-
Exclude:
|
|
29
|
-
- 'admin/app/helpers/workarea/admin/dashboard_helper.rb'
|
|
30
|
-
|
|
31
|
-
# Align comments with method definitions.
|
|
32
|
-
Layout/CommentIndentation:
|
|
33
|
-
Enabled: true
|
|
34
|
-
|
|
35
|
-
Layout/EmptyLineAfterMagicComment:
|
|
36
|
-
Enabled: true
|
|
37
|
-
|
|
38
|
-
# In a regular class definition, no empty lines around the body.
|
|
39
|
-
Layout/EmptyLinesAroundClassBody:
|
|
40
|
-
Enabled: true
|
|
41
|
-
Exclude:
|
|
42
|
-
- 'admin/app/controllers/workarea/admin/release_sessions_controller.rb'
|
|
43
|
-
- 'admin/app/view_models/workarea/admin/release_calendar_view_model.rb'
|
|
44
|
-
- 'admin/lib/workarea/mailer_previews/admin/comment_mailer_preview.rb'
|
|
45
|
-
- 'admin/test/integration/workarea/admin/content_blocks_integration_test.rb'
|
|
46
|
-
- 'admin/test/view_models/workarea/admin/content_view_model_test.rb'
|
|
47
|
-
- 'core/app/models/workarea/checkout/steps/addresses.rb'
|
|
48
|
-
- 'core/app/models/workarea/pricing/discount/buy_some_get_some/product_application.rb'
|
|
49
|
-
- 'core/app/queries/workarea/metadata/catalog_category.rb'
|
|
50
|
-
- 'core/app/queries/workarea/metadata/content_page.rb'
|
|
51
|
-
- 'core/app/queries/workarea/search/facet.rb'
|
|
52
|
-
- 'core/app/queries/workarea/search/range_filter.rb'
|
|
53
|
-
- 'core/config/initializers/13_rack_attack.rb'
|
|
54
|
-
- 'core/lib/generators/workarea/override/override_generator.rb'
|
|
55
|
-
- 'core/lib/workarea/elasticsearch/query_cache.rb'
|
|
56
|
-
- 'core/lib/workarea/monitoring/elasticsearch_check.rb'
|
|
57
|
-
- 'core/lib/workarea/monitoring/mongoid_check.rb'
|
|
58
|
-
- 'core/lib/workarea/monitoring/sidekiq_queue_size_check.rb'
|
|
59
|
-
- 'core/lib/workarea/validators/email_validator.rb'
|
|
60
|
-
- 'core/test/lib/workarea/mail_interceptor_test.rb'
|
|
61
|
-
- 'core/test/models/workarea/commentable_test.rb'
|
|
62
|
-
- 'core/test/models/workarea/search/settings_test.rb'
|
|
63
|
-
- 'core/test/models/workarea/shipping/rate_lookup_test.rb'
|
|
64
|
-
- 'core/test/queries/workarea/find_pipeline_asset_test.rb'
|
|
65
|
-
- 'core/test/queries/workarea/product_primary_image_url_test.rb'
|
|
66
|
-
- 'core/test/queries/workarea/search/filter_test.rb'
|
|
67
|
-
- 'core/test/workers/workarea/bulk_index_admin_test.rb'
|
|
68
|
-
- 'core/test/workers/workarea/bulk_index_products_test.rb'
|
|
69
|
-
- 'core/vendor/active_shipping/lib/active_shipping/carriers/australia_post.rb'
|
|
70
|
-
- 'core/vendor/active_shipping/lib/active_shipping/carriers/canada_post_pws.rb'
|
|
71
|
-
- 'core/vendor/active_shipping/lib/active_shipping/carriers/usps_returns.rb'
|
|
72
|
-
- 'core/vendor/active_shipping/lib/active_shipping/delivery_date_estimates_response.rb'
|
|
73
|
-
- 'core/vendor/active_shipping/lib/active_shipping/rate_response.rb'
|
|
74
|
-
- 'core/vendor/active_shipping/test/remote/australia_post_test.rb'
|
|
75
|
-
- 'core/vendor/active_shipping/test/remote/usps_returns_test.rb'
|
|
76
|
-
- 'core/vendor/active_shipping/test/unit/carriers/australia_post_test.rb'
|
|
77
|
-
- 'core/vendor/active_shipping/test/unit/carriers/canada_post_pws_test.rb'
|
|
78
|
-
- 'core/vendor/active_shipping/test/unit/carriers/usps_returns_test.rb'
|
|
79
|
-
- 'storefront/app/view_models/workarea/storefront/content_blocks/product_list_view_model.rb'
|
|
80
|
-
- 'storefront/app/view_models/workarea/storefront/product_view_model.rb'
|
|
81
|
-
- 'storefront/lib/workarea/mailer_previews/storefront/order_mailer_preview.rb'
|
|
82
|
-
- 'storefront/test/performance/workarea/storefront/categories_performance_test.rb'
|
|
83
|
-
- 'storefront/test/performance/workarea/storefront/search_performance_test.rb'
|
|
84
|
-
- 'storefront/test/view_models/workarea/storefront/user_activity_view_model_test.rb'
|
|
85
|
-
|
|
86
|
-
# In a regular method definition, no empty lines around the body.
|
|
87
|
-
Layout/EmptyLinesAroundMethodBody:
|
|
88
|
-
Enabled: true
|
|
89
|
-
|
|
90
|
-
# In a regular module definition, no empty lines around the body.
|
|
91
|
-
Layout/EmptyLinesAroundModuleBody:
|
|
92
|
-
Enabled: true
|
|
93
|
-
Exclude:
|
|
94
|
-
- 'core/lib/workarea/ext/mongoid/timestamps_timeless.rb'
|
|
95
|
-
- 'storefront/app/view_models/workarea/storefront/search_customization_content.rb'
|
|
96
|
-
- 'testing/lib/workarea/testing/warning_suppressor.rb'
|
|
97
|
-
|
|
98
|
-
# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
|
|
99
|
-
Style/HashSyntax:
|
|
100
|
-
Enabled: true
|
|
101
|
-
|
|
102
|
-
Layout/SpaceAfterColon:
|
|
103
|
-
Enabled: true
|
|
104
|
-
Exclude:
|
|
105
|
-
- 'testing/lib/workarea/testing/factories/content.rb'
|
|
106
|
-
- 'testing/lib/workarea/testing/factories/pricing.rb'
|
|
107
|
-
|
|
108
|
-
Layout/SpaceAfterComma:
|
|
109
|
-
Enabled: true
|
|
110
|
-
Exclude:
|
|
111
|
-
- 'admin/app/controllers/workarea/admin/shipping_services_controller.rb'
|
|
112
|
-
- 'admin/test/helpers/workarea/admin/application_helper_test.rb'
|
|
113
|
-
- 'core/app/models/workarea/payment/credit_card.rb'
|
|
114
|
-
- 'core/app/models/workarea/pricing/request.rb'
|
|
115
|
-
- 'core/spec/lib/workarea/swappable_list_spec.rb'
|
|
116
|
-
- 'core/test/models/workarea/inventory_test.rb'
|
|
117
|
-
- 'core/test/queries/workarea/search/range_facet_test.rb'
|
|
118
|
-
- 'storefront/test/view_models/workarea/storefront/package_view_model_test.rb'
|
|
119
|
-
|
|
120
|
-
Layout/SpaceAroundEqualsInParameterDefault:
|
|
121
|
-
Enabled: true
|
|
122
|
-
Exclude:
|
|
123
|
-
- 'admin/app/helpers/workarea/admin/content_block_icon_helper.rb'
|
|
124
|
-
- 'core/app/helpers/workarea/content_assets_helper.rb'
|
|
125
|
-
- 'core/lib/workarea/elasticsearch/query_cache.rb'
|
|
126
|
-
- 'testing/lib/workarea/system_test.rb'
|
|
127
|
-
- 'testing/lib/workarea/testing/locale_routing_fixes.rb'
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
Layout/SpaceAroundKeyword:
|
|
131
|
-
Enabled: true
|
|
132
|
-
|
|
133
|
-
Layout/SpaceAroundOperators:
|
|
134
|
-
Enabled: true
|
|
135
|
-
Exclude:
|
|
136
|
-
- 'admin/app/controllers/workarea/admin/content_emails_controller.rb'
|
|
137
|
-
- 'admin/app/controllers/workarea/admin/users_controller.rb'
|
|
138
|
-
- 'core/app/helpers/workarea/content_assets_helper.rb'
|
|
139
|
-
- 'core/vendor/active_shipping/lib/active_shipping/carriers/canada_post_pws.rb'
|
|
140
|
-
- 'core/vendor/active_shipping/lib/active_shipping/carriers/fedex.rb'
|
|
141
|
-
- 'core/vendor/active_shipping/lib/active_shipping/carriers/stamps.rb'
|
|
142
|
-
|
|
143
|
-
Layout/SpaceBeforeFirstArg:
|
|
144
|
-
Enabled: true
|
|
145
|
-
|
|
146
|
-
# Defining a method with parameters needs parentheses.
|
|
147
|
-
Style/MethodDefParentheses:
|
|
148
|
-
Enabled: true
|
|
149
|
-
|
|
150
|
-
# Use `foo {}` not `foo{}`.
|
|
151
|
-
Layout/SpaceBeforeBlockBraces:
|
|
152
|
-
Enabled: true
|
|
153
|
-
Exclude:
|
|
154
|
-
- 'admin/app/view_models/workarea/admin/release_calendar_view_model.rb'
|
|
155
|
-
|
|
156
|
-
# Use `foo { bar }` not `foo {bar}`.
|
|
157
|
-
Layout/SpaceInsideBlockBraces:
|
|
158
|
-
Enabled: true
|
|
159
|
-
|
|
160
|
-
# Use `{ a: 1 }` not `{a:1}`.
|
|
161
|
-
Layout/SpaceInsideHashLiteralBraces:
|
|
162
|
-
Enabled: true
|
|
163
|
-
Exclude:
|
|
164
|
-
- 'admin/test/integration/workarea/admin/pricing_sku_prices_integration_test.rb'
|
|
165
|
-
- 'admin/test/integration/workarea/admin/shipping_service_integration_test.rb'
|
|
166
|
-
- 'admin/test/integration/workarea/admin/tax_categories_integration_test.rb'
|
|
167
|
-
- 'admin/test/view_models/workarea/admin/changeset_view_model_test.rb'
|
|
168
|
-
- 'core/app/models/workarea/release/changeset.rb'
|
|
169
|
-
- 'core/app/queries/workarea/search/product_rules.rb'
|
|
170
|
-
- 'core/app/queries/workarea/search/term_filter.rb'
|
|
171
|
-
- 'core/lib/workarea/configuration.rb'
|
|
172
|
-
- 'core/spec/models/workarea/order_spec.rb'
|
|
173
|
-
- 'core/test/models/workarea/application_document_test.rb'
|
|
174
|
-
- 'core/test/models/workarea/fulfillment_test.rb'
|
|
175
|
-
- 'core/test/queries/workarea/search/product_rules_test.rb'
|
|
176
|
-
- 'core/test/workers/workarea/generate_content_metadata_test.rb'
|
|
177
|
-
|
|
178
|
-
Layout/SpaceInsideParens:
|
|
179
|
-
Enabled: true
|
|
180
|
-
Exclude:
|
|
181
|
-
- 'core/app/models/workarea/inventory/collection.rb'
|
|
182
|
-
- 'core/app/models/workarea/pricing/calculators/item_calculator.rb'
|
|
183
|
-
- 'core/spec/models/workarea/order/queries_spec.rb'
|
|
184
|
-
|
|
185
|
-
# Detect hard tabs, no hard tabs.
|
|
186
|
-
Layout/Tab:
|
|
187
|
-
Enabled: true
|
|
188
|
-
Exclude:
|
|
189
|
-
- 'core/vendor/active_shipping/lib/active_shipping/carriers/canada_post.rb'
|
|
190
|
-
|
|
191
|
-
# No trailing whitespace.
|
|
192
|
-
Layout/TrailingWhitespace:
|
|
193
|
-
Enabled: true
|
|
194
|
-
|
|
195
|
-
# Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
|
|
196
|
-
Lint/RequireParentheses:
|
|
197
|
-
Enabled: true
|
|
1
|
+
inherit_from:
|
|
2
|
+
- https://raw.githubusercontent.com/workarea-commerce/workarea/master/.rubocop.yml
|
data/.stylelintrc.json
ADDED
data/CHANGELOG.md
CHANGED
|
@@ -1,41 +1,44 @@
|
|
|
1
|
-
Workarea Gift Cards
|
|
1
|
+
Workarea Gift Cards 4.0.3 (2020-08-19)
|
|
2
2
|
--------------------------------------------------------------------------------
|
|
3
3
|
|
|
4
|
-
* Fix
|
|
4
|
+
* Fix Update Step Result
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* Remove ESLint from Gift Cards build
|
|
6
|
+
Prevent returning `false` early when no Gift Card params are set. This
|
|
7
|
+
ensures the step won't block checkout.
|
|
9
8
|
|
|
10
9
|
Tom Scott
|
|
11
10
|
|
|
12
|
-
*
|
|
11
|
+
* Improve Test Experience For Custom Gift Card Gateways
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
If you're creating a new custom gift card gateway for your project, and
|
|
14
|
+
you want to use the tests from base as a starting point for that
|
|
15
|
+
integration, you currently must duplicate the tests from the plugin in
|
|
16
|
+
your own plugin, which makes things a bit harder but also removes the
|
|
17
|
+
ability to take on updates to the test in case of bug fixes. To improve
|
|
18
|
+
this experience, the `Workarea::GiftCards::GatewayTest` has been
|
|
19
|
+
modified to more easily allow decorating it in a host application. All
|
|
20
|
+
tests are now wrapped in a VCR cassette whose name is defined by the
|
|
21
|
+
parameterized gateway class name and the name of the method being
|
|
22
|
+
tested. This will activate and create cassettes in the real world when a
|
|
23
|
+
gateway makes an outbound HTTP call, similar to
|
|
24
|
+
`CreditCardIntegrationTest`.
|
|
15
25
|
|
|
16
|
-
|
|
26
|
+
GIFTCARDS-9
|
|
17
27
|
|
|
18
28
|
Tom Scott
|
|
19
29
|
|
|
20
|
-
* Use the same env var everywhere
|
|
21
30
|
|
|
22
|
-
Tom Scott
|
|
23
31
|
|
|
24
|
-
|
|
32
|
+
Workarea Gift Cards 4.0.2 (2020-03-03)
|
|
33
|
+
--------------------------------------------------------------------------------
|
|
25
34
|
|
|
26
|
-
|
|
27
|
-
test in base to fail and subsequently block other plugin development
|
|
28
|
-
that depends on this gem. This change is from a later version of
|
|
29
|
-
Workarea, but was not backported to earlier versions. Additionally, this
|
|
30
|
-
commit adds the test workflow and ensures the correct version of
|
|
31
|
-
Workarea is being loaded to ensure accurate testing.
|
|
35
|
+
* Fix misaligned test class name
|
|
32
36
|
|
|
33
|
-
|
|
34
|
-
Tom Scott
|
|
37
|
+
Ben Crouse
|
|
35
38
|
|
|
36
39
|
|
|
37
40
|
|
|
38
|
-
Workarea Gift Cards
|
|
41
|
+
Workarea Gift Cards 4.0.1 (2020-01-21)
|
|
39
42
|
--------------------------------------------------------------------------------
|
|
40
43
|
|
|
41
44
|
* Fix Tests for 2020
|
|
@@ -46,6 +49,23 @@ Workarea Gift Cards 3.4.9 (2020-01-21)
|
|
|
46
49
|
GIFTCARDS-6
|
|
47
50
|
Tom Scott
|
|
48
51
|
|
|
52
|
+
* Fix Tests for 2020
|
|
53
|
+
|
|
54
|
+
Update all tests so that they no longer depend on the year 2020 as an
|
|
55
|
+
expiration year. Instead, use the method provided by Workarea.
|
|
56
|
+
|
|
57
|
+
GIFTCARDS-6
|
|
58
|
+
Tom Scott
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
Workarea Gift Cards 4.0.0 (2019-11-26)
|
|
63
|
+
--------------------------------------------------------------------------------
|
|
64
|
+
|
|
65
|
+
* Use custom fulfillment policy for digital gift card generation
|
|
66
|
+
|
|
67
|
+
Curt Howard
|
|
68
|
+
|
|
49
69
|
|
|
50
70
|
|
|
51
71
|
Workarea Gift Cards 3.4.7 (2019-09-04)
|
data/Gemfile
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
source 'https://rubygems.org'
|
|
2
|
-
git_source(:github) { |repo| "
|
|
2
|
+
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
|
3
3
|
|
|
4
4
|
gemspec
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
gem 'workarea-api', '~> 4.3.0'
|
|
9
|
-
end
|
|
6
|
+
gem 'workarea-api', github: 'workarea-commerce/workarea-api'
|
|
7
|
+
gem 'workarea', github: 'workarea-commerce/workarea', branch: 'v3.5-stable'
|
data/README.md
CHANGED
|
@@ -107,11 +107,35 @@ end
|
|
|
107
107
|
|
|
108
108
|
Note that it is set to a string of the class constant, and not an instance of the class. The system constantizes and initializes a new instance whenever it uses the gateway to ensure autoloading works correctly and so a gateway that cares about the current state of the application is applied correctly. This is most relevant in multi-site environments where each site might want to use their own gift card gateway.
|
|
109
109
|
|
|
110
|
+
### Testing Your Custom Gateway
|
|
111
|
+
|
|
112
|
+
Workarea comes with unit tests for the main Gateway class, and you can
|
|
113
|
+
decorate this test to provide your own setup code. A minimal
|
|
114
|
+
implementation would look as follows:
|
|
115
|
+
|
|
116
|
+
```ruby
|
|
117
|
+
module Workarea
|
|
118
|
+
module GiftCards
|
|
119
|
+
decorate GatewayTest do
|
|
120
|
+
# Provide your own Gateway instance here to use it in each test.
|
|
121
|
+
def gateway
|
|
122
|
+
CustomGiftCardGateway.new
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
# Provide a custom object representing a Gift Card on your
|
|
126
|
+
# 3rd-party service.
|
|
127
|
+
def gift_card
|
|
128
|
+
CustomGiftCard.new(balance: 10.to_m)
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
```
|
|
110
134
|
|
|
111
135
|
Workarea Commerce Documentation
|
|
112
136
|
--------------------------------------------------------------------------------
|
|
113
137
|
|
|
114
|
-
See [https://developer.workarea.com](https://developer.workarea.com) for Workarea Commerce documentation
|
|
138
|
+
See [https://developer.workarea.com](https://developer.workarea.com) for Workarea Commerce documentation
|
|
115
139
|
|
|
116
140
|
License
|
|
117
141
|
--------------------------------------------------------------------------------
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
module Workarea
|
|
2
|
+
if Plugin.installed?(:api)
|
|
3
|
+
module Api
|
|
4
|
+
module Admin
|
|
5
|
+
class GiftCardsController < Admin::ApplicationController
|
|
6
|
+
before_action :find_gift_card, except: [:index, :create, :bulk]
|
|
7
|
+
|
|
8
|
+
swagger_path '/gift_cards' do
|
|
9
|
+
operation :get do
|
|
10
|
+
key :summary, 'All Gift cards'
|
|
11
|
+
key :description, 'Returns all gift cards from the system'
|
|
12
|
+
key :operationId, 'listGiftCards'
|
|
13
|
+
key :produces, ['application/json']
|
|
14
|
+
|
|
15
|
+
parameter do
|
|
16
|
+
key :name, :page
|
|
17
|
+
key :in, :query
|
|
18
|
+
key :description, 'Current page'
|
|
19
|
+
key :required, false
|
|
20
|
+
key :type, :integer
|
|
21
|
+
key :default, 1
|
|
22
|
+
end
|
|
23
|
+
parameter do
|
|
24
|
+
key :name, :sort_by
|
|
25
|
+
key :in, :query
|
|
26
|
+
key :description, 'Field on which to sort (see responses for possible values)'
|
|
27
|
+
key :required, false
|
|
28
|
+
key :type, :string
|
|
29
|
+
key :default, 'created_at'
|
|
30
|
+
end
|
|
31
|
+
parameter do
|
|
32
|
+
key :name, :sort_direction
|
|
33
|
+
key :in, :query
|
|
34
|
+
key :description, 'Direction for sort by'
|
|
35
|
+
key :type, :string
|
|
36
|
+
key :enum, %w(asc desc)
|
|
37
|
+
key :default, 'desc'
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
response 200 do
|
|
41
|
+
key :description, 'Gift cards'
|
|
42
|
+
schema do
|
|
43
|
+
key :type, :object
|
|
44
|
+
property :gift_cards do
|
|
45
|
+
key :type, :array
|
|
46
|
+
items do
|
|
47
|
+
key :'$ref', 'Workarea::Payment::GiftCard'
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
operation :post do
|
|
55
|
+
key :summary, 'Create GiftCard'
|
|
56
|
+
key :description, 'Creates a new gift_card.'
|
|
57
|
+
key :operationId, 'addGiftCard'
|
|
58
|
+
key :produces, ['application/json']
|
|
59
|
+
|
|
60
|
+
parameter do
|
|
61
|
+
key :name, :body
|
|
62
|
+
key :in, :body
|
|
63
|
+
key :description, 'GiftCard to add'
|
|
64
|
+
key :required, true
|
|
65
|
+
schema do
|
|
66
|
+
key :type, :object
|
|
67
|
+
property :gift_card do
|
|
68
|
+
key :'$ref', 'Workarea::Payment::GiftCard'
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
response 201 do
|
|
74
|
+
key :description, 'Gift card created'
|
|
75
|
+
schema do
|
|
76
|
+
key :type, :object
|
|
77
|
+
property :gift_card do
|
|
78
|
+
key :'$ref', 'Workarea::Payment::GiftCard'
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
response 422 do
|
|
84
|
+
key :description, 'Validation failure'
|
|
85
|
+
schema do
|
|
86
|
+
key :type, :object
|
|
87
|
+
property :problem do
|
|
88
|
+
key :type, :string
|
|
89
|
+
end
|
|
90
|
+
property :document do
|
|
91
|
+
key :'$ref', 'Workarea::Payment::GiftCard'
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def index
|
|
99
|
+
@gift_cards = Payment::GiftCard
|
|
100
|
+
.all
|
|
101
|
+
.order_by(sort_field => sort_direction)
|
|
102
|
+
.page(params[:page])
|
|
103
|
+
|
|
104
|
+
respond_with gift_cards: @gift_cards
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def create
|
|
108
|
+
@gift_card = Payment::GiftCard.create!(params[:gift_card])
|
|
109
|
+
respond_with(
|
|
110
|
+
{ gift_card: @gift_card },
|
|
111
|
+
{
|
|
112
|
+
status: :created,
|
|
113
|
+
location: gift_card_path(@gift_card)
|
|
114
|
+
}
|
|
115
|
+
)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
swagger_path '/gift_cards/{id}' do
|
|
119
|
+
operation :get do
|
|
120
|
+
key :summary, 'Find Gift card by ID'
|
|
121
|
+
key :description, 'Returns a single gift card'
|
|
122
|
+
key :operationId, 'showGiftCard'
|
|
123
|
+
|
|
124
|
+
parameter do
|
|
125
|
+
key :name, :id
|
|
126
|
+
key :in, :path
|
|
127
|
+
key :description, 'ID of gift card to fetch'
|
|
128
|
+
key :required, true
|
|
129
|
+
key :type, :string
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
response 200 do
|
|
133
|
+
key :description, 'Gift card details'
|
|
134
|
+
schema do
|
|
135
|
+
key :type, :object
|
|
136
|
+
property :gift_card do
|
|
137
|
+
key :'$ref', 'Workarea::Payment::GiftCard'
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
response 404 do
|
|
143
|
+
key :description, 'Gift card not found'
|
|
144
|
+
schema do
|
|
145
|
+
key :type, :object
|
|
146
|
+
property :problem do
|
|
147
|
+
key :type, :string
|
|
148
|
+
end
|
|
149
|
+
property :params do
|
|
150
|
+
key :type, :object
|
|
151
|
+
key :additionalProperties, true
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
operation :patch do
|
|
158
|
+
key :summary, 'Update a GiftCard'
|
|
159
|
+
key :description, 'Updates attributes on a gift card'
|
|
160
|
+
key :operationId, 'updateGiftCard'
|
|
161
|
+
|
|
162
|
+
parameter do
|
|
163
|
+
key :name, :id
|
|
164
|
+
key :in, :path
|
|
165
|
+
key :description, 'ID of gift card to update'
|
|
166
|
+
key :required, true
|
|
167
|
+
key :type, :string
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
parameter do
|
|
171
|
+
key :name, :body
|
|
172
|
+
key :in, :body
|
|
173
|
+
key :required, true
|
|
174
|
+
schema do
|
|
175
|
+
key :type, :object
|
|
176
|
+
property :gift_card do
|
|
177
|
+
key :description, 'New attributes'
|
|
178
|
+
key :'$ref', 'Workarea::Payment::GiftCard'
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
response 204 do
|
|
184
|
+
key :description, 'Gift card updated successfully'
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
response 422 do
|
|
188
|
+
key :description, 'Validation failure'
|
|
189
|
+
schema do
|
|
190
|
+
key :type, :object
|
|
191
|
+
property :problem do
|
|
192
|
+
key :type, :string
|
|
193
|
+
end
|
|
194
|
+
property :document do
|
|
195
|
+
key :'$ref', 'Workarea::Payment::GiftCard'
|
|
196
|
+
end
|
|
197
|
+
end
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
response 404 do
|
|
201
|
+
key :description, 'Gift card not found'
|
|
202
|
+
schema do
|
|
203
|
+
key :type, :object
|
|
204
|
+
property :problem do
|
|
205
|
+
key :type, :string
|
|
206
|
+
end
|
|
207
|
+
property :params do
|
|
208
|
+
key :type, :object
|
|
209
|
+
key :additionalProperties, true
|
|
210
|
+
end
|
|
211
|
+
end
|
|
212
|
+
end
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
operation :delete do
|
|
216
|
+
key :summary, 'Remove a Gift card'
|
|
217
|
+
key :description, 'Remove a gift card'
|
|
218
|
+
key :operationId, 'removeGiftCard'
|
|
219
|
+
|
|
220
|
+
parameter do
|
|
221
|
+
key :name, :id
|
|
222
|
+
key :in, :path
|
|
223
|
+
key :description, 'ID of gift card to remove'
|
|
224
|
+
key :required, true
|
|
225
|
+
key :type, :string
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
response 204 do
|
|
229
|
+
key :description, 'Gift card removed successfully'
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
response 404 do
|
|
233
|
+
key :description, 'Gift card not found'
|
|
234
|
+
schema do
|
|
235
|
+
key :type, :object
|
|
236
|
+
property :problem do
|
|
237
|
+
key :type, :string
|
|
238
|
+
end
|
|
239
|
+
property :params do
|
|
240
|
+
key :type, :object
|
|
241
|
+
key :additionalProperties, true
|
|
242
|
+
end
|
|
243
|
+
end
|
|
244
|
+
end
|
|
245
|
+
end
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
def show
|
|
249
|
+
respond_with gift_card: @gift_card
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
def update
|
|
253
|
+
@gift_card.update_attributes!(params[:gift_card])
|
|
254
|
+
respond_with gift_card: @gift_card
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
def destroy
|
|
258
|
+
@gift_card.destroy
|
|
259
|
+
head :no_content
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
swagger_path '/gift_cards/bulk' do
|
|
263
|
+
operation :patch do
|
|
264
|
+
key :summary, 'Bulk Upsert Gift cards'
|
|
265
|
+
key :description, 'Creates new gift cards or updates existing ones in bulk.'
|
|
266
|
+
key :operationId, 'upsertGiftCards'
|
|
267
|
+
key :produces, ['application/json']
|
|
268
|
+
|
|
269
|
+
parameter do
|
|
270
|
+
key :name, :body
|
|
271
|
+
key :in, :body
|
|
272
|
+
key :description, 'Array of gift cards to upsert'
|
|
273
|
+
key :required, true
|
|
274
|
+
schema do
|
|
275
|
+
key :type, :object
|
|
276
|
+
property :gift_cards do
|
|
277
|
+
key :type, :array
|
|
278
|
+
items do
|
|
279
|
+
key :'$ref', 'Workarea::Payment::GiftCard'
|
|
280
|
+
end
|
|
281
|
+
end
|
|
282
|
+
end
|
|
283
|
+
end
|
|
284
|
+
|
|
285
|
+
response 204 do
|
|
286
|
+
key :description, 'Upsert received'
|
|
287
|
+
end
|
|
288
|
+
end
|
|
289
|
+
end
|
|
290
|
+
|
|
291
|
+
def bulk
|
|
292
|
+
@bulk = Api::Admin::BulkUpsert.create!(
|
|
293
|
+
klass: Payment::GiftCard,
|
|
294
|
+
data: params[:gift_cards].map(&:to_h)
|
|
295
|
+
)
|
|
296
|
+
|
|
297
|
+
head :no_content
|
|
298
|
+
end
|
|
299
|
+
|
|
300
|
+
private
|
|
301
|
+
|
|
302
|
+
def find_gift_card
|
|
303
|
+
@gift_card = Payment::GiftCard.find(params[:id])
|
|
304
|
+
end
|
|
305
|
+
end
|
|
306
|
+
end
|
|
307
|
+
end
|
|
308
|
+
end
|
|
309
|
+
end
|