workarea-admin 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.
Files changed (388) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +52 -0
  3. data/app/assets/images/workarea/admin/email_logo.png +0 -0
  4. data/app/assets/javascripts/workarea/admin/application.js.erb +11 -1
  5. data/app/assets/javascripts/workarea/admin/config.js.erb +96 -0
  6. data/app/assets/javascripts/workarea/admin/modules/active_by_segment_tooltips.js +108 -0
  7. data/app/assets/javascripts/workarea/admin/modules/calendars.js +1 -1
  8. data/app/assets/javascripts/workarea/admin/modules/categorized_autocomplete_fields.js +1 -1
  9. data/app/assets/javascripts/workarea/admin/modules/impersonation_notification.js +44 -0
  10. data/app/assets/javascripts/workarea/admin/modules/jump_to_menus.js +74 -0
  11. data/app/assets/javascripts/workarea/admin/modules/new_navigation_taxons.js +1 -2
  12. data/app/assets/javascripts/workarea/admin/modules/release_reminder.js +1 -0
  13. data/app/assets/javascripts/workarea/admin/modules/selects.js +33 -0
  14. data/app/assets/javascripts/workarea/admin/modules/style_guide_autocomplete_fields.js +42 -0
  15. data/app/assets/javascripts/workarea/admin/modules/timeline_report_chart.js +105 -0
  16. data/app/assets/javascripts/workarea/admin/modules/toggle_elements.js +27 -0
  17. data/app/assets/javascripts/workarea/admin/modules/tribute_areas.js +91 -0
  18. data/app/assets/javascripts/workarea/admin/templates/chart_legend.jst.ejs +17 -9
  19. data/app/assets/javascripts/workarea/admin/templates/jump_to_menu.jst.ejs +13 -0
  20. data/app/assets/stylesheets/workarea/admin/application.scss.erb +3 -0
  21. data/app/assets/stylesheets/workarea/admin/base/_forms.scss +2 -2
  22. data/app/assets/stylesheets/workarea/admin/components/_activity.scss +24 -16
  23. data/app/assets/stylesheets/workarea/admin/components/_activity_group.scss +3 -19
  24. data/app/assets/stylesheets/workarea/admin/components/_box.scss +21 -5
  25. data/app/assets/stylesheets/workarea/admin/components/_calendar.scss +102 -140
  26. data/app/assets/stylesheets/workarea/admin/components/_chart_legend.scss +10 -13
  27. data/app/assets/stylesheets/workarea/admin/components/_checkbox.scss +49 -23
  28. data/app/assets/stylesheets/workarea/admin/components/_content_block_list.scss +5 -3
  29. data/app/assets/stylesheets/workarea/admin/components/_date_marker.scss +24 -3
  30. data/app/assets/stylesheets/workarea/admin/components/_index_table.scss +5 -0
  31. data/app/assets/stylesheets/workarea/admin/components/_jump_to_menu.scss +57 -0
  32. data/app/assets/stylesheets/workarea/admin/components/_product_summary.scss +46 -0
  33. data/app/assets/stylesheets/workarea/admin/components/_toggle_button.scss +1 -4
  34. data/app/assets/stylesheets/workarea/admin/email/_base.scss +30 -2
  35. data/app/assets/stylesheets/workarea/admin/email/_components.scss +66 -5
  36. data/app/assets/stylesheets/workarea/admin/email/_helpers.scss +16 -5
  37. data/app/assets/stylesheets/workarea/admin/email/{_settings.scss → _settings.scss.erb} +4 -4
  38. data/app/controllers/workarea/admin/application_controller.rb +2 -4
  39. data/app/controllers/workarea/admin/bulk_action_sequential_product_edits_controller.rb +4 -6
  40. data/app/controllers/workarea/admin/bulk_variant_saving.rb +1 -2
  41. data/app/controllers/workarea/admin/catalog_products_controller.rb +4 -6
  42. data/app/controllers/workarea/admin/catalog_variants_controller.rb +2 -3
  43. data/app/controllers/workarea/admin/comments_controller.rb +9 -0
  44. data/app/controllers/workarea/admin/configurations_controller.rb +29 -0
  45. data/app/controllers/workarea/admin/content_assets_controller.rb +3 -1
  46. data/app/controllers/workarea/admin/content_blocks_controller.rb +1 -7
  47. data/app/controllers/workarea/admin/create_catalog_products_controller.rb +2 -8
  48. data/app/controllers/workarea/admin/create_release_undos_controller.rb +43 -0
  49. data/app/controllers/workarea/admin/create_segments_controller.rb +68 -0
  50. data/app/controllers/workarea/admin/dashboards_controller.rb +2 -0
  51. data/app/controllers/workarea/admin/data_file_imports_controller.rb +7 -2
  52. data/app/controllers/workarea/admin/fulfillment_skus_controller.rb +58 -0
  53. data/app/controllers/workarea/admin/fulfillment_tokens_controller.rb +56 -0
  54. data/app/controllers/workarea/admin/guest_browsings_controller.rb +2 -2
  55. data/app/controllers/workarea/admin/impersonations_controller.rb +3 -4
  56. data/app/controllers/workarea/admin/orders_controller.rb +3 -0
  57. data/app/controllers/workarea/admin/pricing_discount_redemptions_controller.rb +13 -0
  58. data/app/controllers/workarea/admin/pricing_overrides_controller.rb +1 -1
  59. data/app/controllers/workarea/admin/product_rules_controller.rb +1 -2
  60. data/app/controllers/workarea/admin/releases_controller.rb +8 -13
  61. data/app/controllers/workarea/admin/reports_controller.rb +18 -0
  62. data/app/controllers/workarea/admin/segment_overrides_controller.rb +19 -0
  63. data/app/controllers/workarea/admin/segment_rules_controller.rb +62 -0
  64. data/app/controllers/workarea/admin/segments_controller.rb +48 -0
  65. data/app/controllers/workarea/admin/tax_rates_controller.rb +62 -1
  66. data/app/controllers/workarea/admin/unsubscribes_controller.rb +40 -0
  67. data/app/controllers/workarea/admin/users_controller.rb +19 -0
  68. data/app/helpers/workarea/admin/application_helper.rb +2 -12
  69. data/app/helpers/workarea/admin/configurations_helper.rb +9 -0
  70. data/app/helpers/workarea/admin/content_helper.rb +2 -3
  71. data/app/helpers/workarea/admin/fulfillment_helper.rb +10 -0
  72. data/app/helpers/workarea/admin/icons_helper.rb +26 -0
  73. data/app/helpers/workarea/admin/navigation_helper.rb +1 -0
  74. data/app/helpers/workarea/admin/pricing_overrides_helper.rb +1 -1
  75. data/app/helpers/workarea/admin/products_helper.rb +13 -0
  76. data/app/helpers/workarea/admin/releases_helper.rb +5 -21
  77. data/app/helpers/workarea/admin/segments_helper.rb +68 -0
  78. data/app/helpers/workarea/admin/settings_helper.rb +11 -3
  79. data/app/mailers/workarea/admin/comment_mailer.rb +3 -3
  80. data/app/mailers/workarea/admin/status_report_mailer.rb +19 -6
  81. data/app/view_models/workarea/admin/bulk_action_product_edit_view_model.rb +5 -0
  82. data/app/view_models/workarea/admin/changeset_view_model.rb +15 -3
  83. data/app/view_models/workarea/admin/code_list_view_model.rb +1 -1
  84. data/app/view_models/workarea/admin/commentable_view_model.rb +4 -0
  85. data/app/view_models/workarea/admin/content_view_model.rb +2 -0
  86. data/app/view_models/workarea/admin/dashboards/marketing_view_model.rb +5 -9
  87. data/app/view_models/workarea/admin/dashboards/reports_view_model.rb +25 -0
  88. data/app/view_models/workarea/admin/discounts/buy_some_get_some_view_model.rb +6 -0
  89. data/app/view_models/workarea/admin/discounts/category_view_model.rb +6 -0
  90. data/app/view_models/workarea/admin/discounts/free_gift_view_model.rb +6 -0
  91. data/app/view_models/workarea/admin/discounts/order_total_view_model.rb +6 -0
  92. data/app/view_models/workarea/admin/discounts/product_attribute_view_model.rb +6 -0
  93. data/app/view_models/workarea/admin/discounts/product_view_model.rb +6 -0
  94. data/app/view_models/workarea/admin/discounts/quantity_fixed_price_view_model.rb +6 -0
  95. data/app/view_models/workarea/admin/discounts/shipping_view_model.rb +6 -0
  96. data/app/view_models/workarea/admin/featured_products_view_model.rb +6 -12
  97. data/app/view_models/workarea/admin/fulfillment_sku_view_model.rb +22 -0
  98. data/app/view_models/workarea/admin/fulfillment_token_view_model.rb +15 -0
  99. data/app/view_models/workarea/admin/fulfillment_view_model.rb +14 -0
  100. data/app/view_models/workarea/admin/insight_view_model.rb +2 -2
  101. data/app/view_models/workarea/admin/insights/product_view_model.rb +2 -2
  102. data/app/view_models/workarea/admin/insights/segment_view_model.rb +25 -0
  103. data/app/view_models/workarea/admin/order_view_model.rb +4 -0
  104. data/app/view_models/workarea/admin/pricing_sku_view_model.rb +0 -51
  105. data/app/view_models/workarea/admin/product_rules_preview_view_model.rb +2 -2
  106. data/app/view_models/workarea/admin/product_view_model.rb +26 -5
  107. data/app/view_models/workarea/admin/recommendations_view_model.rb +3 -11
  108. data/app/view_models/workarea/admin/release_calendar_view_model.rb +4 -9
  109. data/app/view_models/workarea/admin/release_event_view_model.rb +8 -41
  110. data/app/view_models/workarea/admin/release_view_model.rb +10 -17
  111. data/app/view_models/workarea/admin/releases_feed_view_model.rb +5 -13
  112. data/app/view_models/workarea/admin/reports/customers_view_model.rb +4 -2
  113. data/app/view_models/workarea/admin/reports/low_inventory_view_model.rb +2 -5
  114. data/app/view_models/workarea/admin/reports/sales_by_category_view_model.rb +2 -5
  115. data/app/view_models/workarea/admin/reports/sales_by_discount_view_model.rb +2 -5
  116. data/app/view_models/workarea/admin/reports/sales_by_product_view_model.rb +2 -5
  117. data/app/view_models/workarea/admin/reports/sales_by_tender_view_model.rb +13 -0
  118. data/app/view_models/workarea/admin/reports/timeline_view_model.rb +74 -0
  119. data/app/view_models/workarea/admin/search_customization_product_rules_view_model.rb +1 -1
  120. data/app/view_models/workarea/admin/segment_view_model.rb +19 -0
  121. data/app/view_models/workarea/admin/user_view_model.rb +6 -9
  122. data/app/view_models/workarea/admin/variant_view_model.rb +8 -0
  123. data/app/views/layouts/workarea/admin/application.html.haml +1 -1
  124. data/app/views/layouts/workarea/admin/email.html.haml +35 -41
  125. data/app/views/workarea/admin/activities/_configuration_admin_update.html.haml +10 -0
  126. data/app/views/workarea/admin/activities/_fulfillment_sku_create.html.haml +12 -0
  127. data/app/views/workarea/admin/activities/_fulfillment_sku_destroy.html.haml +10 -0
  128. data/app/views/workarea/admin/activities/_fulfillment_sku_update.html.haml +10 -0
  129. data/app/views/workarea/admin/activities/_segment_create.html.haml +12 -0
  130. data/app/views/workarea/admin/activities/_segment_destroy.html.haml +10 -0
  131. data/app/views/workarea/admin/activities/_segment_update.html.haml +10 -0
  132. data/app/views/workarea/admin/activities/show.html.haml +18 -11
  133. data/app/views/workarea/admin/bulk_action_product_edits/edit.html.haml +4 -0
  134. data/app/views/workarea/admin/bulk_action_product_edits/review.html.haml +11 -4
  135. data/app/views/workarea/admin/bulk_action_sequential_product_edits/product.html.haml +1 -1
  136. data/app/views/workarea/admin/catalog_categories/_cards.html.haml +3 -1
  137. data/app/views/workarea/admin/catalog_categories/edit.html.haml +1 -4
  138. data/app/views/workarea/admin/catalog_categories/index.html.haml +1 -0
  139. data/app/views/workarea/admin/catalog_product_images/edit.html.haml +1 -1
  140. data/app/views/workarea/admin/catalog_products/_cards.html.haml +2 -4
  141. data/app/views/workarea/admin/catalog_products/edit.html.haml +2 -1
  142. data/app/views/workarea/admin/catalog_products/index.html.haml +4 -2
  143. data/app/views/workarea/admin/catalog_products/insights.html.haml +2 -0
  144. data/app/views/workarea/admin/catalog_variants/edit.html.haml +6 -1
  145. data/app/views/workarea/admin/catalog_variants/index.html.haml +2 -0
  146. data/app/views/workarea/admin/catalog_variants/new.html.haml +5 -0
  147. data/app/views/workarea/admin/changesets/fields/_active_segment_ids.html.haml +4 -0
  148. data/app/views/workarea/admin/comment_mailer/notify.html.haml +27 -19
  149. data/app/views/workarea/admin/comments/index.html.haml +18 -12
  150. data/app/views/workarea/admin/configurations/_overridden.html.haml +2 -0
  151. data/app/views/workarea/admin/configurations/show.html.haml +49 -0
  152. data/app/views/workarea/admin/configurations/types/_array.html.haml +3 -0
  153. data/app/views/workarea/admin/configurations/types/_boolean.html.haml +1 -0
  154. data/app/views/workarea/admin/configurations/types/_duration.html.haml +2 -0
  155. data/app/views/workarea/admin/configurations/types/_encrypted.html.haml +1 -0
  156. data/app/views/workarea/admin/configurations/types/_float.html.haml +1 -0
  157. data/app/views/workarea/admin/configurations/types/_hash.html.haml +17 -0
  158. data/app/views/workarea/admin/configurations/types/_integer.html.haml +1 -0
  159. data/app/views/workarea/admin/configurations/types/_select.html.haml +1 -0
  160. data/app/views/workarea/admin/configurations/types/_string.html.haml +1 -0
  161. data/app/views/workarea/admin/configurations/types/_symbol.html.haml +1 -0
  162. data/app/views/workarea/admin/content/_edit.html.haml +8 -1
  163. data/app/views/workarea/admin/content/_form.html.haml +13 -7
  164. data/app/views/workarea/admin/content/advanced.html.haml +18 -10
  165. data/app/views/workarea/admin/content_assets/_cards.html.haml +3 -0
  166. data/app/views/workarea/admin/content_assets/_summary.html.haml +1 -1
  167. data/app/views/workarea/admin/content_assets/edit.html.haml +6 -0
  168. data/app/views/workarea/admin/content_assets/index.html.haml +7 -2
  169. data/app/views/workarea/admin/content_assets/new.html.haml +10 -3
  170. data/app/views/workarea/admin/content_blocks/_asset.html.haml +8 -1
  171. data/app/views/workarea/admin/content_pages/_cards.html.haml +1 -0
  172. data/app/views/workarea/admin/content_pages/edit.html.haml +1 -1
  173. data/app/views/workarea/admin/content_pages/index.html.haml +1 -0
  174. data/app/views/workarea/admin/create_catalog_categories/publish.html.haml +1 -0
  175. data/app/views/workarea/admin/create_catalog_products/content.html.haml +1 -1
  176. data/app/views/workarea/admin/create_catalog_products/publish.html.haml +1 -0
  177. data/app/views/workarea/admin/create_content_pages/publish.html.haml +1 -0
  178. data/app/views/workarea/admin/create_pricing_discounts/publish.html.haml +1 -0
  179. data/app/views/workarea/admin/create_release_undos/new.html.haml +45 -0
  180. data/app/views/workarea/admin/create_release_undos/review.html.haml +51 -0
  181. data/app/views/workarea/admin/create_releases/plan.html.haml +4 -3
  182. data/app/views/workarea/admin/create_releases/setup.html.haml +8 -12
  183. data/app/views/workarea/admin/create_segments/rules.html.haml +55 -0
  184. data/app/views/workarea/admin/create_segments/setup.html.haml +42 -0
  185. data/app/views/workarea/admin/create_users/admin.html.haml +0 -2
  186. data/app/views/workarea/admin/dashboards/catalog.html.haml +1 -0
  187. data/app/views/workarea/admin/dashboards/people.html.haml +1 -1
  188. data/app/views/workarea/admin/dashboards/reports.html.haml +31 -0
  189. data/app/views/workarea/admin/dashboards/settings.html.haml +23 -3
  190. data/app/views/workarea/admin/data_file_imports/new.html.haml +4 -2
  191. data/app/views/workarea/admin/data_file_mailer/export.html.haml +2 -0
  192. data/app/views/workarea/admin/data_file_mailer/import.html.haml +2 -0
  193. data/app/views/workarea/admin/data_file_mailer/import_failure.html.haml +2 -0
  194. data/app/views/workarea/admin/facets/_applied.html.haml +1 -1
  195. data/app/views/workarea/admin/featured_products/_selected.html.haml +3 -2
  196. data/app/views/workarea/admin/featured_products/_unselected.html.haml +3 -1
  197. data/app/views/workarea/admin/featured_products/edit.html.haml +3 -3
  198. data/app/views/workarea/admin/featured_products/select.html.haml +0 -1
  199. data/app/views/workarea/admin/fulfillment_skus/_aux_navigation.html.haml +3 -0
  200. data/app/views/workarea/admin/fulfillment_skus/_cards.html.haml +57 -0
  201. data/app/views/workarea/admin/fulfillment_skus/_summary.html.haml +6 -0
  202. data/app/views/workarea/admin/fulfillment_skus/edit.html.haml +53 -0
  203. data/app/views/workarea/admin/fulfillment_skus/index.html.haml +75 -0
  204. data/app/views/workarea/admin/fulfillment_skus/new.html.haml +41 -0
  205. data/app/views/workarea/admin/fulfillment_skus/show.html.haml +17 -0
  206. data/app/views/workarea/admin/fulfillment_tokens/index.html.haml +73 -0
  207. data/app/views/workarea/admin/fulfillments/show.html.haml +41 -6
  208. data/app/views/workarea/admin/insights/_most_discounted_products.html.haml +4 -4
  209. data/app/views/workarea/admin/inventory_skus/show.html.haml +1 -1
  210. data/app/views/workarea/admin/navigation_menus/_summary.html.haml +1 -1
  211. data/app/views/workarea/admin/navigation_menus/edit.html.haml +1 -1
  212. data/app/views/workarea/admin/navigation_menus/index.html.haml +3 -1
  213. data/app/views/workarea/admin/navigation_redirects/index.html.haml +0 -5
  214. data/app/views/workarea/admin/navigation_taxons/index.html.haml +20 -4
  215. data/app/views/workarea/admin/orders/_cards.html.haml +23 -5
  216. data/app/views/workarea/admin/orders/attributes.html.haml +4 -1
  217. data/app/views/workarea/admin/orders/fraud.html.haml +43 -0
  218. data/app/views/workarea/admin/orders/index.html.haml +1 -0
  219. data/app/views/workarea/admin/orders/timeline.html.haml +1 -1
  220. data/app/views/workarea/admin/pricing_discount_code_lists/_cards.html.haml +1 -1
  221. data/app/views/workarea/admin/pricing_discount_code_lists/promo_codes.html.haml +1 -1
  222. data/app/views/workarea/admin/pricing_discount_redemptions/index.html.haml +44 -0
  223. data/app/views/workarea/admin/pricing_discounts/_cards.html.haml +22 -0
  224. data/app/views/workarea/admin/pricing_discounts/conditions/_segments.html.haml +5 -0
  225. data/app/views/workarea/admin/pricing_discounts/edit.html.haml +5 -15
  226. data/app/views/workarea/admin/pricing_discounts/index.html.haml +1 -0
  227. data/app/views/workarea/admin/pricing_discounts/properties/_buy_some_get_some.html.haml +1 -0
  228. data/app/views/workarea/admin/pricing_discounts/properties/_category.html.haml +1 -0
  229. data/app/views/workarea/admin/pricing_discounts/properties/_free_gift.html.haml +1 -0
  230. data/app/views/workarea/admin/pricing_discounts/properties/_order_total.html.haml +1 -0
  231. data/app/views/workarea/admin/pricing_discounts/properties/_product.html.haml +1 -0
  232. data/app/views/workarea/admin/pricing_discounts/properties/_product_attribute.html.haml +2 -1
  233. data/app/views/workarea/admin/pricing_discounts/properties/_quantity_fixed_price.html.haml +1 -0
  234. data/app/views/workarea/admin/pricing_discounts/properties/_shipping.html.haml +1 -0
  235. data/app/views/workarea/admin/pricing_skus/_cards.html.haml +7 -7
  236. data/app/views/workarea/admin/pricing_skus/edit.html.haml +5 -5
  237. data/app/views/workarea/admin/pricing_skus/index.html.haml +4 -4
  238. data/app/views/workarea/admin/pricing_skus/new.html.haml +6 -9
  239. data/app/views/workarea/admin/product_rules/_card.html.haml +2 -2
  240. data/app/views/workarea/admin/product_rules/_form.html.haml +1 -0
  241. data/app/views/workarea/admin/product_rules/index.html.haml +2 -0
  242. data/app/views/workarea/admin/releases/_cards.html.haml +50 -12
  243. data/app/views/workarea/admin/releases/_publish.html.haml +1 -1
  244. data/app/views/workarea/admin/releases/edit.html.haml +33 -46
  245. data/app/views/workarea/admin/releases/index.html.haml +81 -90
  246. data/app/views/workarea/admin/releases/list.html.haml +107 -0
  247. data/app/views/workarea/admin/releases/original.html.haml +50 -0
  248. data/app/views/workarea/admin/releases/show.html.haml +3 -17
  249. data/app/views/workarea/admin/releases/undo.html.haml +64 -0
  250. data/app/views/workarea/admin/reports/average_order_value.html.haml +1 -1
  251. data/app/views/workarea/admin/reports/customers.html.haml +4 -0
  252. data/app/views/workarea/admin/reports/first_time_vs_returning_sales.html.haml +1 -1
  253. data/app/views/workarea/admin/reports/reference.html.haml +19 -60
  254. data/app/views/workarea/admin/reports/sales_by_country.html.haml +6 -0
  255. data/app/views/workarea/admin/reports/sales_by_product.html.haml +6 -0
  256. data/app/views/workarea/admin/reports/sales_by_sku.html.haml +6 -0
  257. data/app/views/workarea/admin/reports/sales_by_tender.html.haml +30 -0
  258. data/app/views/workarea/admin/reports/sales_over_time.html.haml +5 -1
  259. data/app/views/workarea/admin/reports/timeline.html.haml +20 -0
  260. data/app/views/workarea/admin/search_customizations/_cards.html.haml +1 -0
  261. data/app/views/workarea/admin/search_customizations/edit.html.haml +1 -1
  262. data/app/views/workarea/admin/search_customizations/index.html.haml +1 -0
  263. data/app/views/workarea/admin/searches/show.html.haml +6 -5
  264. data/app/views/workarea/admin/segment_overrides/show.html.haml +29 -0
  265. data/app/views/workarea/admin/segment_rules/_form.html.haml +13 -0
  266. data/app/views/workarea/admin/segment_rules/fields/_browser_info.html.haml +13 -0
  267. data/app/views/workarea/admin/segment_rules/fields/_geolocation.html.haml +4 -0
  268. data/app/views/workarea/admin/segment_rules/fields/_last_order.html.haml +3 -0
  269. data/app/views/workarea/admin/segment_rules/fields/_logged_in.html.haml +2 -0
  270. data/app/views/workarea/admin/segment_rules/fields/_orders.html.haml +5 -0
  271. data/app/views/workarea/admin/segment_rules/fields/_revenue.html.haml +9 -0
  272. data/app/views/workarea/admin/segment_rules/fields/_sessions.html.haml +5 -0
  273. data/app/views/workarea/admin/segment_rules/fields/_tags.html.haml +4 -0
  274. data/app/views/workarea/admin/segment_rules/fields/_traffic_referrer.html.haml +13 -0
  275. data/app/views/workarea/admin/segment_rules/geolocation_options.json.jbuilder +4 -0
  276. data/app/views/workarea/admin/segment_rules/index.html.haml +25 -0
  277. data/app/views/workarea/admin/segment_rules/summaries/_browser_info.html.haml +11 -0
  278. data/app/views/workarea/admin/segment_rules/summaries/_geolocation.html.haml +2 -0
  279. data/app/views/workarea/admin/segment_rules/summaries/_last_order.html.haml +2 -0
  280. data/app/views/workarea/admin/segment_rules/summaries/_logged_in.html.haml +5 -0
  281. data/app/views/workarea/admin/segment_rules/summaries/_orders.html.haml +6 -0
  282. data/app/views/workarea/admin/segment_rules/summaries/_revenue.html.haml +7 -0
  283. data/app/views/workarea/admin/segment_rules/summaries/_sessions.html.haml +6 -0
  284. data/app/views/workarea/admin/segment_rules/summaries/_tags.html.haml +2 -0
  285. data/app/views/workarea/admin/segment_rules/summaries/_traffic_referrer.html.haml +10 -0
  286. data/app/views/workarea/admin/segments/_cards.html.haml +81 -0
  287. data/app/views/workarea/admin/segments/_publish.html.haml +10 -0
  288. data/app/views/workarea/admin/segments/edit.html.haml +41 -0
  289. data/app/views/workarea/admin/segments/index.html.haml +64 -0
  290. data/app/views/workarea/admin/segments/insights.html.haml +52 -0
  291. data/app/views/workarea/admin/segments/show.html.haml +20 -0
  292. data/app/views/workarea/admin/shared/_active_field.html.haml +17 -0
  293. data/app/views/workarea/admin/shared/_bulk_actions.html.haml +10 -8
  294. data/app/views/workarea/admin/shared/_primary_nav.html.haml +5 -2
  295. data/app/views/workarea/admin/shared/_toggle_button.html.haml +1 -1
  296. data/app/views/workarea/admin/shipping_services/edit.html.haml +0 -4
  297. data/app/views/workarea/admin/shipping_services/new.html.haml +0 -4
  298. data/app/views/workarea/admin/status_report_mailer/report.html.haml +83 -86
  299. data/app/views/workarea/admin/style_guides/components/_activity.html.haml +3 -5
  300. data/app/views/workarea/admin/style_guides/components/_activity_group.html.haml +9 -15
  301. data/app/views/workarea/admin/style_guides/components/_box.html.haml +12 -7
  302. data/app/views/workarea/admin/style_guides/components/_checkbox.html.haml +21 -2
  303. data/app/views/workarea/admin/style_guides/components/_release_changeset.html.haml +3 -5
  304. data/app/views/workarea/admin/tax_rates/edit.html.haml +64 -0
  305. data/app/views/workarea/admin/tax_rates/index.html.haml +59 -20
  306. data/app/views/workarea/admin/tax_rates/new.html.haml +62 -0
  307. data/app/views/workarea/admin/timeline/show.html.haml +34 -41
  308. data/app/views/workarea/admin/toolbar/show.html.haml +11 -1
  309. data/app/views/workarea/admin/trash/index.html.haml +1 -1
  310. data/app/views/workarea/admin/users/edit.html.haml +60 -57
  311. data/app/views/workarea/admin/users/index.html.haml +1 -3
  312. data/app/views/workarea/admin/users/index.json.jbuilder +8 -0
  313. data/app/views/workarea/admin/users/insights.html.haml +31 -23
  314. data/app/views/workarea/admin/users/permissions.html.haml +10 -1
  315. data/app/views/workarea/admin/users/show.html.haml +7 -0
  316. data/config/locales/en.yml +569 -124
  317. data/config/routes.rb +57 -5
  318. data/lib/workarea/mailer_previews/admin/status_report_mailer_preview.rb +3 -1
  319. data/public/workarea/import_samples/tax_rates.csv +3 -3
  320. data/test/dummy/config/initializers/session_store.rb +1 -1
  321. data/test/helpers/workarea/admin/application_helper_test.rb +0 -16
  322. data/test/helpers/workarea/admin/icons_helper_test.rb +9 -0
  323. data/test/helpers/workarea/admin/products_helper_test.rb +73 -0
  324. data/test/helpers/workarea/admin/releases_helper_test.rb +0 -49
  325. data/test/helpers/workarea/admin/settings_helper_test.rb +22 -1
  326. data/test/integration/workarea/admin/assets_integration_test.rb +2 -5
  327. data/test/integration/workarea/admin/comments_integration_test.rb +27 -7
  328. data/test/integration/workarea/admin/configurations_integration_test.rb +21 -0
  329. data/test/integration/workarea/admin/create_release_undos_integration_test.rb +29 -0
  330. data/test/integration/workarea/admin/create_segments_integration_test.rb +26 -0
  331. data/test/integration/workarea/admin/data_file_imports_integration_test.rb +34 -8
  332. data/test/integration/workarea/admin/fulfillment_skus_integration_test.rb +55 -0
  333. data/test/integration/workarea/admin/fulfillment_tokens_integration_test.rb +43 -0
  334. data/test/integration/workarea/admin/guest_browsings_integration_test.rb +8 -32
  335. data/test/integration/workarea/admin/impersonations_integration_test.rb +13 -57
  336. data/test/integration/workarea/admin/jump_to_integration_test.rb +0 -29
  337. data/test/integration/workarea/admin/pricing_overrides_integration_test.rb +11 -0
  338. data/test/integration/workarea/admin/products_integration_test.rb +0 -13
  339. data/test/integration/workarea/admin/releases_integration_test.rb +71 -87
  340. data/test/integration/workarea/admin/segment_overrides_integration_test.rb +28 -0
  341. data/test/integration/workarea/admin/segment_rules_integration_test.rb +49 -0
  342. data/test/integration/workarea/admin/segments_integration_test.rb +31 -0
  343. data/test/integration/workarea/admin/shipping_service_integration_test.rb +1 -3
  344. data/test/integration/workarea/admin/tax_categories_integration_test.rb +1 -1
  345. data/test/integration/workarea/admin/unsubscribes_integration_test.rb +32 -0
  346. data/test/integration/workarea/admin/users_integration_test.rb +32 -0
  347. data/test/javascripts/fixtures/release_reminder.html.haml +3 -3
  348. data/test/javascripts/new_navigation_taxons_spec.js +1 -12
  349. data/test/mailers/workarea/admin/comment_mailer_test.rb +35 -0
  350. data/test/mailers/workarea/admin/status_report_mailer_test.rb +30 -25
  351. data/test/system/workarea/admin/alerts_system_test.rb +2 -1
  352. data/test/system/workarea/admin/bulk_actions_system_test.rb +1 -1
  353. data/test/system/workarea/admin/comments_system_test.rb +43 -0
  354. data/test/system/workarea/admin/content_system_test.rb +6 -0
  355. data/test/system/workarea/admin/dashboard_system_test.rb +8 -9
  356. data/test/system/workarea/admin/data_files_system_test.rb +1 -1
  357. data/test/system/workarea/admin/discounts_system_test.rb +18 -0
  358. data/test/system/workarea/admin/featured_products_system_test.rb +3 -0
  359. data/test/system/workarea/admin/fulfillment_skus_system_test.rb +48 -0
  360. data/test/system/workarea/admin/impersonation_system_test.rb +5 -2
  361. data/test/system/workarea/admin/orders_system_test.rb +32 -21
  362. data/test/system/workarea/admin/payment_transactions_system_test.rb +34 -32
  363. data/test/system/workarea/admin/releases_system_test.rb +151 -37
  364. data/test/system/workarea/admin/reports_system_test.rb +29 -0
  365. data/test/system/workarea/admin/segments_system_test.rb +124 -0
  366. data/test/system/workarea/admin/tax_categories_system_test.rb +166 -16
  367. data/test/system/workarea/admin/users_system_test.rb +15 -0
  368. data/test/view_models/workarea/admin/changeset_view_model_test.rb +59 -9
  369. data/test/view_models/workarea/admin/code_list_view_model_test.rb +0 -5
  370. data/test/view_models/workarea/admin/content_view_model_test.rb +13 -11
  371. data/test/view_models/workarea/admin/insights/product_view_model_test.rb +4 -4
  372. data/test/view_models/workarea/admin/insights/segment_view_model_test.rb +73 -0
  373. data/test/view_models/workarea/admin/product_rules_preview_view_model_test.rb +37 -0
  374. data/test/view_models/workarea/admin/product_view_model_test.rb +13 -19
  375. data/test/view_models/workarea/admin/release_calendar_view_model_test.rb +16 -0
  376. data/test/view_models/workarea/admin/release_view_model_test.rb +13 -56
  377. data/test/view_models/workarea/admin/releases_feed_view_model_test.rb +8 -21
  378. data/test/view_models/workarea/admin/reports/timeline_view_model_test.rb +76 -0
  379. data/test/view_models/workarea/admin/search_analysis_view_model_test.rb +14 -16
  380. data/test/view_models/workarea/admin/timeline_view_model_test.rb +1 -1
  381. metadata +128 -17
  382. data/app/views/workarea/admin/featured_products/_release_preview_warning.html.haml +0 -4
  383. data/app/views/workarea/admin/releases/calendar.html.haml +0 -54
  384. data/test/dummy/tmp/screenshots/.keep +0 -0
  385. data/test/helpers/workarea/admin/content_helper_test.rb +0 -17
  386. data/test/integration/workarea/admin/index_tracking_integration_test.rb +0 -21
  387. data/test/javascripts/fixtures/existing_navigation_taxon.html.haml +0 -10
  388. data/test/view_models/workarea/admin/pricing_sku_view_model_test.rb +0 -84
