workarea-api 4.4.7 → 4.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (311) hide show
  1. checksums.yaml +4 -4
  2. data/.eslintrc.json +35 -0
  3. data/.github/workflows/ci.yml +35 -0
  4. data/.gitignore +1 -0
  5. data/.rubocop.yml +2 -0
  6. data/.stylelintrc.json +8 -0
  7. data/CHANGELOG.md +15 -11
  8. data/Gemfile +3 -2
  9. data/README.md +13 -0
  10. data/Rakefile +14 -5
  11. data/admin/app/controllers/workarea/api/admin/categories_controller.rb +6 -0
  12. data/admin/app/controllers/workarea/api/admin/content_assets_controller.rb +6 -0
  13. data/admin/app/controllers/workarea/api/admin/content_controller.rb +6 -0
  14. data/admin/app/controllers/workarea/api/admin/discounts_controller.rb +7 -0
  15. data/admin/app/controllers/workarea/api/admin/email_signups_controller.rb +20 -4
  16. data/admin/app/controllers/workarea/api/admin/fulfillments_controller.rb +6 -1
  17. data/admin/app/controllers/workarea/api/admin/inventory_skus_controller.rb +7 -0
  18. data/admin/app/controllers/workarea/api/admin/navigation_menus_controller.rb +7 -0
  19. data/admin/app/controllers/workarea/api/admin/navigation_taxons_controller.rb +7 -0
  20. data/admin/app/controllers/workarea/api/admin/orders_controller.rb +19 -1
  21. data/admin/app/controllers/workarea/api/admin/pages_controller.rb +7 -0
  22. data/admin/app/controllers/workarea/api/admin/payment_profiles_controller.rb +7 -0
  23. data/admin/app/controllers/workarea/api/admin/payment_transactions_controller.rb +7 -0
  24. data/admin/app/controllers/workarea/api/admin/payments_controller.rb +7 -0
  25. data/admin/app/controllers/workarea/api/admin/pricing_skus_controller.rb +7 -0
  26. data/admin/app/controllers/workarea/api/admin/products_controller.rb +11 -4
  27. data/admin/app/controllers/workarea/api/admin/promo_code_lists_controller.rb +7 -0
  28. data/admin/app/controllers/workarea/api/admin/redirects_controller.rb +7 -0
  29. data/admin/app/controllers/workarea/api/admin/releases_controller.rb +7 -0
  30. data/admin/app/controllers/workarea/api/admin/shipping_services_controller.rb +7 -0
  31. data/admin/app/controllers/workarea/api/admin/shippings_controller.rb +7 -0
  32. data/admin/app/controllers/workarea/api/admin/swagger_controller.rb +33 -0
  33. data/admin/app/controllers/workarea/api/admin/tax_categories_controller.rb +2 -0
  34. data/admin/app/controllers/workarea/api/admin/users_controller.rb +28 -14
  35. data/admin/app/models/workarea/api/admin/date_filtering.rb +27 -0
  36. data/admin/lib/workarea/api/admin/engine.rb +11 -0
  37. data/admin/test/documentation/workarea/api/admin/email_signups_documentation_test.rb +14 -2
  38. data/admin/test/documentation/workarea/api/admin/global_functionality_documentation_test.rb +140 -0
  39. data/admin/test/documentation/workarea/api/admin/orders_documentation_test.rb +13 -6
  40. data/admin/test/documentation/workarea/api/admin/users_documentation_test.rb +14 -2
  41. data/admin/test/dummy/config/initializers/session_store.rb +3 -1
  42. data/admin/test/integration/workarea/api/admin/categories_integration_test.rb +32 -0
  43. data/admin/test/integration/workarea/api/admin/content_assets_integration_test.rb +32 -0
  44. data/admin/test/integration/workarea/api/admin/content_integration_test.rb +32 -0
  45. data/admin/test/integration/workarea/api/admin/discounts_integration_test.rb +32 -0
  46. data/admin/test/integration/workarea/api/admin/email_signups_integration_test.rb +38 -1
  47. data/admin/test/integration/workarea/api/admin/fulfillments_integration_test.rb +22 -0
  48. data/admin/test/integration/workarea/api/admin/inventory_skus_integration_test.rb +32 -0
  49. data/admin/test/integration/workarea/api/admin/navigation_menus_integration_test.rb +32 -0
  50. data/admin/test/integration/workarea/api/admin/navigation_taxons_integration_test.rb +32 -0
  51. data/admin/test/integration/workarea/api/admin/orders_integration_test.rb +41 -2
  52. data/admin/test/integration/workarea/api/admin/pages_integration_test.rb +32 -0
  53. data/admin/test/integration/workarea/api/admin/payment_profiles_integration_test.rb +32 -0
  54. data/admin/test/integration/workarea/api/admin/payment_transactions_integration_test.rb +32 -0
  55. data/admin/test/integration/workarea/api/admin/payments_integration_test.rb +32 -0
  56. data/admin/test/integration/workarea/api/admin/pricing_skus_integration_test.rb +32 -0
  57. data/admin/test/integration/workarea/api/admin/products_integration_test.rb +35 -0
  58. data/admin/test/integration/workarea/api/admin/promo_code_lists_integration_test.rb +31 -0
  59. data/admin/test/integration/workarea/api/admin/redirects_integration_test.rb +31 -0
  60. data/admin/test/integration/workarea/api/admin/releases_integration_test.rb +31 -0
  61. data/admin/test/integration/workarea/api/admin/shipping_services_integration_test.rb +31 -0
  62. data/admin/test/integration/workarea/api/admin/shippings_integration_test.rb +31 -0
  63. data/admin/test/integration/workarea/api/admin/tax_categories_integration_test.rb +31 -0
  64. data/admin/test/integration/workarea/api/admin/users_integration_test.rb +44 -1
  65. data/app/views/workarea/api/docs/nav.haml +12 -0
  66. data/doc/api/admin/categories/bulk_upserting_categories.json +8 -4
  67. data/doc/api/admin/categories/creating_a_category.json +11 -8
  68. data/doc/api/admin/categories/listing_categories.json +8 -5
  69. data/doc/api/admin/categories/removing_a_category.json +8 -4
  70. data/doc/api/admin/categories/showing_a_category.json +10 -7
  71. data/doc/api/admin/categories/updating_a_category.json +9 -5
  72. data/doc/api/admin/category_product_rules/creating_a_category_product_rule.json +11 -8
  73. data/doc/api/admin/category_product_rules/listing_category_product_rules.json +10 -7
  74. data/doc/api/admin/category_product_rules/removing_a_category_product_rule.json +8 -4
  75. data/doc/api/admin/category_product_rules/updating_a_category_product_rule.json +8 -4
  76. data/doc/api/admin/content/bulk_upserting_content.json +8 -4
  77. data/doc/api/admin/content/creating_content.json +11 -8
  78. data/doc/api/admin/content/listing_content.json +8 -5
  79. data/doc/api/admin/content/showing_content.json +10 -7
  80. data/doc/api/admin/content/updating_content.json +8 -4
  81. data/doc/api/admin/content_assets/bulk_upserting_content_assets.json +8 -4
  82. data/doc/api/admin/content_assets/creating_a_content_asset.json +11 -8
  83. data/doc/api/admin/content_assets/listing_content_assets.json +8 -5
  84. data/doc/api/admin/content_assets/removing_a_content_asset.json +8 -4
  85. data/doc/api/admin/content_assets/showing_a_content_asset.json +10 -7
  86. data/doc/api/admin/content_assets/updating_a_content_asset.json +9 -5
  87. data/doc/api/admin/discounts/creating_a_discount.json +11 -8
  88. data/doc/api/admin/discounts/listing_discounts.json +8 -5
  89. data/doc/api/admin/discounts/removing_a_discount.json +8 -4
  90. data/doc/api/admin/discounts/showing_a_discount.json +10 -7
  91. data/doc/api/admin/discounts/updating_discounts.json +8 -4
  92. data/doc/api/admin/email_signups/listing_email_signups.json +7 -4
  93. data/doc/api/admin/email_signups/showing_an_email_signup.json +10 -12
  94. data/doc/api/admin/fulfillment/listing_fulfillments.json +7 -4
  95. data/doc/api/admin/fulfillment/marking_items_as_canceled.json +9 -6
  96. data/doc/api/admin/fulfillment/marking_items_as_shipped.json +9 -6
  97. data/doc/api/admin/fulfillment/showing_fulfillment.json +7 -4
  98. data/doc/api/admin/index.json +653 -578
  99. data/doc/api/admin/inventory_skus/bulk_upserting_inventory_skus.json +8 -4
  100. data/doc/api/admin/inventory_skus/creating_an_inventory_sku.json +9 -6
  101. data/doc/api/admin/inventory_skus/listing_inventory_skus.json +7 -4
  102. data/doc/api/admin/inventory_skus/removing_an_inventory_sku.json +6 -2
  103. data/doc/api/admin/inventory_skus/showing_an_inventory_sku.json +7 -4
  104. data/doc/api/admin/inventory_skus/updating_an_inventory_sku.json +6 -2
  105. data/doc/api/admin/navigation_menus/creating_a_menu.json +11 -8
  106. data/doc/api/admin/navigation_menus/listing_menus.json +8 -5
  107. data/doc/api/admin/navigation_menus/removing_a_navigation_menu.json +8 -4
  108. data/doc/api/admin/navigation_menus/showing_a_navigation_menu.json +10 -7
  109. data/doc/api/admin/navigation_menus/updating_a_navigation_menus.json +8 -4
  110. data/doc/api/admin/navigation_taxonomy/bulk_upserting_navigation_taxons.json +8 -4
  111. data/doc/api/admin/navigation_taxonomy/creating_a_taxon.json +10 -7
  112. data/doc/api/admin/navigation_taxonomy/listing_taxons.json +7 -4
  113. data/doc/api/admin/navigation_taxonomy/removing_a_navigation_taxon.json +8 -4
  114. data/doc/api/admin/navigation_taxonomy/showing_a_navigation_taxon.json +9 -6
  115. data/doc/api/admin/navigation_taxonomy/updating_a_navigation_taxons.json +8 -4
  116. data/doc/api/admin/orders/listing_orders.json +8 -5
  117. data/doc/api/admin/orders/showing_an_order.json +8 -5
  118. data/doc/api/admin/pages/bulk_upserting_pages.json +8 -4
  119. data/doc/api/admin/pages/creating_a_page.json +11 -8
  120. data/doc/api/admin/pages/listing_pages.json +8 -5
  121. data/doc/api/admin/pages/removing_a_page.json +8 -4
  122. data/doc/api/admin/pages/showing_a_page.json +10 -7
  123. data/doc/api/admin/pages/updating_a_page.json +9 -5
  124. data/doc/api/admin/payment_profiles/bulk_upserting_payment_profiles.json +8 -4
  125. data/doc/api/admin/payment_profiles/creating_a_payment_profile.json +10 -7
  126. data/doc/api/admin/payment_profiles/listing_payment_profiles.json +7 -4
  127. data/doc/api/admin/payment_profiles/removing_a_payment_profile.json +8 -4
  128. data/doc/api/admin/payment_profiles/showing_a_payment_profile.json +9 -6
  129. data/doc/api/admin/payment_profiles/updating_a_payment_profiles.json +8 -4
  130. data/doc/api/admin/payment_transactions/listing_payment_transactions.json +7 -4
  131. data/doc/api/admin/payment_transactions/showing_a_payment_transaction.json +9 -6
  132. data/doc/api/admin/payments/listing_payments.json +7 -4
  133. data/doc/api/admin/payments/showing_an_payment.json +7 -4
  134. data/doc/api/admin/prices/creating_a_pricing_sku_price.json +8 -5
  135. data/doc/api/admin/prices/listing_pricing_sku_prices.json +8 -5
  136. data/doc/api/admin/prices/removing_a_pricing_sku_price.json +8 -4
  137. data/doc/api/admin/prices/updating_a_pricing_sku_price.json +8 -4
  138. data/doc/api/admin/pricing_skus/bulk_upserting_pricing_skus.json +8 -4
  139. data/doc/api/admin/pricing_skus/creating_an_pricing_sku.json +10 -7
  140. data/doc/api/admin/pricing_skus/listing_pricing_skus.json +8 -5
  141. data/doc/api/admin/pricing_skus/removing_an_pricing_sku.json +6 -2
  142. data/doc/api/admin/pricing_skus/showing_an_pricing_sku.json +8 -5
  143. data/doc/api/admin/pricing_skus/updating_an_pricing_sku.json +6 -2
  144. data/doc/api/admin/product_images/creating_a_product_image_from_base64.json +11 -8
  145. data/doc/api/admin/product_images/creating_a_product_image_from_url.json +11 -8
  146. data/doc/api/admin/product_images/listing_product_images.json +10 -7
  147. data/doc/api/admin/product_images/removing_a_product_image.json +8 -4
  148. data/doc/api/admin/product_images/updating_a_product_image.json +8 -4
  149. data/doc/api/admin/products/bulk_upserting_products.json +8 -4
  150. data/doc/api/admin/products/creating_a_product.json +11 -8
  151. data/doc/api/admin/products/listing_products.json +8 -5
  152. data/doc/api/admin/products/removing_a_product.json +8 -4
  153. data/doc/api/admin/products/showing_a_product.json +10 -7
  154. data/doc/api/admin/products/updating_a_product.json +9 -5
  155. data/doc/api/admin/promo_code_lists/bulk_upserting_promo_code_lists.json +8 -4
  156. data/doc/api/admin/promo_code_lists/creating_a_promo_code_list.json +10 -7
  157. data/doc/api/admin/promo_code_lists/listing_promo_code_lists.json +7 -4
  158. data/doc/api/admin/promo_code_lists/removing_a_promo_code_list.json +8 -4
  159. data/doc/api/admin/promo_code_lists/showing_a_promo_code_list.json +9 -6
  160. data/doc/api/admin/promo_code_lists/updating_a_promo_code_list.json +8 -4
  161. data/doc/api/admin/recommendation_settings/showing_recommendation_settings.json +9 -6
  162. data/doc/api/admin/recommendation_settings/updating_recommendation_settings.json +8 -4
  163. data/doc/api/admin/redirects/bulk_upserting_redirects.json +8 -4
  164. data/doc/api/admin/redirects/creating_a_redirect.json +10 -7
  165. data/doc/api/admin/redirects/listing_redirects.json +7 -4
  166. data/doc/api/admin/redirects/removing_a_redirect.json +8 -4
  167. data/doc/api/admin/redirects/showing_a_redirect.json +9 -6
  168. data/doc/api/admin/redirects/updating_a_redirects.json +8 -4
  169. data/doc/api/admin/release_changes/adding_changes_to_a_release.json +10 -6
  170. data/doc/api/admin/releases/bulk_upserting_releases.json +8 -4
  171. data/doc/api/admin/releases/creating_a_release.json +11 -8
  172. data/doc/api/admin/releases/listing_releases.json +8 -5
  173. data/doc/api/admin/releases/removing_a_release.json +8 -4
  174. data/doc/api/admin/releases/showing_a_release.json +10 -7
  175. data/doc/api/admin/releases/updating_a_release.json +9 -5
  176. data/doc/api/admin/saved_addresses/creating_a_saved_address.json +10 -7
  177. data/doc/api/admin/saved_addresses/listing_saved_address.json +9 -6
  178. data/doc/api/admin/saved_addresses/removing_a_saved_address.json +8 -4
  179. data/doc/api/admin/saved_addresses/updating_a_saved_address.json +8 -4
  180. data/doc/api/admin/saved_credit_cards/creating_a_saved_credit_card.json +11 -8
  181. data/doc/api/admin/saved_credit_cards/listing_saved_credit_cards.json +9 -6
  182. data/doc/api/admin/saved_credit_cards/removing_a_saved_credit_card.json +8 -4
  183. data/doc/api/admin/saved_credit_cards/updating_a_saved_credit_card.json +8 -4
  184. data/doc/api/admin/shipping/listing_shipments.json +7 -4
  185. data/doc/api/admin/shipping/showing_a_shipment.json +9 -6
  186. data/doc/api/admin/shipping_rates/creating_a_shipping_rate.json +10 -7
  187. data/doc/api/admin/shipping_rates/listing_shipping_rates.json +9 -6
  188. data/doc/api/admin/shipping_rates/removing_a_shipping_rate.json +8 -4
  189. data/doc/api/admin/shipping_rates/updating_a_shipping_rate.json +8 -4
  190. data/doc/api/admin/shipping_services/bulk_upserting_shipping_services.json +8 -4
  191. data/doc/api/admin/shipping_services/creating_a_shipping_service.json +10 -7
  192. data/doc/api/admin/shipping_services/listing_shipping_services.json +7 -4
  193. data/doc/api/admin/shipping_services/removing_a_shipping_service.json +8 -4
  194. data/doc/api/admin/shipping_services/showing_a_shipping_service.json +9 -6
  195. data/doc/api/admin/shipping_services/updating_a_shipping_service.json +9 -5
  196. data/doc/api/admin/tax_categories/bulk_upserting_tax_categories.json +8 -4
  197. data/doc/api/admin/tax_categories/creating_a_tax_category.json +10 -7
  198. data/doc/api/admin/tax_categories/listing_tax_categories.json +7 -4
  199. data/doc/api/admin/tax_categories/removing_a_tax_category.json +8 -4
  200. data/doc/api/admin/tax_categories/showing_a_tax_category.json +9 -6
  201. data/doc/api/admin/tax_categories/updating_a_tax_categories.json +8 -4
  202. data/doc/api/admin/tax_rates/creating_a_tax_rate.json +12 -9
  203. data/doc/api/admin/tax_rates/listing_tax_rates.json +10 -7
  204. data/doc/api/admin/tax_rates/removing_a_tax_rate.json +8 -4
  205. data/doc/api/admin/tax_rates/updating_a_tax_rate.json +8 -4
  206. data/doc/api/admin/users/bulk_upserting_users.json +8 -4
  207. data/doc/api/admin/users/creating_a_user.json +11 -8
  208. data/doc/api/admin/users/listing_users.json +8 -5
  209. data/doc/api/admin/users/removing_a_user.json +8 -4
  210. data/doc/api/admin/users/showing_a_user.json +10 -12
  211. data/doc/api/admin/users/updating_a_user.json +9 -5
  212. data/doc/api/admin/variants/creating_a_product_variant.json +11 -8
  213. data/doc/api/admin/variants/listing_product_variants.json +10 -7
  214. data/doc/api/admin/variants/removing_a_product_variant.json +8 -4
  215. data/doc/api/admin/variants/updating_a_product_variant.json +8 -4
  216. data/doc/api/storefront/accounts/creating_an_account.json +8 -7
  217. data/doc/api/storefront/accounts/getting_account_details.json +9 -8
  218. data/doc/api/storefront/accounts/updating_an_account.json +9 -8
  219. data/doc/api/storefront/analytics/saving_a_category_view.json +19 -6
  220. data/doc/api/storefront/analytics/saving_a_product_view.json +19 -6
  221. data/doc/api/storefront/analytics/saving_a_search.json +19 -6
  222. data/doc/api/storefront/assets/showing_an_asset.json +10 -9
  223. data/doc/api/storefront/authentication/creating_an_authentication_token.json +10 -9
  224. data/doc/api/storefront/authentication/refreshing_an_authentication_token.json +10 -9
  225. data/doc/api/storefront/authentication/using_an_authentication_token.json +11 -10
  226. data/doc/api/storefront/cart/adding_a_promo_code.json +11 -10
  227. data/doc/api/storefront/cart/adding_an_item.json +11 -10
  228. data/doc/api/storefront/cart/creating_a_new_cart_for_a_user.json +10 -9
  229. data/doc/api/storefront/cart/creating_a_new_guest_cart.json +8 -7
  230. data/doc/api/storefront/cart/delete_an_item.json +11 -10
  231. data/doc/api/storefront/cart/listing_user_s_carts.json +10 -9
  232. data/doc/api/storefront/cart/showing_cart.json +11 -10
  233. data/doc/api/storefront/cart/updating_an_item.json +11 -10
  234. data/doc/api/storefront/categories/showing_a_category.json +9 -8
  235. data/doc/api/storefront/categories/showing_a_listing_of_categories.json +9 -8
  236. data/doc/api/storefront/checkout/completing_a_checkout.json +10 -9
  237. data/doc/api/storefront/checkout/showing_a_checkout.json +11 -10
  238. data/doc/api/storefront/checkout/updating_a_checkout.json +10 -9
  239. data/doc/api/storefront/contacts/creating_a_contact.json +8 -7
  240. data/doc/api/storefront/email_signups/creating_an_email_signup.json +8 -7
  241. data/doc/api/storefront/email_signups/showing_an_email_signup_content.json +8 -7
  242. data/doc/api/storefront/index.json +263 -258
  243. data/doc/api/storefront/menus/listing_menus.json +9 -8
  244. data/doc/api/storefront/menus/showing_a_menu.json +11 -10
  245. data/doc/api/storefront/orders/listing_the_user_s_orders.json +10 -9
  246. data/doc/api/storefront/orders/showing_an_order.json +11 -10
  247. data/doc/api/storefront/pages/showing_a_page.json +9 -8
  248. data/doc/api/storefront/password_resets/sending_a_forgot_password_email.json +9 -7
  249. data/doc/api/storefront/personalized_recommendations/showing_recommendations_with_a_session_id.json +12 -12
  250. data/doc/api/storefront/personalized_recommendations/showing_recommendations_with_authentication.json +11 -10
  251. data/doc/api/storefront/products/showing_a_product.json +9 -8
  252. data/doc/api/storefront/products/showing_a_product_with_a_specific_sku_selected.json +9 -8
  253. data/doc/api/storefront/recent_views/showing_recent_views_from_authentication.json +11 -10
  254. data/doc/api/storefront/recent_views/showing_recent_views_with_a_session_id.json +12 -12
  255. data/doc/api/storefront/recent_views/updating_recent_views_with_a_session_id.json +7 -5
  256. data/doc/api/storefront/recent_views/updating_recent_views_with_authentication.json +9 -7
  257. data/doc/api/storefront/saved_addresses/creating_a_saved_address.json +8 -7
  258. data/doc/api/storefront/saved_addresses/deleting_a_saved_address.json +8 -6
  259. data/doc/api/storefront/saved_addresses/listing_the_user_s_saved_addresses.json +10 -9
  260. data/doc/api/storefront/saved_addresses/showing_a_saved_address.json +9 -8
  261. data/doc/api/storefront/saved_addresses/updating_a_saved_address.json +9 -8
  262. data/doc/api/storefront/saved_credit_cards/creating_a_saved_credit_card.json +8 -7
  263. data/doc/api/storefront/saved_credit_cards/deleting_a_saved_credit_card.json +8 -6
  264. data/doc/api/storefront/saved_credit_cards/listing_the_user_s_saved_credit_cards.json +10 -9
  265. data/doc/api/storefront/saved_credit_cards/showing_a_saved_credit_card.json +9 -8
  266. data/doc/api/storefront/saved_credit_cards/updating_a_saved_credit_card.json +9 -8
  267. data/doc/api/storefront/searches/showing_search_autocomplete_suggestions.json +10 -9
  268. data/doc/api/storefront/searches/showing_search_results.json +9 -8
  269. data/doc/api/storefront/segmentation/specifying_session_count_for_segmentation.json +93 -0
  270. data/doc/api/storefront/segmentation/using_session_ids_for_segmenting_non_authenticated_users.json +93 -0
  271. data/doc/api/storefront/system_content/showing_system_content.json +9 -8
  272. data/doc/api/storefront/system_content/showing_the_home_page.json +9 -8
  273. data/doc/api/storefront/taxons/showing_a_taxon.json +11 -10
  274. data/doc/api/storefront/validation_errors/checkout_validation_errors.json +10 -9
  275. data/doc/api/storefront/validation_errors/general_validation_errors.json +5 -4
  276. data/lib/workarea/api/documentation_test.rb +10 -1
  277. data/lib/workarea/api/version.rb +1 -1
  278. data/storefront/app/controllers/workarea/api/storefront/analytics_controller.rb +31 -19
  279. data/storefront/app/controllers/workarea/api/storefront/application_controller.rb +15 -2
  280. data/storefront/app/controllers/workarea/api/storefront/authentication.rb +6 -9
  281. data/storefront/app/controllers/workarea/api/storefront/categories_controller.rb +3 -1
  282. data/storefront/app/controllers/workarea/api/storefront/checkouts_controller.rb +0 -1
  283. data/storefront/app/controllers/workarea/api/storefront/menus_controller.rb +3 -1
  284. data/storefront/app/controllers/workarea/api/storefront/pages_controller.rb +3 -1
  285. data/storefront/app/controllers/workarea/api/storefront/products_controller.rb +3 -1
  286. data/storefront/app/controllers/workarea/api/storefront/recent_views_controller.rb +13 -26
  287. data/storefront/app/controllers/workarea/api/storefront/recommendations_controller.rb +2 -8
  288. data/storefront/app/controllers/workarea/api/storefront/searches_controller.rb +0 -12
  289. data/storefront/app/views/workarea/api/storefront/categories/show.json.jbuilder +1 -1
  290. data/storefront/app/views/workarea/api/storefront/email_signups/show.json.jbuilder +1 -1
  291. data/storefront/app/views/workarea/api/storefront/menus/_menu.json.jbuilder +1 -1
  292. data/storefront/app/views/workarea/api/storefront/pages/show.json.jbuilder +1 -1
  293. data/storefront/app/views/workarea/api/storefront/recent_views/show.json.jbuilder +0 -1
  294. data/storefront/app/views/workarea/api/storefront/searches/show.json.jbuilder +1 -1
  295. data/storefront/app/views/workarea/api/storefront/system_content/show.json.jbuilder +1 -1
  296. data/storefront/config/initializers/config.rb +19 -0
  297. data/storefront/lib/workarea/api/storefront/visit.decorator +52 -0
  298. data/storefront/lib/workarea/api/storefront.rb +1 -0
  299. data/storefront/test/documentation/workarea/api/storefront/segmentation_documentation_test.rb +104 -0
  300. data/storefront/test/dummy/config/initializers/session_store.rb +3 -1
  301. data/storefront/test/integration/workarea/api/storefront/analytics_integration_test.rb +12 -7
  302. data/storefront/test/integration/workarea/api/storefront/recent_views_integration_test.rb +38 -33
  303. data/storefront/test/integration/workarea/api/storefront/recommendations_integration_test.rb +1 -1
  304. data/storefront/test/integration/workarea/api/storefront/searches_integration_test.rb +0 -36
  305. data/storefront/test/integration/workarea/api/storefront/segments_integration_test.rb +218 -0
  306. metadata +18 -12
  307. data/doc/api/admin/orders/viewing_orders_by_date_range.json +0 -68
  308. data/doc/api/storefront/analytics/saving_a_search_abandonment.json +0 -38
  309. data/doc/api/storefront/analytics/saving_filters.json +0 -38
  310. data/storefront/app/controllers/workarea/api/storefront/user_activity.rb +0 -36
  311. data/storefront/app/view_models/workarea/api/storefront/search_suggestion_view_model.rb +0 -21
