workarea-gift_cards 3.4.11 → 4.0.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/{.eslintrc → .eslintrc.json} +12 -1
  3. data/.github/workflows/ci.yml +10 -8
  4. data/.rubocop.yml +2 -197
  5. data/.stylelintrc.json +8 -0
  6. data/CHANGELOG.md +0 -71
  7. data/Gemfile +3 -5
  8. data/Rakefile +5 -4
  9. data/app/controllers/workarea/api/admin/gift_cards_controller.rb +309 -0
  10. data/app/controllers/workarea/api/storefront/checkouts_controller.decorator +6 -0
  11. data/app/controllers/workarea/api/storefront/gift_cards_controller.rb +2 -8
  12. data/app/controllers/workarea/storefront/checkout/gift_cards_controller.rb +32 -0
  13. data/app/controllers/workarea/storefront/gift_cards_controller.rb +15 -16
  14. data/app/models/workarea/checkout/steps/gift_card.rb +71 -0
  15. data/app/models/workarea/fulfillment/policies/create_gift_card.rb +30 -0
  16. data/app/models/workarea/payment/authorize/gift_card.rb +7 -20
  17. data/app/models/workarea/payment/capture/gift_card.rb +5 -7
  18. data/app/models/workarea/payment/gift_card.rb +1 -1
  19. data/app/models/workarea/payment/gift_card_operation.rb +9 -0
  20. data/app/models/workarea/payment/purchase/gift_card.rb +24 -1
  21. data/app/models/workarea/payment/refund/gift_card.rb +9 -14
  22. data/app/models/workarea/payment/tender/gift_card.rb +3 -10
  23. data/app/models/workarea/payment.decorator +25 -7
  24. data/app/models/workarea/search/admin/order.decorator +2 -4
  25. data/app/seeds/workarea/gift_card_seeds.rb +7 -7
  26. data/app/view_models/workarea/storefront/gift_card_order_pricing.rb +19 -20
  27. data/app/view_models/workarea/storefront/order_view_model.decorator +2 -22
  28. data/app/views/workarea/admin/payment_gift_cards/_menu.html.haml +2 -1
  29. data/app/views/workarea/storefront/checkouts/_gift_card_error.html.haml +8 -6
  30. data/app/views/workarea/storefront/checkouts/_gift_card_payment.html.haml +20 -12
  31. data/app/views/workarea/storefront/gift_card_mailer/created.html.haml +1 -1
  32. data/app/views/workarea/storefront/order_mailer/_gift_card_summary.html.haml +6 -5
  33. data/app/views/workarea/storefront/orders/_gift_card_summary.html.haml +2 -2
  34. data/app/views/workarea/storefront/products/templates/_gift_card.html.haml +5 -5
  35. data/app/workers/workarea/log_gift_card_redemption.rb +16 -9
  36. data/config/initializers/configuration.rb +7 -4
  37. data/config/initializers/fields.rb +14 -0
  38. data/config/locales/en.yml +14 -4
  39. data/config/routes.rb +9 -2
  40. data/lib/workarea/gift_cards/gateway.rb +128 -0
  41. data/lib/workarea/gift_cards/version.rb +1 -1
  42. data/lib/workarea/gift_cards.rb +9 -0
  43. data/test/documentation/workarea/api/admin/gift_cards_documentation_test.rb +24 -10
  44. data/test/documentation/workarea/api/storefront/gift_cards_documentation_test.rb +57 -50
  45. data/test/dummy/config/initializers/session_store.rb +1 -1
  46. data/test/integration/workarea/api/admin/gift_card_integration_test.rb +13 -5
  47. data/test/integration/workarea/api/storefront/checkout_gift_cards_integration_test.rb +120 -0
  48. data/test/integration/workarea/api/storefront/{balance_integration_test.rb → gift_cards_integration_test.rb} +1 -1
  49. data/test/integration/workarea/storefront/checkout_gift_cards_integration_test.rb +116 -0
  50. data/test/integration/workarea/storefront/gift_cards_integration_test.rb +48 -0
  51. data/test/integration/workarea/storefront/purchase_gift_cards_integration_test.rb +55 -0
  52. data/test/lib/workarea/gift_cards/gateway_test.rb +97 -0
  53. data/test/models/workarea/checkout/steps/gift_card_test.rb +104 -0
  54. data/test/models/workarea/fulfillment/policies/create_gift_card_test.rb +47 -0
  55. data/test/models/workarea/gift_card_payment_test.rb +15 -3
  56. data/test/models/workarea/payment/purchase/gift_card_test.rb +11 -8
  57. data/test/queries/workarea/admin_redemptions_export_test.rb +31 -35
  58. data/test/system/workarea/storefront/gift_cards_system_test.rb +8 -2
  59. data/test/view_models/workarea/storefront/gift_card_order_pricing_test.rb +113 -0
  60. data/test/workers/workarea/log_gift_card_redemption_test.rb +1 -1
  61. data/workarea-gift_cards.gemspec +4 -4
  62. metadata +26 -30
  63. data/.eslintignore +0 -2
  64. data/.scss-lint.yml +0 -188
  65. data/app/controllers/workarea/api/admin/payment_gift_cards_controller.rb +0 -49
  66. data/app/controllers/workarea/storefront/checkouts_controller.decorator +0 -24
  67. data/app/services/workarea/checkout/steps/gift_card.rb +0 -49
  68. data/app/view_models/workarea/storefront/checkout/payment_view_model.decorator +0 -32
  69. data/app/view_models/workarea/storefront/checkout/summary_view_model.decorator +0 -11
  70. data/app/workers/workarea/create_ordered_gift_cards.rb +0 -47
  71. data/config/initializers/jump_to_navigation.rb +0 -3
  72. data/test/integration/workarea/api/storefront/checkout_integration_test.rb +0 -161
  73. data/test/integration/workarea/storefront/gift_card_integration_test.rb +0 -226
  74. data/test/services/workarea/checkout/steps/gift_card_test.rb +0 -87
  75. data/test/view_models/workarea/storefront/checkout/gift_card_payment_view_model_test.rb +0 -65
  76. data/test/workers/workarea/create_ordered_gift_cards_test.rb +0 -39