@@ -52,20 +52,70 @@ module Workarea
52
52
  end
53
53
 
54
54
  def test_old_value_for
55
+ Sidekiq::Testing.fake! # setting publish_at will schedule the job, which runs inline
56
+
57
+ @release.update_attributes!(publish_at: nil)
55
58
  @releasable.update_attributes!(name: 'foo')
56
- @changeset.update_attributes!(changeset: { 'name' => 'bar' })
59
+ @release.as_current { @releasable.update_attributes!(name: 'bar') }
60
+ changeset = @releasable.changesets.first
57
61
 
58
- assert_equal('foo', @view_model.old_value_for('name'))
62
+ view_model = ChangesetViewModel.wrap(changeset)
63
+ assert_equal('foo', view_model.old_value_for('name'))
64
+ assert_equal('foo', @releasable.name)
59
65
 
60
- @changeset.update_attributes!(
61
- changeset: { 'name' => 'baz' },
62
- undo: { 'name' => 'bar' }
63
- )
66
+ @release.update_attributes!(publish_at: 1.week.from_now)
67
+ view_model = ChangesetViewModel.wrap(changeset.reload)
68
+ assert_equal('foo', view_model.old_value_for('name'))
69
+ assert_equal('foo', @releasable.name)
70
+
71
+ previous = create_release(publish_at: 1.day.from_now)
72
+ previous.as_current { @releasable.update_attributes!(name: 'baz') }
73
+
74
+ view_model = ChangesetViewModel.wrap(changeset.reload)
75
+ assert_equal('baz', view_model.old_value_for('name'))
76
+ assert_equal('foo', @releasable.name)
77
+
78
+ undo = create_release(undoes: @release)
79
+ undo_changeset = @release.changesets.first.build_undo(release: undo).tap(&:save!)
64
80
 