@@ -10,19 +10,16 @@ module Workarea
10
10
  helper_method :current_user
11
11
  end
12
12
 
13
- def current_user
14
- return @current_user if defined?(@current_user)
15
-
16
- user = authenticate_with_http_token do |token, options|
17
- User::AuthenticationToken.authenticate(token, options).try(:user)
18
- end
13
+ def self.find_user(token, options)
14
+ User::AuthenticationToken.authenticate(token, options).try(:user)
15
+ end
19
16
 
20
- @current_user = user || raise(InvalidError)
17
+ def current_user
18
+ current_visit.current_user || raise(InvalidError)
21
19
  end
22
20
 
23
21
  def authentication?
24
- regex = ActionController::HttpAuthentication::Token::TOKEN_REGEX
25
- request.authorization.to_s[regex].present?
22
+ current_visit.logged_in?
26
23
  end
27
24
  end
28
25
  end
@@ -5,7 +5,7 @@ module Workarea
5
5
  before_action :cache_page
6
6
 
7
7
  def index
8
- models = Catalog::Category.active.page(params[:page])
8
+ models = Catalog::Category.page(params[:page]).select(&:active?)
9
9
  @categories = Workarea::Storefront::CategoryViewModel.wrap(
10
10
  models,
11
11
  view_model_options
@@ -14,6 +14,8 @@ module Workarea
14
14
 
15
15
  def show
16
16
  model = Catalog::Category.find_by(slug: params[:id])
17
+ raise InvalidDisplay unless model.active?
18
+
17
19
  @category = Workarea::Storefront::CategoryViewModel.wrap(
18
20
  model,
19
21
  view_model_options
@@ -96,7 +96,6 @@ module Workarea
96
96
  if authentication?
97
97
  current_order.touch_checkout!(
98
98
  ip_address: request.remote_ip,
99
- user_activity_id: current_user.id,
100
99
  checkout_by_id: current_user.id,
101
100
  source: 'storefront_api'
102
101
  )
@@ -10,7 +10,9 @@ module Workarea
10
10
  end
11
11
 
12
12
  def show
13
- model = Navigation::Menu.active.find(params[:id])
13
+ model = Navigation::Menu.find(params[:id])
14
+ raise InvalidDisplay unless model.active?
15
+
14
16
  @menu = Workarea::Storefront::MenuViewModel.wrap(model, params)
15
17
  end
16
18
  end
@@ -5,7 +5,9 @@ module Workarea
5
5
  before_action :cache_page
6
6
 
7
7
  def show
8
- model = Content::Page.active.find_by(slug: params[:id])
8
+ model = Content::Page.find_by(slug: params[:id])
9
+ raise InvalidDisplay unless model.active?
10
+
9
11
  @page = Workarea::Storefront::PageViewModel.new(model, view_model_options)
10
12
  end
11
13
  end
@@ -5,7 +5,9 @@ module Workarea
5
5
  before_action :cache_page
6
6
 
7
7
  def show
8
- model = Workarea::Catalog::Product.active.find_by(slug: params[:id])
8
+ model = Workarea::Catalog::Product.find_by(slug: params[:id])
9
+ raise InvalidDisplay unless model.active?
10
+
9
11
  @product = Workarea::Storefront::ProductViewModel.wrap(
10
12
  model,
11
13
  view_model_options
@@ -2,39 +2,26 @@ module Workarea
2
2
  module Api
3
3
  module Storefront
4
4
  class RecentViewsController < Api::Storefront::ApplicationController
5
- before_action :assert_current_user_activity_id
5
+ before_action :assert_current_metrics_id
6
6
 
7
7
  def show
8
- if stale?(
9
- etag: user_activity,
10
- last_modified: user_activity.updated_at,
11
- public: true
8
+ @recent_views = Workarea::Storefront::UserActivityViewModel.new(
9
+ current_metrics
12
10
  )
13
- @recent_views = Workarea::Storefront::UserActivityViewModel.new(
14
- user_activity
15
- )
16
- end
17
11
  end
18
12
 
19
13
  def update
20
- if params[:product_id].present?
21
- Recommendation::UserActivity.save_product(
22
- current_user_activity_id,
23
- params[:product_id]
24
- )
25
- end
26
-
27
- if params[:category_id].present?
28
- Recommendation::UserActivity.save_category(
29
- current_user_activity_id,
30
- params[:category_id]
31
- )
32
- end
14
+ product_ids = Array.wrap(params[:product_id])
15
+ category_ids = Array.wrap(params[:category_id])
16
+ search_ids = Array.wrap(params[:search])
33
17
 
34
- if params[:search].present?
35
- Recommendation::UserActivity.save_search(
36
- current_user_activity_id,
37
- params[:search]
18
+ if current_metrics_id.present?
19
+ Metrics::User.save_affinity(
20
+ id: current_metrics_id,
21
+ action: 'viewed',
22
+ product_ids: product_ids,
23
+ category_ids: category_ids,
24
+ search_ids: search_ids
38
25
  )
39
26
  end
40
27
 
@@ -2,17 +2,11 @@ module Workarea
2
2
  module Api
3
3
  module Storefront
4
4
  class RecommendationsController < Api::Storefront::ApplicationController
5
- before_action :assert_current_user_activity_id
5
+ before_action :assert_current_metrics_id
6
6
 
7
7
  def show
8
- fresh_when(
9
- etag: user_activity,
10
- last_modified: user_activity.updated_at,
11
- public: true
12
- )
13
-
14
8
  @recommendations = Workarea::Storefront::PersonalizedRecommendationsViewModel.new(
15
- user_activity,
9
+ current_metrics,
16
10
  view_model_options
17
11
  )
18
12
  end
@@ -4,18 +4,6 @@ module Workarea
4
4
  class SearchesController < Api::Storefront::ApplicationController
5
5
  before_action :cache_page
6
6
 
7
- def index
8
- search_query = QueryString.new(params[:q]).sanitized
9
-
10
- render(nothing: true) && (return) if search_query.blank?
11
- autocomplete_params = params.permit(:q)
12
- search = Search::SearchSuggestions.new(autocomplete_params)
13
-
14
- @results = search.results.map do |result|
15
- SearchSuggestionViewModel.new(result).to_h
16
- end
17
- end
18
-
19
7
  def show
20
8
  response = Search::StorefrontSearch.new(params.to_unsafe_h).response
21
9
  @search = Workarea::Storefront::SearchViewModel.new(
@@ -14,7 +14,7 @@ json.cache! @category.cache_key, expires_in: 1.hour do
14
14
  json.partial! 'workarea/api/storefront/taxons/taxon', taxon: taxon
15
15
  end
16
16
 
17
- json.content_blocks @category.content.blocks do |block|
17
+ json.content_blocks @category.content.blocks.select(&:active?) do |block|
18
18
  json.partial! 'workarea/api/storefront/content_blocks/block', block: block
19
19
  end
20
20
 
@@ -1,4 +1,4 @@
1
1
  json.title @email_signup.title
2
- json.content_blocks @email_signup.content.blocks do |block|
2
+ json.content_blocks @email_signup.content.blocks.select(&:active?) do |block|
3
3
  json.partial! 'workarea/api/storefront/content_blocks/block', block: block
4
4
  end
@@ -5,7 +5,7 @@ json.cache! menu.cache_key, expires_in: 1.hour do
5
5
  json.url menu_path(menu)
6
6
  json.taxon_url menu.taxon.url.presence || storefront_api_url_for(menu.taxon)
7
7
 
8
- json.content_blocks menu.content.blocks do |block|
8
+ json.content_blocks menu.content.blocks.select(&:active?) do |block|
9
9
  json.partial! 'workarea/api/storefront/content_blocks/block', block: block
10
10
  end
11
11
  end
@@ -10,7 +10,7 @@ json.cache! @page.cache_key, expires_in: 1.hour do
10
10
  json.partial! 'workarea/api/storefront/taxons/taxon', taxon: taxon
11
11
  end
12
12
 
13
- json.content_blocks @page.content.blocks do |block|
13
+ json.content_blocks @page.content.blocks.select(&:active?) do |block|
14
14
  json.partial! 'workarea/api/storefront/content_blocks/block', block: block
15
15
  end
16
16
  end
@@ -5,4 +5,3 @@ end
5
5
  json.products @recent_views.products do |product|
6
6
  json.partial! 'workarea/api/storefront/products/product', product: product
7
7
  end
8
- json.searches @recent_views.searches
@@ -4,7 +4,7 @@ json.redirect @search.redirect
4
4
  json.sorts @search.sorts
5
5
  json.sort @search.sort
6
6
 
7
- json.content_blocks @search.content.blocks do |block|
7
+ json.content_blocks @search.content.blocks.select(&:active?) do |block|
8
8
  json.partial! 'workarea/api/storefront/content_blocks/block', block: block
9
9
  end
10
10
 
@@ -6,7 +6,7 @@ json.cache! @content.cache_key, expires_in: 1.hour do
6
6
  json.browser_title @content.browser_title
7
7
  json.meta_description @content.meta_description
8
8
 
9
- json.content_blocks @content.content.blocks do |block|
9
+ json.content_blocks @content.content.blocks.select(&:active?) do |block|
10
10
  json.partial! 'workarea/api/storefront/content_blocks/block', block: block
11
11
  end
12
12
  end
@@ -1,2 +1,21 @@
1
1
  Workarea.config.api_product_image_jobs_blacklist ||= %i[convert encode rotate optim avatar thumb]
2
2
  Workarea.config.authentication_token_expiration ||= 1.week
3
+
4
+ # Ok, this one's a doozy.
5
+ #
6
+ # To deliver segmentation in the storefront API, we need a way to change a
7
+ # {Visit}'s definition of things like sessions, cookies, auth, etc.
8
+ #
9
+ # Since segments are determined first (before any other middleware), we need a
10
+ # way to know whether this is an API request to for logic in {Visit}.
11
+ #
12
+ # Since this is before any other middleware (including Rails' routing), we don't
13
+ # have a way to check the controller class or anything else application-related
14
+ # for whether it's an API request or an ordinary request.
15
+ #
16
+ # The best thing I could come up with is this regex. This lambda provides a hook
17
+ # for builds in case it doesn't work. They can provide their own logic here.
18
+ #
19
+ Workarea.config.is_api_visit = lambda do |request|
20
+ request.original_url =~ /:\/\/api\.|\/api\/./
21
+ end
@@ -0,0 +1,52 @@
1
+ module Workarea
2
+ decorate Visit, with: 'storefront_api' do
3
+ def api?
4
+ return @api if defined?(@api)
5
+ @api = Workarea.config.is_api_visit.call(request)
6
+ end
7
+
8
+ def cookies
9
+ api? ? {} : super
10
+ end
11
+
12
+ def session
13
+ api? ? {} : super
14
+ end
15
+
16
+ def logged_in?
17
+ return super unless api?
18
+
19
+ regex = ActionController::HttpAuthentication::Token::TOKEN_REGEX
20
+ request.authorization.to_s[regex].present?
21
+ end
22
+
23
+ def current_email
24
+ return super unless api?
25
+ return request.params['email'] unless logged_in?
26
+ return @current_email if defined? @current_email
27
+
28
+ @current_email = current_user&.email
29
+ end
30
+
31
+ def current_user
32
+ token, options = ActionController::HttpAuthentication::Token.token_and_options(request)
33
+ @current_user ||= Api::Storefront::Authentication.find_user(token, options)
34
+ end
35
+
36
+ def sessions
37
+ api? ? request.params['sessions'].to_i : super
38
+ end
39
+
40
+ def current_metrics_id
41
+ return super unless api?
42
+
43
+ return @current_metrics_id if defined?(@current_metrics_id)
44
+ @current_metrics_id = current_email.presence || request.params['session_id']
45
+ end
46
+
47
+ def current_metrics_id=(value)
48
+ return super unless api?
49
+ # Unsupported in the API
50
+ end
51
+ end
52
+ end
@@ -13,3 +13,4 @@ end
13
13
 
14
14
  require 'workarea/api/version'
15
15
  require 'workarea/api/storefront/engine'
16
+ require 'workarea/api/storefront/visit.decorator'
@@ -0,0 +1,104 @@
1
+ require 'test_helper'
2
+ require 'workarea/api/documentation_test'
3
+
4
+ module Workarea
5
+ module Api
6
+ module Storefront
7
+ class SegmentationDocumentationTest < DocumentationTest
8
+ resource 'Segmentation'
9
+
10
+ def test_and_document_session_count
11
+ description 'Specifying session count for segmentation'
12
+ route storefront_api.system_content_path('home_page')
13
+ explanation <<~EOS
14
+ Workarea supports segmenting users by number of sessions, e.g.
15
+ first-time vs returning visitors. To support this in the storefront
16
+ API, the client will be responsible for managing this since the API
17
+ is stateless (doesn't have cookies/session).
18
+
19
+ To get session-based segments functioning, you need to pass a
20
+ `sessions` parameter in each request. Workarea will use that as
21
+ the number of sessions for determing the segments for the response.
22
+ This works for all requests across the storefront API.
23
+
24
+ This example shows getting a home page with segmented content based
25
+ on the number of sessions.
26
+ EOS
27
+
28
+ first_time = Segment::FirstTimeVisitor.instance
29
+ returning = Segment::ReturningVisitor.instance
30
+
31
+ content = Content.for('Home Page')
32
+ content.blocks.create!(
33
+ type: 'text',
34
+ data: { text: 'Hello visitor!' },
35
+ active_segment_ids: [first_time.id]
36
+ )
37
+ content.blocks.create!(
38
+ type: 'text',
39
+ data: { text: 'Welcome back!' },
40
+ active_segment_ids: [returning.id]
41
+ )
42
+
43
+ record_request do
44
+ get storefront_api.system_content_path('home_page', sessions: 1)
45
+ assert_match(/Hello visitor!/, response.body)
46
+ assert(response.ok?)
47
+ end
48
+ record_request do
49
+ get storefront_api.system_content_path('home_page', sessions: 2)
50
+ assert_match(/Welcome back!/, response.body)
51
+ assert(response.ok?)
52
+ end
53
+ end
54
+
55
+ def test_and_document_session_ids
56
+ description 'Using session IDs for segmenting non-authenticated users'
57
+ route storefront_api.system_content_path('home_page')
58
+ explanation <<~EOS
59
+ Workarea supports segmenting users by number of orders, revenue, etc.
60
+ For this functionality to work for users without accounts, you'll
61
+ need to maintain and pass a `session_id` consistently throughout calls
62
+ to the API.
63
+
64
+ An instance of `Metrics::User` will be found or created for that
65
+ `session_id`, and data about the user will be tracked there.
66
+
67
+ Assuming use of the `session_id` consistently through checkout, this
68
+ example shows getting home page content for two different anonymous
69
+ users and getting segmented content back.
70
+ EOS
71
+
72
+ first_time = Segment::FirstTimeCustomer.instance
73
+ returning = Segment::ReturningCustomer.instance
74
+
75
+ Metrics::User.create!(id: 'session_1', orders: 1)
76
+ Metrics::User.create!(id: 'session_2', orders: 2)
77
+
78
+ content = Content.for('Home Page')
79
+ content.blocks.create!(
80
+ type: 'text',
81
+ data: { text: 'Thanks for your order!' },
82
+ active_segment_ids: [first_time.id]
83
+ )
84
+ content.blocks.create!(
85
+ type: 'text',
86
+ data: { text: 'Welcome back repeat customer!' },
87
+ active_segment_ids: [returning.id]
88
+ )
89
+
90
+ record_request do
91
+ get storefront_api.system_content_path('home_page', session_id: 'session_1')
92
+ assert_match(/Thanks/, response.body)
93
+ assert(response.ok?)
94
+ end
95
+ record_request do
96
+ get storefront_api.system_content_path('home_page', session_id: 'session_2')
97
+ assert_match(/Welcome back/, response.body)
98
+ assert(response.ok?)
99
+ end
100
+ end
101
+ end
102
+ end
103
+ end
104
+ end
@@ -1,3 +1,5 @@
1
1
  # Be sure to restart your server when you modify this file.
2
2
 
3
- Rails.application.config.session_store :cookie_store, key: '_dummy_session'
3
+ Rails.application.config.session_store :cookie_store,
4
+ key: '_dummy_session',
5
+ expire_after: 30.minutes
@@ -7,11 +7,19 @@ module Workarea
7
7
  def test_saving_category_view
8
8
  post storefront_api.analytics_category_view_path(category_id: 'foo')
9
9
  assert_equal(1, Metrics::CategoryByDay.first.views)
10
+
11
+ post storefront_api.analytics_category_view_path(category_id: 'foo', session_id: '1')
12
+ assert_equal(2, Metrics::CategoryByDay.first.views)
13
+ assert_equal(%w(foo), Metrics::User.find('1').viewed.category_ids)
10
14
  end
11
15
 
12
16
  def test_saving_product_view
13
17
  post storefront_api.analytics_product_view_path(product_id: 'foo')
14
18
  assert_equal(1, Metrics::ProductByDay.first.views)
19
+
20
+ post storefront_api.analytics_product_view_path(product_id: 'foo', session_id: '1')
21
+ assert_equal(2, Metrics::ProductByDay.first.views)
22
+ assert_equal(%w(foo), Metrics::User.find('1').viewed.product_ids)
15
23
  end
16
24
 
17
25
  def test_saving_search
@@ -21,14 +29,11 @@ module Workarea
21
29
  insights = Metrics::SearchByDay.first
22
30
  assert_equal(1, insights.searches)
23
31
  assert_equal(5, insights.total_results)
24
- end
25
32
 
26
- def test_saving_search_abandonment
27
- # Saving abandonment is deprecated, and this will be removed in v3.5
28
- end
29
-
30
- def test_saving_filters
31
- # Saving filters is deprecated, and this will be removed in v3.5
33
+ post storefront_api.analytics_search_path,
34
+ params: { q: 'foo', total_results: 5, session_id: '1' }
35
+ assert_equal(2, insights.reload.searches)
36
+ assert_equal(%w(foo), Metrics::User.find('1').viewed.search_ids)
32
37
  end
33
38
  end
34
39
  end
@@ -19,30 +19,38 @@ module Workarea
19
19
 
20
20
  def test_showing_recent_views_with_authentication
21
21
  user = create_user(first_name: 'Ben', last_name: 'Crouse')
22
- set_current_user(user)
22
+ post storefront_api.authentication_tokens_path,
23
+ params: { email: user.email, password: user.password }
24
+ token = JSON.parse(response.body)['token']
23
25
 
24
- activity = create_user_activity(
25
- id: user.id,
26
+ Metrics::User.save_affinity(
27
+ id: user.email,
28
+ action: 'viewed',
26
29
  product_ids: [@product.id],
27
30
  category_ids: [@category.id],
28
- searches: ['foo']
31
+ at: Time.current,
32
+ search_ids: %w(foo)
29
33
  )
30
34
 
31
- get storefront_api.recent_views_path
35
+ get storefront_api.recent_views_path,
36
+ headers: { 'HTTP_AUTHORIZATION' => encode_credentials(token) }
32
37
 
33
38
  assert(response.ok?)
34
39
  result = JSON.parse(response.body)
35
40
 
36
- assert_equal(activity.id, result['id'])
41
+ assert_equal(user.email, result['id'])
37
42
  assert_equal(@product.id, result['products'].first['id'])
38
43
  assert_equal(@category.id.to_s, result['categories'].first['id'])
39
- assert_includes(result['searches'], 'foo')
40
44
  end
41
45
 
42
46
  def test_adding_recent_views_for_authentication
43
47
  user = create_user(first_name: 'Ben', last_name: 'Crouse')
44
- set_current_user(user)
48
+ post storefront_api.authentication_tokens_path,
49
+ params: { email: user.email, password: user.password }
50
+ token = JSON.parse(response.body)['token']
51
+
45
52
  patch storefront_api.recent_views_path,
53
+ headers: { 'HTTP_AUTHORIZATION' => encode_credentials(token) },
46
54
  params: {
47
55
  product_id: @product.id,
48
56
  category_id: @category.id,
@@ -51,54 +59,51 @@ module Workarea
51
59
 
52
60
  assert(response.ok?)
53
61
 
54
- user_activity = Recommendation::UserActivity.first
55
- assert_equal(user.id.to_s, user_activity.id.to_s)
56
- assert_includes(user_activity.product_ids, @product.id)
57
- assert_includes(user_activity.category_ids, @category.id.to_s)
58
- assert_includes(user_activity.searches, 'foo')
62
+ user_activity = Workarea::Storefront::UserActivityViewModel.wrap(
63
+ Metrics::User.first
64
+ )
65
+ assert_equal(user.email, user_activity.id)
66
+ assert_includes(user_activity.products, @product)
67
+ assert_includes(user_activity.categories, @category)
59
68
  end
60
69
 
61
70
  def test_showing_recent_views_with_session_id
62
- activity = create_user_activity(
71
+ Metrics::User.save_affinity(
72
+ id: BSON::ObjectId.new.to_s,
73
+ action: 'viewed',
63
74
  product_ids: [@product.id],
64
75
  category_ids: [@category.id],
65
- searches: ['bar']
76
+ search_ids: %w(foo)
66
77
  )
78
+ activity = Metrics::User.last
67
79
 
68
80
  get storefront_api.recent_views_path,
69
81
  params: { session_id: activity.id }
70
82
 
71
- assert(response.ok?)
83
+ assert_response(:success)
72
84
  result = JSON.parse(response.body)
73
85
 
74
- assert_equal(activity.id, result['id'])
75
- assert_equal(@product.id, result['products'].first['id'])
86
+ assert_equal(activity.id.to_s, result['id'])
87
+ assert_equal(@product.id.to_s, result['products'].first['id'])
76
88
  assert_equal(@category.id.to_s, result['categories'].first['id'])
77
- assert_includes(result['searches'], 'bar')
78
89
  end
79
90
 
80
91
  def test_adding_recent_views_for_session_id
81
- activity = create_user_activity(
82
- product_ids: [@product.id],
83
- category_ids: [@category.id],
84
- searches: ['bar']
85
- )
86
-
87
92
  patch storefront_api.recent_views_path,
88
93
  params: {
89
- session_id: activity.id,
94
+ session_id: BSON::ObjectId.new.to_s,
90
95
  product_id: @product.id,
91
96
  category_id: @category.id,
92
97
  search: 'bar'
93
98
  }
94
99
 
95
- assert(response.ok?)
100
+ assert_response(:success)
96
101
 
97
- user_activity = Recommendation::UserActivity.first
98
- assert_equal(activity.id, user_activity.id)
99
- assert_includes(user_activity.product_ids, @product.id)
100
- assert_includes(user_activity.category_ids, @category.id.to_s)
101
- assert_includes(user_activity.searches, 'bar')
102
+ user_activity = Workarea::Storefront::UserActivityViewModel.wrap(
103
+ Metrics::User.first
104
+ )
105
+ assert_includes(user_activity.products, @product)
106
+ assert_includes(user_activity.categories, @category)
102
107
  end
103
108
 
104
109
  def test_adding_without_id
@@ -110,7 +115,7 @@ module Workarea
110
115
  }
111
116
 
112
117
  refute(response.ok?)
113
- assert_equal(0, Recommendation::UserActivity.count)
118
+ assert_equal(0, Metrics::User.count)
114
119
  end
115
120
  end
116
121
  end
@@ -23,7 +23,7 @@ module Workarea
23
23
  end
24
24
 
25
25
  def set_user_activity
26
- @activity = create_user_activity
26
+ @activity = Metrics::User.create!
27
27
  end
28
28
 
29
29
  def test_showing_recommendations_with_authentication