workarea-storefront 3.4.45 → 3.5.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +52 -0
- data/app/assets/javascripts/workarea/storefront/application.js.erb +2 -12
- data/app/assets/javascripts/workarea/storefront/config.js.erb +0 -5
- data/app/assets/javascripts/workarea/storefront/modules/{analytics.js → analytics.js.erb} +17 -0
- data/app/assets/javascripts/workarea/storefront/modules/dialog_buttons.js +1 -1
- data/app/assets/javascripts/workarea/storefront/modules/workarea_analytics.js +4 -0
- data/app/assets/stylesheets/workarea/storefront/application.scss.erb +0 -2
- data/app/assets/stylesheets/workarea/storefront/email/_base.scss +9 -1
- data/app/assets/stylesheets/workarea/storefront/email/_components.scss +1 -1
- data/app/assets/stylesheets/workarea/storefront/email/_helpers.scss +16 -0
- data/app/assets/stylesheets/workarea/storefront/email/{_settings.scss → _settings.scss.erb} +1 -1
- data/app/controllers/workarea/storefront/analytics_controller.rb +36 -21
- data/app/controllers/workarea/storefront/application_controller.rb +2 -4
- data/app/controllers/workarea/storefront/cart_items_controller.rb +1 -2
- data/app/controllers/workarea/storefront/checkout/addresses_controller.rb +0 -2
- data/app/controllers/workarea/storefront/checkouts_controller.rb +6 -4
- data/app/controllers/workarea/storefront/content_areas_controller.rb +1 -0
- data/app/controllers/workarea/storefront/content_blocks_controller.rb +1 -0
- data/app/controllers/workarea/storefront/current_checkout.rb +20 -14
- data/app/controllers/workarea/storefront/downloads_controller.rb +18 -0
- data/app/controllers/workarea/storefront/email_signups_controller.rb +1 -0
- data/app/controllers/workarea/storefront/errors_controller.rb +6 -0
- data/app/controllers/workarea/storefront/recent_views_controller.rb +2 -35
- data/app/controllers/workarea/storefront/recommendations_controller.rb +2 -2
- data/app/controllers/workarea/storefront/searches_controller.rb +0 -11
- data/app/controllers/workarea/storefront/users/accounts_controller.rb +2 -7
- data/app/controllers/workarea/storefront/users/credit_cards_controller.rb +5 -2
- data/app/controllers/workarea/storefront/users/passwords_controller.rb +1 -5
- data/app/helpers/workarea/storefront/application_helper.rb +19 -3
- data/app/helpers/workarea/storefront/content_helper.rb +1 -1
- data/app/helpers/workarea/storefront/favicons_helper.rb +6 -7
- data/app/helpers/workarea/storefront/navigation_helper.rb +10 -0
- data/app/helpers/workarea/storefront/schema_org_helper.rb +156 -0
- data/app/mailers/workarea/storefront/application_mailer.rb +1 -0
- data/app/view_models/workarea/storefront/category_view_model.rb +2 -2
- data/app/view_models/workarea/storefront/content_block_view_model.rb +41 -10
- data/app/view_models/workarea/storefront/content_blocks/product_insights_view_model.rb +1 -1
- data/app/view_models/workarea/storefront/display_content.rb +3 -1
- data/app/view_models/workarea/storefront/inquiry_view_model.rb +1 -7
- data/app/view_models/workarea/storefront/inventory_status_view_model.rb +10 -6
- data/app/view_models/workarea/storefront/order_item_view_model.rb +14 -0
- data/app/view_models/workarea/storefront/product_view_model.rb +22 -4
- data/app/view_models/workarea/storefront/recommendations_view_model.rb +8 -4
- data/app/view_models/workarea/storefront/search_view_model.rb +1 -1
- data/app/view_models/workarea/storefront/user_activity_view_model.rb +6 -17
- data/app/views/layouts/workarea/storefront/application.html.haml +13 -17
- data/app/views/layouts/workarea/storefront/checkout.html.haml +1 -1
- data/app/views/layouts/workarea/storefront/content_preview.html.haml +1 -0
- data/app/views/layouts/workarea/storefront/email.html.haml +33 -26
- data/app/views/layouts/workarea/storefront/empty.html.haml +1 -0
- data/app/views/layouts/workarea/storefront/navigation.html.haml +1 -1
- data/app/views/workarea/storefront/account_mailer/creation.html.haml +2 -0
- data/app/views/workarea/storefront/account_mailer/password_reset.html.haml +2 -0
- data/app/views/workarea/storefront/cart_items/create.html.haml +1 -1
- data/app/views/workarea/storefront/carts/show.html.haml +1 -1
- data/app/views/workarea/storefront/categories/show.html.haml +3 -2
- data/app/views/workarea/storefront/checkouts/confirmation.html.haml +1 -1
- data/app/views/workarea/storefront/contacts/show.html.haml +4 -2
- data/app/views/workarea/storefront/content_areas/show.html.haml +1 -0
- data/app/views/workarea/storefront/content_blocks/_category_summary.html.haml +2 -1
- data/app/views/workarea/storefront/content_blocks/_product_insights.html.haml +2 -1
- data/app/views/workarea/storefront/content_blocks/_product_list.html.haml +2 -1
- data/app/views/workarea/storefront/errors/show.html.haml +1 -0
- data/app/views/workarea/storefront/fulfillment_mailer/shipped.html.haml +3 -1
- data/app/views/workarea/storefront/order_mailer/_summary.html.haml +6 -0
- data/app/views/workarea/storefront/order_mailer/confirmation.html.haml +3 -0
- data/app/views/workarea/storefront/order_mailer/reminder.html.haml +3 -0
- data/app/views/workarea/storefront/orders/_summary.html.haml +3 -1
- data/app/views/workarea/storefront/orders/show.html.haml +3 -3
- data/app/views/workarea/storefront/pages/home_page.html.haml +4 -0
- data/app/views/workarea/storefront/pages/robots.text.erb +0 -1
- data/app/views/workarea/storefront/pages/show.html.haml +1 -0
- data/app/views/workarea/storefront/products/_price.html.haml +1 -2
- data/app/views/workarea/storefront/products/_pricing.html.haml +12 -6
- data/app/views/workarea/storefront/products/_summary.html.haml +3 -3
- data/app/views/workarea/storefront/products/show.html.haml +6 -4
- data/app/views/workarea/storefront/products/templates/_generic.html.haml +5 -5
- data/app/views/workarea/storefront/products/templates/_option_selects.html.haml +5 -7
- data/app/views/workarea/storefront/products/templates/_option_thumbnails.html.haml +5 -7
- data/app/views/workarea/storefront/recent_views/aside.html.haml +3 -10
- data/app/views/workarea/storefront/recent_views/narrow.html.haml +3 -10
- data/app/views/workarea/storefront/recent_views/show.html.haml +3 -10
- data/app/views/workarea/storefront/recommendations/show.html.haml +1 -1
- data/app/views/workarea/storefront/searches/show.html.haml +4 -5
- data/app/views/workarea/storefront/users/accounts/edit.html.haml +3 -3
- data/app/views/workarea/storefront/users/accounts/show.html.haml +3 -3
- data/app/views/workarea/storefront/users/addresses/edit.html.haml +3 -3
- data/app/views/workarea/storefront/users/addresses/new.html.haml +3 -3
- data/app/views/workarea/storefront/users/credit_cards/edit.html.haml +3 -3
- data/app/views/workarea/storefront/users/credit_cards/new.html.haml +3 -3
- data/app/views/workarea/storefront/users/orders/index.html.haml +3 -3
- data/app/views/workarea/storefront/users/orders/show.html.haml +4 -4
- data/app/views/workarea/storefront/users/passwords/new.html.haml +3 -3
- data/config/locales/en.yml +16 -3
- data/config/routes.rb +4 -2
- data/test/dummy/config/initializers/session_store.rb +1 -1
- data/test/helpers/workarea/storefront/content_helper_test.rb +1 -0
- data/test/helpers/workarea/storefront/navigation_helper_test.rb +4 -0
- data/test/helpers/workarea/storefront/schema_org_helper_test.rb +27 -0
- data/test/integration/workarea/storefront/analytics_integration_test.rb +44 -4
- data/test/integration/workarea/storefront/cart_items_integration_test.rb +0 -12
- data/test/integration/workarea/storefront/categories_integration_test.rb +0 -10
- data/test/integration/workarea/storefront/checkout_side_effects_integration_test.rb +15 -1
- data/test/integration/workarea/storefront/checkouts_integration_test.rb +68 -11
- data/test/integration/workarea/storefront/contact_form_integration_test.rb +18 -20
- data/test/integration/workarea/storefront/content_blocks_integration_test.rb +1 -4
- data/test/integration/workarea/storefront/current_checkout_integration_test.rb +53 -2
- data/test/integration/workarea/storefront/downloads_integration_test.rb +38 -0
- data/test/integration/workarea/storefront/email_signups_integration_test.rb +2 -0
- data/test/integration/workarea/storefront/guest_browsing_integration_test.rb +2 -2
- data/test/integration/workarea/storefront/impersonations_integration_test.rb +2 -2
- data/test/integration/workarea/storefront/login_integration_test.rb +3 -9
- data/test/integration/workarea/storefront/order_data_integration_test.rb +1 -9
- data/test/integration/workarea/storefront/place_order_integration_test.rb +5 -7
- data/test/integration/workarea/storefront/placing_order_integration_test.rb +1 -1
- data/test/integration/workarea/storefront/recent_views_integration_test.rb +29 -0
- data/test/integration/workarea/storefront/releases_integration_test.rb +132 -0
- data/test/integration/workarea/storefront/search_integration_test.rb +0 -46
- data/test/integration/workarea/storefront/segment_overrides_integration_test.rb +48 -0
- data/test/integration/workarea/storefront/segments_integration_test.rb +250 -0
- data/test/integration/workarea/storefront/store_credit_integration_test.rb +1 -1
- data/test/integration/workarea/storefront/users/credit_cards_integration_test.rb +2 -2
- data/test/integration/workarea/storefront/users/passwords_integration_test.rb +0 -19
- data/test/javascripts/traffic_referrer_spec.js +1 -1
- data/test/mailers/workarea/storefront/transactional_mailer_test.rb +9 -13
- data/test/system/workarea/storefront/analytics_system_test.rb +54 -40
- data/test/system/workarea/storefront/content_system_test.rb +10 -1
- data/test/system/workarea/storefront/digital_products_system_test.rb +2 -0
- data/test/system/workarea/storefront/download_system_test.rb +145 -0
- data/test/system/workarea/storefront/guest_checkout_system_test.rb +20 -0
- data/test/system/workarea/storefront/logged_in_checkout_system_test.rb +31 -32
- data/test/system/workarea/storefront/passwords_system_test.rb +35 -37
- data/test/system/workarea/storefront/pricing_overrides_system_test.rb +13 -2
- data/test/system/workarea/storefront/segment_overrides_system_test.rb +69 -0
- data/test/view_models/workarea/storefront/category_view_model_test.rb +20 -0
- data/test/view_models/workarea/storefront/content_block_view_model_test.rb +135 -3
- data/test/view_models/workarea/storefront/display_content_test.rb +4 -0
- data/test/view_models/workarea/storefront/product_view_model/option_set_test.rb +7 -8
- data/test/view_models/workarea/storefront/product_view_model_test.rb +17 -10
- data/test/view_models/workarea/storefront/search_view_model_test.rb +0 -6
- data/test/view_models/workarea/storefront/user_activity_view_model_test.rb +18 -20
- metadata +20 -22
- data/app/assets/javascripts/workarea/storefront/modules/recent_views.js +0 -25
- data/app/assets/javascripts/workarea/storefront/modules/search_fields.js +0 -59
- data/app/assets/javascripts/workarea/storefront/templates/ui_menu_heading.jst.ejs +0 -1
- data/app/assets/javascripts/workarea/storefront/templates/ui_menu_item.jst.ejs +0 -8
- data/app/assets/stylesheets/jquery_ui/storefront/_ui_autocomplete.scss +0 -17
- data/app/assets/stylesheets/jquery_ui/storefront/_ui_menu.scss +0 -40
- data/app/controllers/workarea/storefront/http_caching.rb +0 -33
- data/app/controllers/workarea/storefront/user_activity.rb +0 -19
- data/app/view_models/workarea/storefront/search_suggestion_view_model.rb +0 -87
- data/app/views/workarea/storefront/searches/index.json.jbuilder +0 -1
- data/app/views/workarea/storefront/style_guides/components/_ui_autocomplete.html.haml +0 -11
- data/test/dummy/tmp/screenshots/.keep +0 -0
- data/test/view_models/workarea/storefront/search_suggestion_view_model_test.rb +0 -42
@@ -47,18 +47,6 @@ module Workarea
|
|
47
47
|
assert_equal(5.to_m, order.items.first.total_price)
|
48
48
|
end
|
49
49
|
|
50
|
-
def test_fail_to_add_an_item
|
51
|
-
post storefront.cart_items_path,
|
52
|
-
params: {
|
53
|
-
product_id: @product.id,
|
54
|
-
sku: 'SKU1',
|
55
|
-
quantity: -1
|
56
|
-
}
|
57
|
-
|
58
|
-
assert_response(:success)
|
59
|
-
assert_empty(Order.all)
|
60
|
-
end
|
61
|
-
|
62
50
|
def test_adding_product_with_shared_skus
|
63
51
|
product_2 = Catalog::Product.create!(name: 'Product', variants: [{ sku: 'SKU1' }])
|
64
52
|
|
@@ -16,16 +16,6 @@ module Workarea
|
|
16
16
|
get storefront.category_path(create_category(active: false))
|
17
17
|
assert(response.ok?)
|
18
18
|
end
|
19
|
-
|
20
|
-
def test_not_accepting_per_page_param
|
21
|
-
products = [create_product, create_product]
|
22
|
-
category = create_category(product_ids: products.map(&:id))
|
23
|
-
|
24
|
-
get storefront.category_path(category, page: 1, per_page: 1)
|
25
|
-
assert(response.ok?)
|
26
|
-
assert_includes(response.body, storefront.product_path(products.first))
|
27
|
-
assert_includes(response.body, storefront.product_path(products.second))
|
28
|
-
end
|
29
19
|
end
|
30
20
|
end
|
31
21
|
end
|
@@ -74,7 +74,7 @@ module Workarea
|
|
74
74
|
assert_equal('Crouse', credit_card.last_name)
|
75
75
|
assert_equal('XXXX-XXXX-XXXX-1', credit_card.display_number)
|
76
76
|
assert_equal(1, credit_card.month)
|
77
|
-
assert_equal(
|
77
|
+
assert_equal(2020, credit_card.year)
|
78
78
|
refute(credit_card.token.blank?)
|
79
79
|
|
80
80
|
complete_checkout('bcrouse@workarea.com', 'W3bl1nc!')
|
@@ -151,6 +151,7 @@ module Workarea
|
|
151
151
|
end
|
152
152
|
|
153
153
|
def test_updating_metrics
|
154
|
+
create_life_cycle_segments
|
154
155
|
create_user(email: 'bcrouse@workarea.com', password: 'W3bl1nc!')
|
155
156
|
create_tax_category(code: '001', rates: [{ percentage: 0.06, country: 'US' }])
|
156
157
|
create_order_total_discount(amount_type: 'percent', amount: 10)
|
@@ -208,6 +209,19 @@ module Workarea
|
|
208
209
|
assert_equal(-1, user.discounts)
|
209
210
|
assert_kind_of(Time, user.first_order_at)
|
210
211
|
assert_kind_of(Time, user.last_order_at)
|
212
|
+
assert_equal(1, user.purchased.product_ids.size)
|
213
|
+
|
214
|
+
segment = Metrics::SegmentByDay.first
|
215
|
+
assert_equal(1, segment.orders)
|
216
|
+
assert_equal(0, segment.returning_orders)
|
217
|
+
assert_equal(1, segment.customers)
|
218
|
+
assert_equal(2, segment.units_sold)
|
219
|
+
assert_equal(2, segment.discounted_units_sold)
|
220
|
+
assert_equal(10, segment.merchandise)
|
221
|
+
assert_equal(-1, segment.discounts)
|
222
|
+
assert_equal(7, segment.shipping)
|
223
|
+
assert_equal(0.96, segment.tax)
|
224
|
+
assert_equal(16.96, segment.revenue)
|
211
225
|
end
|
212
226
|
end
|
213
227
|
end
|
@@ -135,7 +135,6 @@ module Workarea
|
|
135
135
|
phone_number: '2159251800'
|
136
136
|
}
|
137
137
|
}
|
138
|
-
|
139
138
|
get storefront.checkout_shipping_path
|
140
139
|
patch storefront.checkout_shipping_path
|
141
140
|
|
@@ -144,6 +143,8 @@ module Workarea
|
|
144
143
|
assert_equal(1, Order.count)
|
145
144
|
assert_equal('bcrouse@workarea.com', Order.first.email)
|
146
145
|
assert_equal(0, Payment::Profile.count)
|
146
|
+
assert(cookies[:email].present?)
|
147
|
+
original_email_cookie = cookies[:email]
|
147
148
|
|
148
149
|
get storefront.checkout_addresses_path
|
149
150
|
patch storefront.checkout_addresses_path,
|
@@ -181,7 +182,7 @@ module Workarea
|
|
181
182
|
credit_card: {
|
182
183
|
number: '2',
|
183
184
|
month: 1,
|
184
|
-
year:
|
185
|
+
year: 2020,
|
185
186
|
cvv: '999'
|
186
187
|
}
|
187
188
|
}
|
@@ -193,6 +194,8 @@ module Workarea
|
|
193
194
|
assert_equal(1, Payment::Profile.count)
|
194
195
|
assert_equal('bcrouse@weblinc.com', payment_profile.email)
|
195
196
|
assert_includes(payment_profile.reference, order.id)
|
197
|
+
assert(cookies[:email].present?)
|
198
|
+
refute_equal(original_email_cookie, cookies[:email])
|
196
199
|
end
|
197
200
|
|
198
201
|
def test_setting_traffic_referrer
|
@@ -223,21 +226,41 @@ module Workarea
|
|
223
226
|
assert_equal('https://www.workarea.com/', order.traffic_referrer.uri)
|
224
227
|
end
|
225
228
|
|
226
|
-
def
|
229
|
+
def test_saving_segment_ids
|
230
|
+
create_life_cycle_segments
|
227
231
|
product = create_product
|
228
232
|
|
233
|
+
post storefront.cart_items_path,
|
234
|
+
params: { product_id: product.id, sku: product.skus.first }
|
235
|
+
|
236
|
+
get storefront.checkout_addresses_path
|
237
|
+
assert_equal(
|
238
|
+
[Segment::FirstTimeVisitor.instance.id],
|
239
|
+
Order.desc(:updated_at).first.segment_ids
|
240
|
+
)
|
241
|
+
end
|
242
|
+
|
243
|
+
def test_saving_fraud_decision
|
244
|
+
complete_checkout
|
245
|
+
order = Order.desc(:created_at).first
|
246
|
+
|
247
|
+
assert(order.fraud_decision.present?)
|
248
|
+
assert(order.placed?)
|
249
|
+
refute(order.fraud_suspected_at.present?)
|
250
|
+
assert(order.fraud_decided_at.present?)
|
251
|
+
assert_equal(:no_decision, order.fraud_decision.decision)
|
252
|
+
|
229
253
|
post storefront.cart_items_path,
|
230
254
|
params: {
|
231
255
|
product_id: product.id,
|
232
256
|
sku: product.skus.first,
|
233
|
-
quantity:
|
257
|
+
quantity: 1
|
234
258
|
}
|
235
259
|
|
236
260
|
get storefront.checkout_addresses_path
|
237
|
-
|
238
261
|
patch storefront.checkout_addresses_path,
|
239
262
|
params: {
|
240
|
-
email: '
|
263
|
+
email: 'decline@workarea.com',
|
241
264
|
billing_address: {
|
242
265
|
first_name: 'Ben',
|
243
266
|
last_name: 'Crouse',
|
@@ -259,15 +282,39 @@ module Workarea
|
|
259
282
|
phone_number: '2159251800'
|
260
283
|
}
|
261
284
|
}
|
285
|
+
get storefront.checkout_shipping_path
|
286
|
+
patch storefront.checkout_shipping_path
|
262
287
|
|
263
|
-
|
288
|
+
get storefront.checkout_payment_path
|
289
|
+
|
290
|
+
patch storefront.checkout_place_order_path,
|
291
|
+
params: {
|
292
|
+
payment: 'new_card',
|
293
|
+
credit_card: {
|
294
|
+
number: '2',
|
295
|
+
month: 1,
|
296
|
+
year: 2020,
|
297
|
+
cvv: '999'
|
298
|
+
}
|
299
|
+
}
|
300
|
+
|
301
|
+
order = Order.desc(:created_at).first
|
302
|
+
|
303
|
+
assert_equal(:declined, order.fraud_decision.decision)
|
304
|
+
assert(order.fraud_suspected_at.present?)
|
305
|
+
assert(order.fraud_decided_at.present?)
|
306
|
+
refute(order.placed?)
|
264
307
|
end
|
265
308
|
|
266
|
-
def
|
267
|
-
product = create_product
|
309
|
+
def test_no_valid_shipping_options
|
310
|
+
product = create_product
|
268
311
|
|
269
312
|
post storefront.cart_items_path,
|
270
|
-
params: {
|
313
|
+
params: {
|
314
|
+
product_id: product.id,
|
315
|
+
sku: product.skus.first,
|
316
|
+
quantity: 2
|
317
|
+
}
|
271
318
|
|
272
319
|
get storefront.checkout_addresses_path
|
273
320
|
|
@@ -283,10 +330,20 @@ module Workarea
|
|
283
330
|
postal_code: '19106',
|
284
331
|
country: 'US',
|
285
332
|
phone_number: '2159251800'
|
333
|
+
},
|
334
|
+
shipping_address: {
|
335
|
+
first_name: 'Ben',
|
336
|
+
last_name: 'Crouse',
|
337
|
+
street: '22 S. 3rd St.',
|
338
|
+
city: 'Philadelphia',
|
339
|
+
region: 'PA',
|
340
|
+
postal_code: '19106',
|
341
|
+
country: 'US',
|
342
|
+
phone_number: '2159251800'
|
286
343
|
}
|
287
344
|
}
|
288
345
|
|
289
|
-
|
346
|
+
assert(flash[:error].present?)
|
290
347
|
end
|
291
348
|
end
|
292
349
|
end
|
@@ -4,29 +4,27 @@ module Workarea
|
|
4
4
|
module Storefront
|
5
5
|
class ContactFormIntegrationTest < Workarea::IntegrationTest
|
6
6
|
def test_inquiry_creation
|
7
|
-
Workarea.
|
8
|
-
config.email_to = 'test@workarea.com'
|
7
|
+
Workarea.config.email_to = 'test@workarea.com'
|
9
8
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
9
|
+
post storefront.contact_path,
|
10
|
+
params: {
|
11
|
+
name: 'Ben Crouse',
|
12
|
+
email: 'bcrouse@workarea.com',
|
13
|
+
subject: 'orders',
|
14
|
+
order_id: 'ORDER123',
|
15
|
+
message: 'test message'
|
16
|
+
}
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
18
|
+
result = Inquiry.first
|
19
|
+
assert_equal('Ben Crouse', result.name)
|
20
|
+
assert_equal('bcrouse@workarea.com', result.email)
|
21
|
+
assert(result.subject.present?)
|
22
|
+
assert_equal('ORDER123', result.order_id)
|
23
|
+
assert_equal('test message', result.message)
|
25
24
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
end
|
25
|
+
last_email = ActionMailer::Base.deliveries.last
|
26
|
+
assert_includes(last_email.subject, 'Orders')
|
27
|
+
assert_includes(last_email.to, Workarea.config.email_to)
|
30
28
|
end
|
31
29
|
end
|
32
30
|
end
|
@@ -59,10 +59,7 @@ module Workarea
|
|
59
59
|
)
|
60
60
|
content.save!
|
61
61
|
|
62
|
-
draft =
|
63
|
-
block.attributes.merge('content_id' => content.id)
|
64
|
-
)
|
65
|
-
|
62
|
+
draft = block.to_draft.tap(&:save!)
|
66
63
|
get storefront.draft_content_block_path(draft)
|
67
64
|
assert(response.ok?)
|
68
65
|
end
|
@@ -4,26 +4,77 @@ module Workarea
|
|
4
4
|
module Storefront
|
5
5
|
class CurrentCheckoutIntegrationTest < Workarea::IntegrationTest
|
6
6
|
class CurrentCheckoutController < Storefront::ApplicationController
|
7
|
+
before_action :require_login, only: :logged_in
|
8
|
+
|
7
9
|
def test
|
8
10
|
current_order.save if params[:save]
|
9
11
|
head :ok
|
10
12
|
end
|
13
|
+
|
14
|
+
def test_login
|
15
|
+
login(User.find(params[:user_id]))
|
16
|
+
self.current_order = Order.new(id: params[:order_id]) if params[:order_id].present?
|
17
|
+
head :ok
|
18
|
+
end
|
19
|
+
|
20
|
+
def logged_in
|
21
|
+
head :ok
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_logout
|
25
|
+
logout
|
26
|
+
head :ok
|
27
|
+
end
|
11
28
|
end
|
12
29
|
|
13
30
|
setup do
|
14
31
|
Rails.application.routes.prepend do
|
15
32
|
get 'current_checkout_test', to: "#{CurrentCheckoutController.controller_path}#test"
|
33
|
+
get 'current_checkout_test_login', to: "#{CurrentCheckoutController.controller_path}#test_login"
|
34
|
+
get 'current_checkout_test_logout', to: "#{CurrentCheckoutController.controller_path}#test_logout"
|
35
|
+
get 'current_checkout_test_login_required', to: "#{CurrentCheckoutController.controller_path}#logged_in"
|
16
36
|
end
|
17
37
|
|
18
38
|
Rails.application.reload_routes!
|
39
|
+
|
40
|
+
@user = create_user
|
19
41
|
end
|
20
42
|
|
21
43
|
def test_current_order
|
22
44
|
get '/current_checkout_test'
|
23
|
-
assert(
|
45
|
+
assert(cookies[:order_id].blank?)
|
46
|
+
|
47
|
+
get '/current_checkout_test', params: { save: true }
|
48
|
+
assert(cookies[:order_id].present?)
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_clearing_current_order
|
52
|
+
get '/current_checkout_test_login', params: { user_id: @user.id, order_id: 'foo' }
|
53
|
+
assert(cookies[:order_id].present?)
|
24
54
|
|
55
|
+
get '/current_checkout_test_logout'
|
56
|
+
assert(cookies[:order_id].blank?)
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_require_login_does_not_clear_current_order
|
25
60
|
get '/current_checkout_test', params: { save: true }
|
26
|
-
assert(
|
61
|
+
assert(cookies[:order_id].present?)
|
62
|
+
|
63
|
+
assert_no_changes 'cookies[:order_id]' do
|
64
|
+
get '/current_checkout_test_login_required'
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_ip_address_changing_clears_current_order
|
69
|
+
get '/current_checkout_test_login', params: { user_id: @user.id, order_id: 'foo' }
|
70
|
+
|
71
|
+
get '/current_checkout_test_login_required'
|
72
|
+
assert(cookies[:order_id].present?)
|
73
|
+
|
74
|
+
@user.update!(ip_address: '192.168.0.1')
|
75
|
+
|
76
|
+
get '/current_checkout_test_login_required'
|
77
|
+
assert(cookies[:order_id].blank?)
|
27
78
|
end
|
28
79
|
end
|
29
80
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Workarea
|
4
|
+
module Storefront
|
5
|
+
class DownloadsIntegrationTest < Workarea::IntegrationTest
|
6
|
+
def test_show
|
7
|
+
token = create_fulfillment_token(sku: 'SKU1')
|
8
|
+
sku = create_fulfillment_sku(id: 'SKU1', policy: :download, file: product_image_file)
|
9
|
+
|
10
|
+
get storefront.download_path(token)
|
11
|
+
assert(response.ok?)
|
12
|
+
assert_equal(1, token.reload.downloads)
|
13
|
+
|
14
|
+
token.update!(enabled: false)
|
15
|
+
|
16
|
+
get storefront.download_path(token)
|
17
|
+
assert_redirected_to(storefront.root_path)
|
18
|
+
assert(flash[:info].present?)
|
19
|
+
assert_equal(1, token.reload.downloads)
|
20
|
+
|
21
|
+
token.update!(enabled: true)
|
22
|
+
sku.update!(policy: 'ignore')
|
23
|
+
|
24
|
+
get storefront.download_path(token)
|
25
|
+
assert_redirected_to(storefront.root_path)
|
26
|
+
assert(flash[:info].present?)
|
27
|
+
assert_equal(1, token.reload.downloads)
|
28
|
+
|
29
|
+
sku.destroy!
|
30
|
+
|
31
|
+
get storefront.download_path(token)
|
32
|
+
assert_redirected_to(storefront.root_path)
|
33
|
+
assert(flash[:info].present?)
|
34
|
+
assert_equal(1, token.reload.downloads)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -8,6 +8,7 @@ module Workarea
|
|
8
8
|
params: { email: 'bcrouse@workarea.com' }
|
9
9
|
|
10
10
|
assert_redirected_to(storefront.root_path)
|
11
|
+
assert(cookies[:email].present?)
|
11
12
|
assert(flash[:success].present?)
|
12
13
|
assert_equal(1, Email::Signup.where(email: 'bcrouse@workarea.com').count)
|
13
14
|
end
|
@@ -17,6 +18,7 @@ module Workarea
|
|
17
18
|
params: { email: 'bcrouse@workarea' }
|
18
19
|
|
19
20
|
assert_redirected_to(storefront.root_path)
|
21
|
+
assert(cookies[:email].blank?)
|
20
22
|
assert(flash[:error].present?)
|
21
23
|
assert_equal(0, Email::Signup.count)
|
22
24
|
end
|
@@ -16,8 +16,8 @@ module Workarea
|
|
16
16
|
complete_checkout
|
17
17
|
order = Order.placed.first
|
18
18
|
assert_nil(order.user_id)
|
19
|
-
|
20
|
-
|
19
|
+
assert_equal('admin', order.source)
|
20
|
+
assert_equal(order.checkout_by_id, admin_user.id.to_s)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -69,7 +69,7 @@ module Workarea
|
|
69
69
|
credit_card: {
|
70
70
|
number: '1',
|
71
71
|
month: 1,
|
72
|
-
year:
|
72
|
+
year: 2020,
|
73
73
|
cvv: '999'
|
74
74
|
}
|
75
75
|
}
|
@@ -101,7 +101,7 @@ module Workarea
|
|
101
101
|
}
|
102
102
|
|
103
103
|
# simulate expiration of admin session.
|
104
|
-
|
104
|
+
reset!
|
105
105
|
|
106
106
|
# Cart should be empty now that admin is logged out
|
107
107
|
get storefront.checkout_path
|