65
- assert_equal('bar', @view_model.old_value_for('name'))
81
+ view_model = ChangesetViewModel.wrap(changeset.reload)
82
+ assert_equal('baz', view_model.old_value_for('name'))
83
+ assert_equal('foo', @releasable.name)
84
+
85
+ @release.update_attributes!(publish_at: nil)
86
+ view_model = ChangesetViewModel.wrap(changeset.reload)
87
+ assert_equal('foo', view_model.old_value_for('name'))
88
+ assert_equal('foo', @releasable.name)
89
+
90
+ undo.update_attributes!(publish_at: 1.week.from_now)
91
+ view_model = ChangesetViewModel.wrap(changeset.reload)
92
+ assert_equal('foo', view_model.old_value_for('name'))
93
+ assert_equal('foo', @releasable.name)
94
+
95
+ undo.update_attributes!(publish_at: 1.week.from_now)
96
+ view_model = ChangesetViewModel.wrap(undo_changeset.reload)
97
+ assert_equal('baz', view_model.old_value_for('name'))
98
+ assert_equal('foo', @releasable.name)
99
+
100
+ @release.update_attributes!(publish_at: 1.day.from_now)
101
+ view_model = ChangesetViewModel.wrap(undo_changeset.reload)
102
+ assert_equal('bar', view_model.old_value_for('name'))
103
+ assert_equal('foo', @releasable.name)
104
+
105
+ undo.update_attributes!(publish_at: nil)
106
+ view_model = ChangesetViewModel.wrap(undo_changeset.reload)
107
+ assert_equal('bar', view_model.old_value_for('name'))
108
+ assert_equal('foo', @releasable.name)
109
+
110
+ @release.update_attributes!(publish_at: nil)
111
+ view_model = ChangesetViewModel.wrap(undo_changeset.reload)
112
+ assert_equal('bar', view_model.old_value_for('name'))
113
+ assert_equal('foo', @releasable.name)
114
+ end
66
115
 