@@ -1,161 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Workarea
4
- if Plugin.installed?(:api)
5
- module Api
6
- module Storefront
7
- class CheckoutIntegrationTest < Workarea::IntegrationTest
8
- setup :tax, :product, :shipping_service, :gift_card
9
-
10
- def tax
11
- @tax ||= create_tax_category(
12
- name: 'Sales Tax',
13
- code: '001',
14
- rates: [{ percentage: 0.07, country: 'US', region: 'PA' }]
15
- )
16
- end
17
-
18
- def product
19
- @product ||= create_product(
20
- name: 'Integration Product',
21
- variants: [
22
- { sku: 'SKU1',
23
- regular: 6.to_m,
24
- tax_code: '001',
25
- on_sale: true,
26
- sale: 5.to_m }
27
- ]
28
- )
29
- end
30
-
31
- def shipping_service
32
- @shipping_service ||= create_shipping_service(
33
- name: 'Ground',
34
- tax_code: '001',
35
- rates: [{ price: 7.to_m }]
36
- )
37
- end
38
-
39
- def gift_card
40
- @gift_card ||= create_gift_card(amount: 5.to_m)
41
- end
42
-
43
- def complete_checkout
44
- post storefront_api.carts_path
45
- order_id = JSON.parse(response.body)['id']
46
-
47
- post storefront_api.cart_items_path(order_id),
48
- params: {
49
- product_id: product.id,
50
- sku: product.skus.first,
51
- quantity: 2
52
- }
53
-
54
- patch storefront_api.checkout_path(order_id),
55
- params: {
56
- email: 'bcrouse@workarea.com',
57
- billing_address: {
58
- first_name: 'Ben',
59
- last_name: 'Crouse',
60
- street: '12 N. 3rd St.',
61
- city: 'Philadelphia',
62
- region: 'PA',
63
- postal_code: '19106',
64
- country: 'US',
65
- phone_number: '2159251800'
66
- },
67
- shipping_address: {
68
- first_name: 'Ben',
69
- last_name: 'Crouse',
70
- street: '22 S. 3rd St.',
71
- city: 'Philadelphia',
72
- region: 'PA',
73
- postal_code: '19106',
74
- country: 'US',
75
- phone_number: '2159251800'
76
- }
77
- }
78
-
79
- patch storefront_api.add_gift_card_checkout_path(order_id),
80
- params: { gift_card_number: gift_card.token }
81
-
82
- post storefront_api.complete_checkout_path(order_id),
83
- params: {
84
- payment: 'new_card',
85
- credit_card: {
86
- number: '1',
87
- month: '1',
88
- year: Time.now.year + 1,
89
- cvv: '999'
90
- }
91
- }
92
- end
93
-
94
- def test_saves_order_info
95
- complete_checkout
96
-
97
- order = Order.first
98
-
99
- assert_equal('bcrouse@workarea.com', order.email)
100
- assert(order.placed_at.present?)
101
- assert_equal(1, order.items.length)
102
-
103
- assert_equal(product.id, order.items.first.product_id)
104
- assert_equal(product.skus.first, order.items.first.sku)
105
- assert_equal(2, order.items.first.quantity)
106
-
107
- assert_equal(10.to_m, order.items.first.total_price)
108
- assert_equal(1, order.items.first.price_adjustments.length)
109
- assert_equal(10.to_m, order.items.first.price_adjustments.first.amount)
110
-
111
- assert(order.items.first.on_sale?)
112
- assert(order.items.first.product_attributes.present?)
113
-
114
- payment = Payment.find(order.id)
115
- assert_equal('Ben', payment.first_name)
116
- assert_equal('Crouse', payment.last_name)
117
- assert_equal('Ben', payment.address.first_name)
118
- assert_equal('Crouse', payment.address.last_name)
119
- assert_equal('12 N. 3rd St.', payment.address.street)
120
- assert_equal('Philadelphia', payment.address.city)
121
- assert_equal('PA', payment.address.region)
122
- assert_equal('19106', payment.address.postal_code)
123
- assert_equal('US', payment.address.country.alpha2)
124
- assert_equal('2159251800', payment.address.phone_number)
125
-
126
- assert_equal('Test Card', payment.credit_card.issuer)
127
- assert_equal('XXXX-XXXX-XXXX-1', payment.credit_card.display_number)
128
- assert_equal(1, payment.credit_card.month)
129
- assert(payment.credit_card.year.present?)
130
- assert_equal(13.19.to_m, payment.credit_card.amount)
131
- assert(payment.credit_card.token.present?)
132
- assert(payment.credit_card.saved_card_id.blank?)
133
-
134
- assert_equal(1, payment.credit_card.transactions.length)
135
- assert(payment.credit_card.transactions.first.response.present?)
136
- assert_equal(13.19.to_m, payment.credit_card.transactions.first.amount)
137
-
138
- assert_equal(gift_card.token, payment.gift_card.number)
139
- assert_equal(5.to_m, payment.gift_card.amount)
140
- assert_equal(1, payment.gift_card.transactions.length)
141
- assert_equal(5.to_m, payment.gift_card.transactions.first.amount)
142
- end
143
-
144
- def test_reduces_balance_on_gift_card
145
- complete_checkout
146
-
147
- gift_card.reload
148
- assert_equal(0.to_m, gift_card.balance)
149
- assert_equal(5.to_m, gift_card.amount)
150
- assert_equal(5.to_m, gift_card.used)
151
-
152
- order = Order.first
153
- redemption = gift_card.redemptions.first
154
- assert_equal(order.placed_at, redemption.redeemed_at)
155
- assert_equal(5.to_m, redemption.amount)
156
- end
157
- end
158
- end
159
- end
160
- end
161
- end
@@ -1,226 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Workarea
4
- module Storefront
5
- class GiftCardIntegrationTest < Workarea::IntegrationTest
6
- setup :tax, :product, :shipping_service, :gift_card
7
-
8
- def next_year
9
- 1.year.from_now.year
10
- end
11
-
12
- def tax
13
- @tax ||= create_tax_category(
14
- name: 'Sales Tax',
15
- code: '001',
16
- rates: [{ percentage: 0.07, country: 'US', region: 'PA' }]
17
- )
18
- end
19
-
20
- def product
21
- @product ||= create_product(
22
- name: 'Integration Product',
23
- variants: [
24
- { sku: 'SKU1',
25
- regular: 6.to_m,
26
- tax_code: '001',
27
- on_sale: true,
28
- sale: 5.to_m }
29
- ]
30
- )
31
- end
32
-
33
- def shipping_service
34
- @shipping_service ||= create_shipping_service(
35
- name: 'Ground',
36
- tax_code: '001',
37
- rates: [{ price: 7.to_m }]
38
- )
39
- end
40
-
41
- def gift_card
42
- @gift_card ||= create_gift_card(amount: 5.to_m)
43
- end
44
-
45
- def complete_checkout
46
- post storefront.cart_items_path,
47
- params: {
48
- product_id: product.id,
49
- sku: product.skus.first,
50
- quantity: 2
51
- }
52
-
53
- patch storefront.checkout_addresses_path,
54
- params: {
55
- email: 'bcrouse@workarea.com',
56
- billing_address: {
57
- first_name: 'Ben',
58
- last_name: 'Crouse',
59
- street: '12 N. 3rd St.',
60
- city: 'Philadelphia',
61
- region: 'PA',
62
- postal_code: '19106',
63
- country: 'US',
64
- phone_number: '2159251800'
65
- },
66
- shipping_address: {
67
- first_name: 'Ben',
68
- last_name: 'Crouse',
69
- street: '22 S. 3rd St.',
70
- city: 'Philadelphia',
71
- region: 'PA',
72
- postal_code: '19106',
73
- country: 'US',
74
- phone_number: '2159251800'
75
- }
76
- }
77
-
78
- patch storefront.checkout_add_gift_card_path,
79
- params: { gift_card_number: gift_card.token }
80
-
81
- patch storefront.checkout_place_order_path,
82
- params: {
83
- payment: 'new_card',
84
- credit_card: {
85
- number: '1',
86
- month: 1,
87
- year: next_year,
88
- cvv: '999'
89
- }
90
- }
91
- end
92
-
93
- def test_saves_order_info
94
- complete_checkout
95
-
96
- order = Order.first
97
-
98
- assert_equal('bcrouse@workarea.com', order.email)
99
- assert(order.placed_at.present?)
100
- assert_equal(1, order.items.length)
101
-
102
- assert_equal(product.id, order.items.first.product_id)
103
- assert_equal(product.skus.first, order.items.first.sku)
104
- assert_equal(2, order.items.first.quantity)
105
-
106
- assert_equal(10.to_m, order.items.first.total_price)
107
- assert_equal(1, order.items.first.price_adjustments.length)
108
- assert_equal(10.to_m, order.items.first.price_adjustments.first.amount)
109
-
110
- assert(order.items.first.on_sale?)
111
- assert(order.items.first.product_attributes.present?)
112
-
113
- payment = Payment.find(order.id)
114
- assert_equal('Ben', payment.first_name)
115
- assert_equal('Crouse', payment.last_name)
116
- assert_equal('Ben', payment.address.first_name)
117
- assert_equal('Crouse', payment.address.last_name)
118
- assert_equal('12 N. 3rd St.', payment.address.street)
119
- assert_equal('Philadelphia', payment.address.city)
120
- assert_equal('PA', payment.address.region)
121
- assert_equal('19106', payment.address.postal_code)
122
- assert_equal('US', payment.address.country.alpha2)
123
- assert_equal('2159251800', payment.address.phone_number)
124
-
125
- assert_equal('Test Card', payment.credit_card.issuer)
126
- assert_equal('XXXX-XXXX-XXXX-1', payment.credit_card.display_number)
127
- assert_equal(1, payment.credit_card.month)
128
- assert_equal(next_year, payment.credit_card.year)
129
- assert_equal(13.19.to_m, payment.credit_card.amount)
130
- assert(payment.credit_card.token.present?)
131
- assert(payment.credit_card.saved_card_id.blank?)
132
-
133
- assert_equal(1, payment.credit_card.transactions.length)
134
- assert(payment.credit_card.transactions.first.response.present?)
135
- assert_equal(13.19.to_m, payment.credit_card.transactions.first.amount)
136
-
137
- assert_equal(gift_card.token, payment.gift_card.number)
138
- assert_equal(5.to_m, payment.gift_card.amount)
139
- assert_equal(1, payment.gift_card.transactions.length)
140
- assert_equal(5.to_m, payment.gift_card.transactions.first.amount)
141
- end
142
-
143
- def test_reduces_balance_on_gift_card
144
- complete_checkout
145
-
146
- gift_card.reload
147
- assert_equal(0.to_m, gift_card.balance)
148
- assert_equal(5.to_m, gift_card.amount)
149
- assert_equal(5.to_m, gift_card.used)
150
-
151
- order = Order.first
152
- redemption = gift_card.redemptions.first
153
- assert_equal(order.placed_at, redemption.redeemed_at)
154
- assert_equal(5.to_m, redemption.amount)
155
- end
156
-
157
- def test_generates_gift_card
158
- product = create_product(
159
- name: 'Gift Card',
160
- gift_card: true,
161
- digital: true,
162
- customizations: 'gift_card',
163
- variants: [{ sku: 'GIFTCARD', regular: 10.to_m }]
164
- )
165
-
166
- post storefront.cart_items_path,
167
- params: {
168
- product_id: product.id,
169
- sku: product.skus.first,
170
- email: 'recipient@workarea.com',
171
- from: 'from@workarea.com',
172
- message: 'this is a message',
173
- quantity: 1
174
- }
175
-
176
- patch storefront.checkout_addresses_path,
177
- params: {
178
- email: 'bcrouse@workarea.com',
179
- billing_address: {
180
- first_name: 'Ben',
181
- last_name: 'Crouse',
182
- street: '12 N. 3rd St.',
183
- city: 'Philadelphia',
184
- region: 'PA',
185
- postal_code: '19106',
186
- country: 'US',
187
- phone_number: '2159251800'
188
- }
189
- }
190
-
191
- patch storefront.checkout_place_order_path,
192
- params: {
193
- payment: 'new_card',
194
- credit_card: {
195
- number: '1',
196
- month: 1,
197
- year: next_year,
198
- cvv: '999'
199
- }
200
- }
201
-
202
- assert_equal(2, Payment::GiftCard.count)
203
-
204
- card = Payment::GiftCard.desc(:created_at).first
205
- assert_equal(10.to_m, card.amount)
206
- assert_equal(0.to_m, card.used)
207
- assert_equal(10.to_m, card.balance)
208
- assert(card.order_id.present?)
209
-
210
- assert_equal(2, ActionMailer::Base.deliveries.length)
211
-
212
- assert(card.purchased?)
213
-
214
- gift_card_email = ActionMailer::Base.deliveries.detect do |email|
215
- assert_includes(email.to, 'recipient@workarea.com')
216
- end
217
-
218
- gift_card_email.parts.each do |part|
219
- assert_includes(part.body, card.token)
220
- assert_includes(part.body, 'from@workarea.com')
221
- assert_includes(part.body, 'this is a message')
222
- end
223
- end
224
- end
225
- end
226
- end
@@ -1,87 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Workarea
4
- class Checkout
5
- module Steps
6
- class GiftCardTest < TestCase
7
- def user
8
- @user ||= create_user
9
- end
10
-
11
- def order
12
- @order ||= create_order
13
- end
14
-
15
- def checkout
16
- @checkout ||= Checkout.new(order, user)
17
- end
18
-
19
- def payment
20
- @payment ||= checkout.payment.tap(&:save!)
21
- end
22
-
23
- def step
24
- @step ||= Checkout::Steps::GiftCard.new(checkout)
25
- end
26
-
27
- def card
28
- @card ||= create_gift_card
29
- end
30
-
31
- def test_user
32
- assert_equal(user, step.user)
33
- end
34
-
35
- def test_update
36
- product = create_product
37
- create_shipping_sku(id: product.skus.first)
38
- shipping = create_shipping(order_id: order.id)
39
- shipping.set_shipping_service(
40
- id: 'GROUND',
41
- name: 'Ground',
42
- tax_code: '001',
43
- base_price: 1.to_m
44
- )
45
- shipping.set_address(
46
- first_name: 'Ben',
47
- last_name: 'Crouse',
48
- street: '22 S. 3rd St.',
49
- street_2: 'Second Floor',
50
- city: 'Philadelphia',
51
- region: 'PA',
52
- postal_code: '19106',
53
- country: 'US',
54
- phone_number: '2159251800'
55
- )
56
- order.add_item(
57
- product_id: product.id,
58
- sku: product.skus.first,
59
- quantity: 1
60
- )
61
- params = { gift_card_number: " #{card.number} " }
62
-
63
- refute_empty(order.items)
64
- assert(payment.set_gift_card(number: card.number))
65
- assert(step.update(params))
66
-
67
- assert_equal(1.to_m, order.shipping_total)
68
- assert_equal(5.to_m, order.subtotal_price)
69
- assert_equal(6.to_m, payment.gift_card.amount)
70
- end
71
-
72
- def test_complete?
73
- assert(step.complete?)
74
-
75
- payment.set_gift_card(number: card.number)
76
- assert(step.complete?)
77
-
78
- payment.set_gift_card(number: '')
79
- refute(step.complete?)
80
-
81
- payment.set_gift_card(number: '1234')
82
- refute(step.complete?)
83
- end
84
- end
85
- end
86
- end
87
- end
@@ -1,65 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Workarea
4
- module Storefront
5
- module Checkout
6
- class GiftCardPaymentViewModelTest < TestCase
7
- def test_order_covered_by_gift_card_when_amounts_match
8
- product = create_product
9
- order = create_order
10
- order.add_item(sku: product.skus.first, quantity: 1, product_id: product.id)
11
- Pricing.perform(order)
12
- order.reload
13
- gift_card = create_gift_card(amount: order.total_price, token: 'foo')
14
- payment = create_payment(id: order.id)
15
- payment.set_gift_card(number: gift_card.token)
16
- checkout = Workarea::Checkout.new(order)
17
- step = Workarea::Checkout::Steps::Payment.new(checkout)
18
- step.update(gift_card: { number: gift_card.token })
19
- view_model = Storefront::Checkout::PaymentViewModel.new(step)
20
-
21
- assert(view_model.show_gift_card?)
22
- assert(view_model.order_covered_by_gift_card?)
23
- end
24
-
25
- def test_order_covered_by_gift_card_when_balance_exceeds_total
26
- product = create_product
27
- order = create_order
28
- order.add_item(sku: product.skus.first, quantity: 1, product_id: product.id)
29
- Pricing.perform(order)
30
- order.reload
31
- gift_card = create_gift_card(amount: order.total_price + 1.to_m, token: 'foo')
32
- payment = create_payment(id: order.id)
33
- payment.set_gift_card(number: gift_card.token)
34
- checkout = Workarea::Checkout.new(order)
35
- step = Workarea::Checkout::Steps::Payment.new(checkout)
36
- step.update(gift_card: { number: gift_card.token })
37
- view_model = Storefront::Checkout::PaymentViewModel.new(step)
38
-
39
- assert(view_model.show_gift_card?)
40
- assert(view_model.order_covered_by_gift_card?)
41
- end
42
-
43
- def test_order_not_covered_by_gift_card_when_total_exceeds_balance
44
- product = create_product
45
- order = create_order
46
- order.add_item(sku: product.skus.first, quantity: 1, product_id: product.id)
47
- Pricing.perform(order)
48
- order.reload
49
- gift_card = create_gift_card(amount: 1.to_m, token: 'foo')
50
- payment = create_payment(id: order.id)
51
- payment.set_gift_card(number: gift_card.token)
52
- checkout = Workarea::Checkout.new(order)
53
- step = Workarea::Checkout::Steps::Payment.new(checkout)
54
- step.update(gift_card: { number: gift_card.token })
55
- view_model = Storefront::Checkout::PaymentViewModel.new(step)
56
-
57
- assert(view_model.show_gift_card?)
58
- assert_equal(5.to_m, order.total_price)
59
- assert_equal(1.to_m, view_model.gift_card_balance)
60
- refute(view_model.order_covered_by_gift_card?)
61
- end
62
- end
63
- end
64
- end
65
- end
@@ -1,39 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Workarea
4
- class CreateOrderedGiftCardsTest < TestCase
5
- def test_perform
6
- order = create_order(id: 123)
7
- order.add_item(
8
- product_id: 'PROD',
9
- sku: 'SKU',
10
- product_attributes: { digital: true },
11
- gift_card: true,
12
- customizations: {
13
- 'email' => 'bob@workarea.com',
14
- 'from' => 'system@workarea.com',
15
- 'message' => 'Hello'
16
- },
17
- price_adjustments: [
18
- {
19
- amount: 10.to_m
20
- }
21
- ]
22
- )
23
-
24
- CreateFulfillment.new(order).perform
25
- CreateOrderedGiftCards.new.perform('123')
26
- card = Payment::GiftCard.first
27
- assert(card.present?)
28
- assert(card.notify)
29
- assert(card.purchased)
30
- assert_equal('bob@workarea.com', card.to)
31
- assert_equal('system@workarea.com', card.from)
32
- assert_equal('Hello', card.message)
33
- assert_equal(order.id, card.order_id)
34
-
35
- fulfillment = Fulfillment.find(order.id)
36
- assert_equal(1, fulfillment.items.first.quantity_shipped)
37
- end
38
- end
39
- end