67
- @changeset.update_attributes!(undo: { 'name' => { 'en' => 'baz' } })
68
- assert_equal('baz', @view_model.old_value_for('name'))
116
+ def test_missing_root
117
+ @releasable.destroy
118
+ assert_nil(@view_model.root)
69
119
  end
70
120
  end
71
121
  end
@@ -21,11 +21,6 @@ module Workarea
21
21
 
22
22
  view_model = CodeListViewModel.wrap(code_list)
23
23
  assert_equal(1, view_model.used_count)
24
-
25
- code_list.promo_codes.create!(code: "#{code_list.prefix}123")
26
-
27
- view_model = CodeListViewModel.wrap(code_list)
28
- assert_equal(1, view_model.used_count)
29
24
  end
30
25
 
31
26
  def test_last_used_at
@@ -13,17 +13,6 @@ module Workarea
13
13
  view_model.areas
14
14
  )
15
15
 
16
- Workarea.with_config do |config|
17
- config.content_areas['landing'] = %w(top bottom)
18
- model = Content.new(contentable: create_page(template: 'landing'))
19
- view_model = ContentViewModel.new(model)
20
-
21
- assert_equal(
22
- %w(top bottom),
23
- view_model.areas
24
- )
25
- end
26
-
27
16
  model = Content.new(contentable: create_category)
28
17
  view_model = ContentViewModel.new(model)
29
18
 
@@ -39,6 +28,15 @@ module Workarea
39
28
  Workarea.config.content_areas['generic'],
40
29
  view_model.areas
41
30
  )
31
+
32
+ Workarea.config.content_areas['landing'] = %w(top bottom)
33
+ model = Content.new(contentable: create_page(template: 'landing'))
34
+ view_model = ContentViewModel.new(model)
35
+
36
+ assert_equal(
37
+ %w(top bottom),
38
+ view_model.areas
39
+ )
42
40
  end
43
41
 
44
42
  def test_new_block
@@ -98,6 +96,10 @@ module Workarea
98
96
  og_asset = view_model.open_graph_asset
99
97
  assert(og_asset.open_graph_placeholder?)
100
98
 
99
+ default_asset = create_asset(tag_list: 'og-default')
100
+ view_model = ContentViewModel.wrap(content)
101
+ assert_equal(default_asset, view_model.open_graph_asset)
102
+
101
103
  content.update_attributes(open_graph_asset_id: create_asset.id)
102
104
  view_model = ContentViewModel.wrap(content)
103
105
  og_asset = view_model.open_graph_asset
@@ -77,13 +77,13 @@ module Workarea
77
77
 
78
78
  product = create_product(id: 'foo')
79
79
  view_model = ProductViewModel.wrap(product, starts_at: '2018-10-28', ends_at: '2018-10-29')
80
- assert_equal(5.8, view_model.average_price)
81
- assert_equal(5.0, view_model.previous_average_price)
80
+ assert_equal(11.6, view_model.average_price)
81
+ assert_equal(10, view_model.previous_average_price)
82
82
  assert_in_delta(15.999, view_model.average_price_percent_change)
83
83
 
84
84
  view_model = ProductViewModel.wrap(product, starts_at: '2018-10-29', ends_at: '2018-10-30')
85
- assert_equal(5.5, view_model.average_price)
86
- assert_in_delta(5.833, view_model.previous_average_price)
85
+ assert_equal(11, view_model.average_price)
86
+ assert_in_delta(11.666, view_model.previous_average_price)
87
87
  assert_in_delta(-5.714, view_model.average_price_percent_change)
88
88
  end
89
89
  end
@@ -0,0 +1,73 @@
1
+ require 'test_helper'
2
+
3
+ module Workarea
4
+ module Admin
5
+ module Insights
6
+ class SegmentViewModelTest < TestCase
7
+ def test_average_order_value
8
+ segment = create_segment
9
+
10
+ Metrics::SegmentByDay.inc(
11
+ key: { segment_id: segment.id },
12
+ at: Time.zone.local(2018, 10, 26),
13
+ orders: 1,
14
+ revenue: 10.to_m
15
+ )
16
+
17
+ Metrics::SegmentByDay.inc(
18
+ key: { segment_id: segment.id },
19
+ at: Time.zone.local(2018, 10, 27),
20
+ orders: 1,
21
+ revenue: 10.to_m
22
+ )
23
+
24
+ Metrics::SegmentByDay.inc(
25
+ key: { segment_id: segment.id },
26
+ at: Time.zone.local(2018, 10, 28),
27
+ orders: 2,
28
+ revenue: 15.to_m
29
+ )
30
+
31
+ Metrics::SegmentByDay.inc(
32
+ key: { segment_id: segment.id },
33
+ at: Time.zone.local(2018, 10, 29),
34
+ orders: 3,
35
+ revenue: 27.to_m
36
+ )
37
+
38
+ Metrics::SegmentByDay.inc(
39
+ key: { segment_id: 'bar' },
40
+ at: Time.zone.local(2018, 10, 27),
41
+ orders: 2,
42
+ revenue: 11.to_m
43
+ )
44
+
45
+ Metrics::SegmentByDay.inc(
46
+ key: { segment_id: 'bar' },
47
+ at: Time.zone.local(2018, 10, 28),
48
+ orders: 3,
49
+ revenue: 15.to_m
50
+ )
51
+
52
+ Metrics::SegmentByDay.inc(
53
+ key: { segment_id: 'bar' },
54
+ at: Time.zone.local(2018, 10, 29),
55
+ orders: 4,
56
+ revenue: 27.to_m
57
+ )
58
+
59
+
60
+ view_model = SegmentViewModel.wrap(segment, starts_at: '2018-10-28', ends_at: '2018-10-29')
61
+ assert_equal(8.4, view_model.average_order_value)
62
+ assert_equal(10, view_model.previous_average_order_value)
63
+ assert_in_delta(-15.999, view_model.average_order_value_percent_change)
64
+
65
+ view_model = SegmentViewModel.wrap(segment, starts_at: '2018-10-29', ends_at: '2018-10-30')
66
+ assert_equal(9, view_model.average_order_value)
67
+ assert_in_delta(8.333, view_model.previous_average_order_value)
68
+ assert_in_delta(7.999, view_model.average_order_value_percent_change)
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,37 @@
1
+ require 'test_helper'
2
+
3
+ module Workarea
4
+ module Admin
5
+ class ProductRulesPreviewViewModelTest < TestCase
6
+ def test_only_uses_active_rules
7
+ customization = create_search_customization(
8
+ id: 'foo',
9
+ product_rules: [
10
+ { name: 'excluded_products', operator: 'equals', value: '1' },
11
+ { name: 'excluded_products', operator: 'equals', value: '2', active: false }
12
+ ]
13
+ )
14
+
15
+ view_model = ProductRulesPreviewViewModel.wrap(customization)
16
+ assert(view_model.display_results?)
17
+ assert_equal(customization.product_rules.take(1), view_model.search.params[:rules])
18
+
19
+ category = create_category(
20
+ product_rules: [
21
+ { name: 'excluded_products', operator: 'equals', value: '1' },
22
+ { name: 'excluded_products', operator: 'equals', value: '2', active: false }
23
+ ]
24
+ )
25
+
26
+ view_model = ProductRulesPreviewViewModel.wrap(category)
27
+ assert(view_model.display_results?)
28
+ assert_equal(category.product_rules.take(1), view_model.search.params[:rules])
29
+
30
+ category.product_rules.first.update!(active: false)
31
+ view_model = ProductRulesPreviewViewModel.wrap(category)
32
+ refute(view_model.display_results?)
33
+ assert_empty(view_model.search.params[:rules])
34
+ end
35
+ end
36
+ end
37
+ end
@@ -14,16 +14,14 @@ module Workarea
14
14
  end
15
15
 
16
16
  def test_templates_includes_template_options_without_test
17
- Workarea.with_config do |config|
18
- config.product_templates = [:foo, :test]
19
- assert_equal(
20
- [['Generic', 'generic'], ['Foo', 'foo']],
21
- @view_model.templates
22
- )
23
- end
17
+ Workarea.config.product_templates = [:foo, :test]
18
+ assert_equal(
19
+ [['Generic', 'generic'], ['Foo', 'foo']],
20
+ @view_model.templates
21
+ )
24
22
  end
25
23
 
26
- def test_variant_details
24
+ def test_options
27
25
  @view_model.variants.build(
28
26
  sku: 'SKU1',
29
27
  name: 'name',
@@ -42,7 +40,7 @@ module Workarea
42
40
 
43
41
  assert_equal(
44
42
  { 'Color' => ['Red', 'Black', 'White'], 'Size' => ['S', 'M', 'L'] },
45
- @view_model.variant_details
43
+ @view_model.options
46
44
  )
47
45
  end
48
46
 
@@ -60,16 +58,12 @@ module Workarea
60
58
  end
61
59
 
62
60
  def test_customization_options
63
- Workarea.with_config do |config|
64
- config.customization_types = []
65
- assert_equal([['None', nil]], @view_model.customization_options)
66
- end
67
-
68
- Workarea.with_config do |config|
69
- config.customization_types = [FooBar]
70
- customizations = @view_model.customization_options
71
- assert_equal([['None', nil], ['Foo Bar', 'foo_bar']], customizations)
72
- end
61
+ Workarea.config.customization_types = []
62
+ assert_equal([['None', nil]], @view_model.customization_options)
63
+
64
+ Workarea.config.customization_types = [FooBar]
65
+ customizations = @view_model.customization_options
66
+ assert_equal([['None', nil], ['Foo Bar', 'foo_bar']], customizations)
73
67
  end
74
68
 
75
69
  def test_pricing
@@ -31,6 +31,22 @@ module Workarea
31
31
  assert_equal(@release.id, day.first.id)
32
32
  end
33
33
 
34
+ def test_days_sorts_results
35
+ travel_to Time.zone.local(2019, 6, 24, 9, 35)
36
+
37
+ @release.update_attributes!(name: 'Third', publish_at: 3.hours.from_now)
38
+ create_release(name: 'First', published_at: 1.hour.ago)
39
+ create_release(name: 'Second', publish_at: 2.hours.from_now)
40
+
41
+ view_model = ReleaseCalendarViewModel.wrap(@release)
42
+ day = view_model.days[(@release.publish_at).strftime('%Y-%m-%d').to_s]
43
+
44
+ assert_equal(3, day.length)
45
+ assert_equal('First', day.first.name)
46
+ assert_equal('Second', day.second.name)
47
+ assert_equal('Third', day.third.name)
48
+ end
49
+
34
50
  def test_prev_week
35
51
  view_model = ReleaseCalendarViewModel.new(@release)
36
52
  assert_equal(Time.zone.today - 1.week, view_model.prev_week)
@@ -3,76 +3,33 @@ require 'test_helper'
3
3
  module Workarea
4
4
  module Admin
5
5
  class ReleaseViewModelTest < TestCase
6
- setup :set_release
6
+ def test_calendar_on_returns_the_rescheduled_date
7
+ release = create_release
7
8
 
8
- def set_release
9
- @release = create_release
10
- end
11
-
12
- def test_published_on_date_returns_true_if_the_release_was_published_on_the_supplied_date
13
- @release.published_at = Time.current
14
- @release.save!
15
-
16
- view_model = ReleaseViewModel.new(@release)
17
- assert(view_model.published_on_date?(Date.current))
18
- end
19
-
20
- def test_published_on_returns_true_if_the_release_was_scheduled_for_the_supplied_date
21
- @release.publish_at = Time.current + 1.day
22
- @release.save!
23
-
24
- view_model = ReleaseViewModel.new(@release)
25
- assert(view_model.published_on_date?(Date.current + 1.day))
26
- end
27
-
28
- def test_ended_on_date
29
- @release.published_at = Time.current
30
- @release.undo_at = Time.current + 1.month
31
- @release.save!
32
-
33
- view_model = ReleaseViewModel.new(@release)
34
- assert(view_model.ended_on_date?(Date.current + 1.month))
35
- end
36
-
37
- def test_content_release
38
- view_model = ReleaseViewModel.new(@release)
39
- assert(view_model.content_release?)
40
- end
41
-
42
- def test_publish_time_returns_the_rescheduled_publish_time
43
- now = Time.current
44
-
45
- @release.published_at = now - 1.month
46
- @release.publish_at = now + 1.month
47
- @release.save!
48
-
49
- view_model = ReleaseViewModel.new(@release)
50
- assert_equal(now + 1.month, view_model.publish_time)
51
- end
52
-
53
- def test_publish_time_returns_the_time_it_was_published_if_not_rescheduled
54
- now = Time.current
55
-
56
- @release.published_at = now - 1.month
57
- @release.save!
9
+ release.published_at = Date.current - 1.month
10
+ release.publish_at = Date.current + 1.month
11
+ view_model = ReleaseViewModel.wrap(release)
12
+ assert_equal(Date.current + 1.month, view_model.calendar_on)
58
13
 
59
- view_model = ReleaseViewModel.new(@release)
60
- assert_equal(now - 1.month, view_model.publish_time)
14
+ release.publish_at = nil
15
+ view_model = ReleaseViewModel.wrap(release)
16
+ assert_equal(Date.current - 1.month, view_model.calendar_on)
61
17
  end
62
18
 
63
19
  def test_nil_changesets_are_excluded_from_changesets_with_releasable
20
+ release = create_release
64
21
  pricing_sku = create_pricing_sku(prices: [{ regular: 3, sale: 1, min_quantity: 1 }])
65
22
  releasable = pricing_sku.prices.first
66
23
  releasable.changesets.create!(
67
- release: @release,
24
+ release: release,
68
25
  document_path: releasable.document_path
69
26
  )
70
27
 
71
- view_model = ReleaseViewModel.new(@release)
28
+ view_model = ReleaseViewModel.new(release)
72
29
  assert_equal(view_model.changesets_with_releasable.length, 1)
73
30
 
74
31
  pricing_sku.prices.first.delete
75
- view_model = ReleaseViewModel.new(@release)
32
+ view_model = ReleaseViewModel.new(release)
76
33
  assert_empty(view_model.changesets_with_releasable)
77
34
  end
78
35
  end
@@ -4,35 +4,22 @@ module Workarea
4
4
  module Admin
5
5
  class ReleasesFeedViewModelTest < TestCase
6
6
  def test_calendar
7
- foo_publish_at = 1.hour.from_now
8
- foo_undo_at = 2.hours.from_now
9
- foo_release = create_release(
10
- name: 'Foo',
11
- publish_at: foo_publish_at,
12
- undo_at: foo_undo_at
13
- )
7
+ foo_release = create_release(name: 'Foo', publish_at: 1.hour.from_now)
8
+ bar_release = create_release(name: 'Bar', publish_at: 1.week.from_now)
14
9
 
15
- bar_publish_at = 1.week.from_now
16
- bar_undo_at = 2.weeks.from_now
17
- bar_release = create_release(
18
- name: 'Bar',
19
- publish_at: bar_publish_at,
20
- undo_at: bar_undo_at
21
- )
22
-
23
- vm = ReleasesFeedViewModel.wrap(nil)
24
- feed = vm.calendar
10
+ view_model = ReleasesFeedViewModel.new
11
+ feed = view_model.calendar
25
12
 
26
13
  assert_equal(2, feed.events.length)
27
14
 
28
15
  assert_equal('Foo', feed.events.first.summary)
29
16
  assert_equal('Bar', feed.events.second.summary)
30
17
 
31
- assert_equal(foo_publish_at.to_s, feed.events.first.dtstart.to_s)
32
- assert_equal(foo_undo_at.to_s, feed.events.first.dtend.to_s)
18
+ assert_equal(foo_release.publish_at.to_s, feed.events.first.dtstart.to_s)
19
+ assert(feed.events.first.dtend.present?)
33
20
 
34
- assert_equal(bar_publish_at.to_date.to_s, feed.events.second.dtstart.to_s)
35
- assert_equal(bar_undo_at.to_date.to_s, feed.events.second.dtend.to_s)
21
+ assert_equal(bar_release.publish_at.to_s, feed.events.second.dtstart.to_s)
22
+ assert(feed.events.second.dtend.present?)
36
23
  end
37
24
  end
38
25
  end
@@ -0,0 +1,76 @@
1
+ require 'test_helper'
2
+
3
+ module Workarea
4
+ module Admin
5
+ module Reports
6
+ class TimelineViewModelTest < TestCase
7
+ setup :create_metrics
8
+
9
+ def create_metrics
10
+ Metrics::SalesByDay.inc(
11
+ at: Time.zone.local(2018, 1, 1),
12
+ revenue: 14.99,
13
+ orders: 10,
14
+ units_sold: 15,
15
+ customers: 3
16
+ )
17
+
18
+ Metrics::SalesByDay.inc(
19
+ at: Time.zone.local(2018, 1, 2),
20
+ revenue: 34.22,
21
+ orders: 5,
22
+ units_sold: 9,
23
+ customers: 13
24
+ )
25
+
26
+ create_release(published_at: Time.zone.local(2018, 1, 1))
27
+
28
+ travel_to Time.zone.local(2018, 1, 3)
29
+ end
30
+
31
+ def test_summary_data
32
+ report = Workarea::Reports::SalesOverTime.new(
33
+ starts_at: 2.days.ago,
34
+ group_by: 'day'
35
+ )
36
+
37
+ view_model = TimelineViewModel.wrap(report)
38
+
39
+ assert_equal(14.99 + 34.22, view_model.summary[:revenue])
40
+ assert_equal(15, view_model.summary[:orders])
41
+ assert_equal(24, view_model.summary[:units_sold])
42
+ assert_equal(16, view_model.summary[:customers])
43
+ assert_equal(1, view_model.summary[:releases])
44
+ end
45
+
46
+ def test_graph_data
47
+ report = Workarea::Reports::SalesOverTime.new(
48
+ starts_at: 2.days.ago,
49
+ group_by: 'day'
50
+ )
51
+
52
+ view_model = TimelineViewModel.wrap(report)
53
+
54
+ labels = view_model.graph_data[:labels]
55
+ assert_equal(3, labels.size)
56
+
57
+ assert_equal(Time.zone.local(2018, 1, 3).to_date, labels.first)
58
+ assert_equal(Time.zone.local(2018, 1, 2).to_date, labels.second)
59
+ assert_equal(Time.zone.local(2018, 1, 1).to_date, labels.third)
60
+
61
+ datasets = view_model.graph_data[:datasets]
62
+ assert_equal({ x: labels.third.to_time, y: 14.99 }, datasets[:revenue].third)
63
+ assert_equal({ x: labels.second.to_time, y: 34.22 }, datasets[:revenue].second)
64
+ assert_equal({ x: labels.third.to_time, y: 10 }, datasets[:orders].third)
65
+ assert_equal({ x: labels.second.to_time, y: 5 }, datasets[:orders].second)
66
+ assert_equal({ x: labels.third.to_time, y: 15 }, datasets[:units_sold].third)
67
+ assert_equal({ x: labels.second.to_time, y: 9 }, datasets[:units_sold].second)
68
+ assert_equal({ x: labels.third.to_time, y: 3 }, datasets[:customers].third)
69
+ assert_equal({ x: labels.second.to_time, y: 13 }, datasets[:customers].second)
70
+ assert_equal({ x: labels.third.to_time, y: 1 }, datasets[:releases].third)
71
+ assert_equal({ x: labels.second.to_time, y: 0 }, datasets[:releases].second)
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
@@ -39,24 +39,22 @@ module Workarea
39
39
  BulkIndexProducts.perform
40
40
  view_model = SearchAnalysisViewModel.wrap(customization)
41
41
 
42
- Workarea.with_config do |config|
43
- config.storefront_search_middleware = SwappableList.new(
44
- %w(
45
- Workarea::Search::StorefrontSearch::Redirect
46
- Workarea::Search::StorefrontSearch::ExactMatches
47
- Workarea::Search::StorefrontSearch::ProductMultipass
48
- Workarea::Search::StorefrontSearch::SpellingCorrection
49
- Workarea::Search::StorefrontSearch::Template
50
- )
42
+ Workarea.config.storefront_search_middleware = SwappableList.new(
43
+ %w(
44
+ Workarea::Search::StorefrontSearch::Redirect
45
+ Workarea::Search::StorefrontSearch::ExactMatches
46
+ Workarea::Search::StorefrontSearch::ProductMultipass
47
+ Workarea::Search::StorefrontSearch::SpellingCorrection
48
+ Workarea::Search::StorefrontSearch::Template
51
49
  )
50
+ )
52
51
 
53
- assert_equal(5, view_model.middleware.size)
54
- assert_equal(:pass, view_model.middleware[Search::StorefrontSearch::Redirect])
55
- assert_equal(:last, view_model.middleware[Search::StorefrontSearch::ExactMatches])
56
- assert_equal(:ignore, view_model.middleware[Search::StorefrontSearch::ProductMultipass])
57
- assert_equal(:ignore, view_model.middleware[Search::StorefrontSearch::SpellingCorrection])
58
- assert_equal(:ignore, view_model.middleware[Search::StorefrontSearch::Template])
59
- end
52
+ assert_equal(5, view_model.middleware.size)
53
+ assert_equal(:pass, view_model.middleware[Search::StorefrontSearch::Redirect])
54
+ assert_equal(:last, view_model.middleware[Search::StorefrontSearch::ExactMatches])
55
+ assert_equal(:ignore, view_model.middleware[Search::StorefrontSearch::ProductMultipass])
56
+ assert_equal(:ignore, view_model.middleware[Search::StorefrontSearch::SpellingCorrection])
57
+ assert_equal(:ignore, view_model.middleware[Search::StorefrontSearch::Template])
60
58
  end
61
59
 
62
60
  def test_tokens
@@ -16,7 +16,7 @@ module Workarea
16
16
  assert_equal(view_model.upcoming_changesets.first.release_id, release.id)
17
17
 
18
18
  release = create_release(name: 'Bar', publish_at: 4.days.from_now)
19
- release.as_current { @releasable.update_attributes!(name: 'Changed') }
19
+ release.as_current { @releasable.update_attributes!(name: 'Changed Again') }
20
20
 
21
21
  view_model = TimelineViewModel.new(@releasable)
22
22
  assert_equal(view_model.upcoming_changesets.length, 2)