spree_backend 3.1.14 → 3.2.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (309) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/admin/logo.png +0 -0
  3. data/app/assets/javascripts/spree/backend/admin.js +2 -25
  4. data/app/assets/javascripts/spree/backend/checkouts/edit.js +2 -1
  5. data/app/assets/javascripts/spree/backend/line_items.js.coffee +2 -2
  6. data/app/assets/javascripts/spree/backend/line_items_on_order_edit.js +5 -2
  7. data/app/assets/javascripts/spree/backend/option_type_autocomplete.js +2 -2
  8. data/app/assets/javascripts/spree/backend/option_value_picker.js +2 -2
  9. data/app/assets/javascripts/spree/backend/payments/edit.js.coffee +10 -8
  10. data/app/assets/javascripts/spree/backend/product_picker.js +3 -2
  11. data/app/assets/javascripts/spree/backend/{shipments.js.erb → shipments.js} +1 -1
  12. data/app/assets/javascripts/spree/backend/states.js +9 -7
  13. data/app/assets/javascripts/spree/backend/stock_location.js +3 -0
  14. data/app/assets/javascripts/spree/backend/tag_picker.js +52 -0
  15. data/app/assets/javascripts/spree/backend/taxon_autocomplete.js +2 -2
  16. data/app/assets/javascripts/spree/backend/taxon_permalink_preview.js +12 -0
  17. data/app/assets/javascripts/spree/backend/taxonomy.js.coffee +2 -2
  18. data/app/assets/javascripts/spree/backend/taxons.js.coffee +1 -1
  19. data/app/assets/javascripts/spree/backend/user_picker.js +4 -3
  20. data/app/assets/javascripts/spree/backend.js +8 -7
  21. data/app/assets/stylesheets/spree/backend/components/_main.scss +5 -1
  22. data/app/assets/stylesheets/spree/backend/components/_sidebar.scss +7 -0
  23. data/app/assets/stylesheets/spree/backend/shared/_forms.scss +1 -1
  24. data/app/assets/stylesheets/spree/backend/spree_admin.css.scss +0 -1
  25. data/app/controllers/spree/admin/base_controller.rb +0 -11
  26. data/app/controllers/spree/admin/option_types_controller.rb +2 -14
  27. data/app/controllers/spree/admin/option_values_controller.rb +1 -1
  28. data/app/controllers/spree/admin/orders_controller.rb +7 -7
  29. data/app/controllers/spree/admin/payment_methods_controller.rb +4 -0
  30. data/app/controllers/spree/admin/product_properties_controller.rb +1 -1
  31. data/app/controllers/spree/admin/products_controller.rb +1 -1
  32. data/app/controllers/spree/admin/promotion_actions_controller.rb +5 -5
  33. data/app/controllers/spree/admin/promotion_rules_controller.rb +6 -6
  34. data/app/controllers/spree/admin/promotions_controller.rb +2 -2
  35. data/app/controllers/spree/admin/properties_controller.rb +1 -1
  36. data/app/controllers/spree/admin/prototypes_controller.rb +2 -2
  37. data/app/controllers/spree/admin/refunds_controller.rb +1 -1
  38. data/app/controllers/spree/admin/reimbursement_types_controller.rb +26 -0
  39. data/app/controllers/spree/admin/reimbursements_controller.rb +1 -1
  40. data/app/controllers/spree/admin/reports_controller.rb +1 -1
  41. data/app/controllers/spree/admin/resource_controller.rb +8 -8
  42. data/app/controllers/spree/admin/return_authorizations_controller.rb +3 -3
  43. data/app/controllers/spree/admin/return_index_controller.rb +1 -1
  44. data/app/controllers/spree/admin/shipping_methods_controller.rb +2 -2
  45. data/app/controllers/spree/admin/states_controller.rb +1 -1
  46. data/app/controllers/spree/admin/stock_items_controller.rb +2 -2
  47. data/app/controllers/spree/admin/stock_movements_controller.rb +1 -5
  48. data/app/controllers/spree/admin/store_credits_controller.rb +1 -1
  49. data/app/controllers/spree/admin/taxons_controller.rb +1 -10
  50. data/app/controllers/spree/admin/users_controller.rb +5 -41
  51. data/app/controllers/spree/admin/variants_controller.rb +3 -1
  52. data/app/helpers/spree/admin/base_helper.rb +1 -6
  53. data/app/helpers/spree/admin/navigation_helper.rb +9 -31
  54. data/app/helpers/spree/admin/promotion_rules_helper.rb +12 -0
  55. data/app/views/kaminari/_first_page.html.erb +1 -1
  56. data/app/views/kaminari/_last_page.html.erb +1 -1
  57. data/app/views/kaminari/_next_page.html.erb +1 -1
  58. data/app/views/kaminari/_page.html.erb +1 -1
  59. data/app/views/kaminari/_paginator.html.erb +2 -4
  60. data/app/views/kaminari/_prev_page.html.erb +1 -1
  61. data/app/views/spree/admin/adjustments/_adjustments_table.html.erb +1 -1
  62. data/app/views/spree/admin/adjustments/_form.html.erb +4 -4
  63. data/app/views/spree/admin/countries/_form.html.erb +2 -2
  64. data/app/views/spree/admin/countries/edit.html.erb +3 -3
  65. data/app/views/spree/admin/countries/index.html.erb +3 -3
  66. data/app/views/spree/admin/countries/new.html.erb +3 -3
  67. data/app/views/spree/admin/customer_returns/new.html.erb +1 -1
  68. data/app/views/spree/admin/images/_form.html.erb +2 -2
  69. data/app/views/spree/admin/option_types/_form.html.erb +2 -2
  70. data/app/views/spree/admin/option_types/edit.html.erb +5 -5
  71. data/app/views/spree/admin/option_types/new.html.erb +3 -3
  72. data/app/views/spree/admin/orders/_adjustments.html.erb +6 -4
  73. data/app/views/spree/admin/orders/_form.html.erb +1 -1
  74. data/app/views/spree/admin/orders/_line_items.html.erb +8 -6
  75. data/app/views/spree/admin/orders/_line_items_edit_form.html.erb +1 -1
  76. data/app/views/spree/admin/orders/_shipment.html.erb +9 -7
  77. data/app/views/spree/admin/orders/cart.html.erb +0 -4
  78. data/app/views/spree/admin/orders/edit.html.erb +0 -4
  79. data/app/views/spree/admin/orders/index.html.erb +20 -20
  80. data/app/views/spree/admin/payment_methods/_form.html.erb +5 -5
  81. data/app/views/spree/admin/payment_methods/index.html.erb +3 -3
  82. data/app/views/spree/admin/payments/_form.html.erb +6 -6
  83. data/app/views/spree/admin/payments/source_forms/_gateway.html.erb +6 -6
  84. data/app/views/spree/admin/products/_form.html.erb +14 -8
  85. data/app/views/spree/admin/products/_properties_form.erb +1 -1
  86. data/app/views/spree/admin/products/index.html.erb +6 -6
  87. data/app/views/spree/admin/products/new.html.erb +16 -16
  88. data/app/views/spree/admin/promotion_categories/_form.html.erb +3 -3
  89. data/app/views/spree/admin/promotion_categories/edit.html.erb +3 -3
  90. data/app/views/spree/admin/promotion_categories/index.html.erb +3 -3
  91. data/app/views/spree/admin/promotion_categories/new.html.erb +3 -3
  92. data/app/views/spree/admin/promotions/_actions.html.erb +4 -4
  93. data/app/views/spree/admin/promotions/_form.html.erb +10 -10
  94. data/app/views/spree/admin/promotions/_promotion_rule.html.erb +1 -1
  95. data/app/views/spree/admin/promotions/_rules.html.erb +4 -4
  96. data/app/views/spree/admin/promotions/actions/_create_adjustment.html.erb +1 -1
  97. data/app/views/spree/admin/promotions/actions/_create_item_adjustments.html.erb +2 -2
  98. data/app/views/spree/admin/promotions/actions/_create_line_items.html.erb +1 -1
  99. data/app/views/spree/admin/promotions/edit.html.erb +6 -6
  100. data/app/views/spree/admin/promotions/index.html.erb +5 -5
  101. data/app/views/spree/admin/promotions/new.html.erb +3 -3
  102. data/app/views/spree/admin/promotions/rules/_country.html.erb +6 -0
  103. data/app/views/spree/admin/promotions/rules/_landing_page.html.erb +1 -1
  104. data/app/views/spree/admin/promotions/rules/_product.html.erb +2 -2
  105. data/app/views/spree/admin/promotions/rules/_taxon.html.erb +2 -2
  106. data/app/views/spree/admin/properties/_form.html.erb +2 -2
  107. data/app/views/spree/admin/properties/edit.html.erb +3 -3
  108. data/app/views/spree/admin/properties/index.html.erb +6 -6
  109. data/app/views/spree/admin/prototypes/_prototypes.html.erb +1 -1
  110. data/app/views/spree/admin/prototypes/available.js.erb +1 -1
  111. data/app/views/spree/admin/prototypes/edit.html.erb +3 -3
  112. data/app/views/spree/admin/prototypes/index.html.erb +3 -3
  113. data/app/views/spree/admin/prototypes/new.html.erb +3 -3
  114. data/app/views/spree/admin/prototypes/show.html.erb +1 -1
  115. data/app/views/spree/admin/refunds/edit.html.erb +2 -0
  116. data/app/views/spree/admin/refunds/new.html.erb +2 -0
  117. data/app/views/spree/admin/reimbursement_types/_form.html.erb +32 -0
  118. data/app/views/spree/admin/reimbursement_types/edit.html.erb +11 -0
  119. data/app/views/spree/admin/reimbursement_types/index.html.erb +9 -0
  120. data/app/views/spree/admin/reimbursement_types/new.html.erb +11 -0
  121. data/app/views/spree/admin/reimbursements/edit.html.erb +1 -1
  122. data/app/views/spree/admin/reports/sales_total.html.erb +1 -1
  123. data/app/views/spree/admin/return_authorizations/_form.html.erb +4 -4
  124. data/app/views/spree/admin/return_index/customer_returns.html.erb +1 -2
  125. data/app/views/spree/admin/return_index/return_authorizations.html.erb +4 -4
  126. data/app/views/spree/admin/roles/edit.html.erb +1 -1
  127. data/app/views/spree/admin/roles/new.html.erb +1 -1
  128. data/app/views/spree/admin/shared/_calculator_fields.html.erb +2 -2
  129. data/app/views/spree/admin/shared/_destroy.js.erb +1 -1
  130. data/app/views/spree/admin/shared/_edit_resource_links.html.erb +2 -2
  131. data/app/views/spree/admin/shared/_head.html.erb +2 -1
  132. data/app/views/spree/admin/shared/_header.html.erb +4 -11
  133. data/app/views/spree/admin/shared/_index_table_options.html.erb +1 -1
  134. data/app/views/spree/admin/shared/_main_menu.html.erb +6 -0
  135. data/app/views/spree/admin/shared/_new_resource_links.html.erb +2 -2
  136. data/app/views/spree/admin/shared/_order_summary.html.erb +3 -3
  137. data/app/views/spree/admin/shared/_refunds.html.erb +1 -1
  138. data/app/views/spree/admin/shared/_report_order_criteria.html.erb +3 -3
  139. data/app/views/spree/admin/shared/_translations.html.erb +38 -38
  140. data/app/views/spree/admin/shared/{_update_order_state.js → _update_order_state.js.erb} +3 -3
  141. data/app/views/spree/admin/shared/named_types/_index.html.erb +2 -2
  142. data/app/views/spree/admin/shipping_categories/edit.html.erb +3 -3
  143. data/app/views/spree/admin/shipping_categories/index.html.erb +3 -3
  144. data/app/views/spree/admin/shipping_categories/new.html.erb +3 -3
  145. data/app/views/spree/admin/shipping_methods/_form.html.erb +14 -14
  146. data/app/views/spree/admin/shipping_methods/edit.html.erb +3 -3
  147. data/app/views/spree/admin/shipping_methods/index.html.erb +3 -3
  148. data/app/views/spree/admin/shipping_methods/new.html.erb +3 -3
  149. data/app/views/spree/admin/states/_form.html.erb +2 -2
  150. data/app/views/spree/admin/states/_state_list.html.erb +2 -2
  151. data/app/views/spree/admin/states/edit.html.erb +3 -3
  152. data/app/views/spree/admin/states/index.html.erb +3 -3
  153. data/app/views/spree/admin/states/new.html.erb +3 -3
  154. data/app/views/spree/admin/stock_locations/_form.html.erb +0 -8
  155. data/app/views/spree/admin/stock_locations/_transfer_stock_form.html.erb +1 -1
  156. data/app/views/spree/admin/stock_locations/edit.html.erb +3 -3
  157. data/app/views/spree/admin/stock_locations/index.html.erb +4 -4
  158. data/app/views/spree/admin/stock_locations/new.html.erb +3 -3
  159. data/app/views/spree/admin/stock_transfers/index.html.erb +3 -3
  160. data/app/views/spree/admin/stock_transfers/new.html.erb +1 -1
  161. data/app/views/spree/admin/stock_transfers/show.html.erb +3 -3
  162. data/app/views/spree/admin/tax_categories/_form.html.erb +7 -7
  163. data/app/views/spree/admin/tax_categories/edit.html.erb +3 -3
  164. data/app/views/spree/admin/tax_categories/new.html.erb +3 -3
  165. data/app/views/spree/admin/tax_rates/_form.html.erb +5 -5
  166. data/app/views/spree/admin/tax_rates/edit.html.erb +3 -3
  167. data/app/views/spree/admin/tax_rates/new.html.erb +3 -3
  168. data/app/views/spree/admin/taxonomies/_form.html.erb +2 -2
  169. data/app/views/spree/admin/taxonomies/_js_head.html.erb +0 -5
  170. data/app/views/spree/admin/taxonomies/new.html.erb +1 -1
  171. data/app/views/spree/admin/taxons/_form.html.erb +7 -7
  172. data/app/views/spree/admin/taxons/_taxon_table.html.erb +1 -1
  173. data/app/views/spree/admin/taxons/edit.html.erb +0 -15
  174. data/app/views/spree/admin/taxons/index.html.erb +1 -1
  175. data/app/views/spree/admin/trackers/_form.html.erb +1 -1
  176. data/app/views/spree/admin/trackers/edit.html.erb +3 -3
  177. data/app/views/spree/admin/trackers/index.html.erb +3 -3
  178. data/app/views/spree/admin/trackers/new.html.erb +3 -3
  179. data/app/views/spree/admin/users/_addresses_form.html.erb +2 -2
  180. data/app/views/spree/admin/users/_form.html.erb +3 -3
  181. data/app/views/spree/admin/users/index.html.erb +7 -7
  182. data/app/views/spree/admin/users/items.html.erb +2 -2
  183. data/app/views/spree/admin/users/new.html.erb +3 -3
  184. data/app/views/spree/admin/variants/_autocomplete_line_items_stock.js.erb +24 -7
  185. data/app/views/spree/admin/variants/_autocomplete_stock.js.erb +1 -0
  186. data/app/views/spree/admin/variants/_form.html.erb +7 -7
  187. data/app/views/spree/admin/variants/new.html.erb +3 -3
  188. data/app/views/spree/admin/zones/_country_members.html.erb +1 -1
  189. data/app/views/spree/admin/zones/_form.html.erb +6 -6
  190. data/app/views/spree/admin/zones/_state_members.html.erb +1 -1
  191. data/app/views/spree/admin/zones/edit.html.erb +3 -3
  192. data/app/views/spree/admin/zones/index.html.erb +5 -5
  193. data/app/views/spree/admin/zones/new.html.erb +3 -3
  194. data/config/routes.rb +4 -12
  195. data/lib/spree/backend/engine.rb +2 -6
  196. data/spec/controllers/spree/admin/base_controller_spec.rb +46 -0
  197. data/spec/controllers/spree/admin/customer_returns_controller_spec.rb +185 -0
  198. data/spec/controllers/spree/admin/general_settings_controller_spec.rb +41 -0
  199. data/spec/controllers/spree/admin/missing_products_controller_spec.rb +18 -0
  200. data/spec/controllers/spree/admin/orders/customer_details_controller_spec.rb +197 -0
  201. data/spec/controllers/spree/admin/orders_controller_spec.rb +296 -0
  202. data/spec/controllers/spree/admin/payment_methods_controller_spec.rb +49 -0
  203. data/spec/controllers/spree/admin/payments_controller_spec.rb +97 -0
  204. data/spec/controllers/spree/admin/products_controller_spec.rb +99 -0
  205. data/spec/controllers/spree/admin/promotion_actions_controller_spec.rb +21 -0
  206. data/spec/controllers/spree/admin/promotion_rules_controller_spec.rb +21 -0
  207. data/spec/controllers/spree/admin/promotions_controller_spec.rb +44 -0
  208. data/spec/controllers/spree/admin/refunds_controller_spec.rb +32 -0
  209. data/spec/controllers/spree/admin/reimbursements_controller_spec.rb +74 -0
  210. data/spec/controllers/spree/admin/reports_controller_spec.rb +42 -0
  211. data/spec/controllers/spree/admin/resource_controller_spec.rb +252 -0
  212. data/spec/controllers/spree/admin/return_authorizations_controller_spec.rb +225 -0
  213. data/spec/controllers/spree/admin/return_index_controller_spec.rb +37 -0
  214. data/spec/controllers/spree/admin/return_items_controller_spec.rb +27 -0
  215. data/spec/controllers/spree/admin/shipping_methods_controller_spec.rb +14 -0
  216. data/spec/controllers/spree/admin/stock_items_controller_spec.rb +19 -0
  217. data/spec/controllers/spree/admin/stock_locations_controller_spec.rb +41 -0
  218. data/spec/controllers/spree/admin/stock_transfers_controller_spec.rb +41 -0
  219. data/spec/controllers/spree/admin/tax_categories_controller_spec.rb +34 -0
  220. data/spec/controllers/spree/admin/users_controller_spec.rb +161 -0
  221. data/spec/controllers/spree/admin/variants_controller_spec.rb +32 -0
  222. data/spec/features/admin/configuration/analytics_tracker_spec.rb +47 -0
  223. data/spec/features/admin/configuration/countries_spec.rb +24 -0
  224. data/spec/features/admin/configuration/general_settings_spec.rb +44 -0
  225. data/spec/features/admin/configuration/payment_methods_spec.rb +63 -0
  226. data/spec/features/admin/configuration/roles_spec.rb +47 -0
  227. data/spec/features/admin/configuration/shipping_methods_spec.rb +62 -0
  228. data/spec/features/admin/configuration/states_spec.rb +68 -0
  229. data/spec/features/admin/configuration/stock_locations_spec.rb +48 -0
  230. data/spec/features/admin/configuration/store_credit_categories_spec.rb +50 -0
  231. data/spec/features/admin/configuration/tax_categories_spec.rb +56 -0
  232. data/spec/features/admin/configuration/tax_rates_spec.rb +18 -0
  233. data/spec/features/admin/configuration/zones_spec.rb +39 -0
  234. data/spec/features/admin/homepage_spec.rb +89 -0
  235. data/spec/features/admin/locale_spec.rb +31 -0
  236. data/spec/features/admin/orders/adjustments_promotions_spec.rb +53 -0
  237. data/spec/features/admin/orders/adjustments_spec.rb +129 -0
  238. data/spec/features/admin/orders/cancelling_and_resuming_spec.rb +47 -0
  239. data/spec/features/admin/orders/customer_details_spec.rb +154 -0
  240. data/spec/features/admin/orders/line_items_spec.rb +51 -0
  241. data/spec/features/admin/orders/listing_spec.rb +224 -0
  242. data/spec/features/admin/orders/log_entries_spec.rb +55 -0
  243. data/spec/features/admin/orders/new_order_spec.rb +186 -0
  244. data/spec/features/admin/orders/order_details_spec.rb +662 -0
  245. data/spec/features/admin/orders/payments_spec.rb +231 -0
  246. data/spec/features/admin/orders/risk_analysis_spec.rb +48 -0
  247. data/spec/features/admin/orders/shipments_spec.rb +64 -0
  248. data/spec/features/admin/orders/state_changes_spec.rb +21 -0
  249. data/spec/features/admin/products/edit/images_spec.rb +86 -0
  250. data/spec/features/admin/products/edit/products_spec.rb +64 -0
  251. data/spec/features/admin/products/edit/taxons_spec.rb +41 -0
  252. data/spec/features/admin/products/edit/variants_spec.rb +56 -0
  253. data/spec/features/admin/products/option_types_spec.rb +114 -0
  254. data/spec/features/admin/products/products_spec.rb +445 -0
  255. data/spec/features/admin/products/properties_spec.rb +147 -0
  256. data/spec/features/admin/products/prototypes_spec.rb +112 -0
  257. data/spec/features/admin/products/stock_management_spec.rb +124 -0
  258. data/spec/features/admin/products/taxonomies_spec.rb +52 -0
  259. data/spec/features/admin/products/variant_spec.rb +50 -0
  260. data/spec/features/admin/promotions/adjustments_spec.rb +259 -0
  261. data/spec/features/admin/promotions/option_value_rule_spec.rb +70 -0
  262. data/spec/features/admin/promotions/tiered_calculator_spec.rb +70 -0
  263. data/spec/features/admin/refund_reasons/refund_reasons_spec.rb +57 -0
  264. data/spec/features/admin/reimbursement_type/edit_reimbursement_type_spec.rb +36 -0
  265. data/spec/features/admin/reimbursement_type/new_reimbursement_type_spec.rb +62 -0
  266. data/spec/features/admin/reports_spec.rb +61 -0
  267. data/spec/features/admin/return_authorization_reasons/return_authorization_reasons_spec.rb +63 -0
  268. data/spec/features/admin/returns/customer_returns_spec.rb +80 -0
  269. data/spec/features/admin/returns/return_authorizations_spec.rb +152 -0
  270. data/spec/features/admin/stock_transfer_spec.rb +75 -0
  271. data/spec/features/admin/store_credits_spec.rb +93 -0
  272. data/spec/features/admin/taxons_spec.rb +47 -0
  273. data/spec/features/admin/users_spec.rb +286 -0
  274. data/spec/helpers/admin/base_helper_spec.rb +30 -0
  275. data/spec/helpers/admin/navigation_helper_spec.rb +111 -0
  276. data/spec/helpers/admin/promotion_rules_helper_spec.rb +12 -0
  277. data/spec/helpers/admin/stock_movements_helper_spec.rb +30 -0
  278. data/spec/models/spree/resource_spec.rb +48 -0
  279. data/spec/routing/admin_path_spec.rb +22 -0
  280. data/spec/spec_helper.rb +144 -0
  281. data/spec/support/appear_before_matcher.rb +8 -0
  282. data/spec/support/ror_ringer.jpeg +0 -0
  283. data/spec/test_views/spree/admin/submodule/posts/edit.html.erb +1 -0
  284. data/spec/test_views/spree/admin/submodule/posts/new.html.erb +1 -0
  285. data/spec/test_views/spree/admin/widgets/edit.html.erb +1 -0
  286. data/spec/test_views/spree/admin/widgets/new.html.erb +1 -0
  287. data/spree_backend.gemspec +4 -3
  288. data/vendor/assets/javascripts/jquery.jstree/jquery.jstree.js +130 -154
  289. metadata +114 -34
  290. data/app/assets/images/admin/payment_banner.png +0 -0
  291. data/app/assets/images/admin/progress.gif +0 -0
  292. data/app/assets/javascripts/spree/backend/nested-attribute.js +0 -27
  293. data/app/assets/javascripts/spree/backend/orders/edit_form.js +0 -21
  294. data/app/assets/stylesheets/spree/backend/components/_variables.scss +0 -12
  295. data/app/assets/stylesheets/spree/backend/plugins/_js_tree.scss +0 -0
  296. data/app/assets/stylesheets/spree/backend/shared/_typography.scss +0 -5
  297. data/app/controllers/spree/admin/root_controller.rb +0 -18
  298. data/app/controllers/spree/admin/search_controller.rb +0 -41
  299. data/app/helpers/spree/admin/inventory_settings_helper.rb +0 -9
  300. data/app/helpers/spree/admin/products_helper.rb +0 -29
  301. data/app/helpers/spree/admin/tables_helper.rb +0 -15
  302. data/app/helpers/spree/promotion_rules_helper.rb +0 -13
  303. data/app/views/spree/admin/inventory_units/adjust.html.erb +0 -29
  304. data/app/views/spree/admin/orders/_line_item.html.erb +0 -21
  305. data/app/views/spree/admin/refund_reasons/destroy.js.erb +0 -1
  306. data/app/views/spree/admin/return_authorization_reasons/destroy.js.erb +0 -1
  307. data/app/views/spree/admin/search/products.rabl +0 -9
  308. data/app/views/spree/admin/search/users.rabl +0 -30
  309. data/app/views/spree/admin/stock_movements/edit.html.erb +0 -17
@@ -0,0 +1,112 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Prototypes", type: :feature, js: true do
4
+ stub_authorization!
5
+
6
+ context "listing prototypes" do
7
+ it "should be able to list existing prototypes" do
8
+ create(:property, name: "model", presentation: "Model")
9
+ create(:property, name: "brand", presentation: "Brand")
10
+ create(:property, name: "shirt_fabric", presentation: "Fabric")
11
+ create(:property, name: "shirt_sleeve_length", presentation: "Sleeve")
12
+ create(:property, name: "mug_type", presentation: "Type")
13
+ create(:property, name: "bag_type", presentation: "Type")
14
+ create(:property, name: "manufacturer", presentation: "Manufacturer")
15
+ create(:property, name: "bag_size", presentation: "Size")
16
+ create(:property, name: "mug_size", presentation: "Size")
17
+ create(:property, name: "gender", presentation: "Gender")
18
+ create(:property, name: "shirt_fit", presentation: "Fit")
19
+ create(:property, name: "bag_material", presentation: "Material")
20
+ create(:property, name: "shirt_type", presentation: "Type")
21
+ p = create(:prototype, name: "Shirt")
22
+ %w( brand gender manufacturer model shirt_fabric shirt_fit shirt_sleeve_length shirt_type ).each do |prop|
23
+ p.properties << Spree::Property.find_by_name(prop)
24
+ end
25
+ p = create(:prototype, name: "Mug")
26
+ %w( mug_size mug_type ).each do |prop|
27
+ p.properties << Spree::Property.find_by_name(prop)
28
+ end
29
+ p = create(:prototype, name: "Bag")
30
+ %w( bag_type bag_material ).each do |prop|
31
+ p.properties << Spree::Property.find_by_name(prop)
32
+ end
33
+
34
+ visit spree.admin_path
35
+ click_link "Products"
36
+ click_link "Prototypes"
37
+
38
+ within_row(1) { expect(column_text(1)).to eq "Shirt" }
39
+ within_row(2) { expect(column_text(1)).to eq "Mug" }
40
+ within_row(3) { expect(column_text(1)).to eq "Bag" }
41
+ end
42
+ end
43
+
44
+ context "creating a prototype" do
45
+ it "should allow an admin to create a new product prototype" do
46
+ visit spree.admin_path
47
+ click_link "Products"
48
+ click_link "Prototypes"
49
+
50
+ click_link "new_prototype_link"
51
+ within('.content-header') do
52
+ expect(page).to have_content("New Prototype")
53
+ end
54
+ fill_in "prototype_name", with: "male shirts"
55
+ click_button "Create"
56
+ expect(page).to have_content("successfully created!")
57
+ click_link "Products"
58
+ click_link "Prototypes"
59
+ within_row(1) { click_icon :edit }
60
+ fill_in "prototype_name", with: "Shirt 99"
61
+ click_button "Update"
62
+ expect(page).to have_content("successfully updated!")
63
+ expect(page).to have_content("Shirt 99")
64
+ end
65
+ end
66
+
67
+ context "editing a prototype" do
68
+ it "should allow to empty its properties" do
69
+ model_property = create(:property, name: "model", presentation: "Model")
70
+ brand_property = create(:property, name: "brand", presentation: "Brand")
71
+
72
+ shirt_prototype = create(:prototype, name: "Shirt", properties: [])
73
+ %w( brand model ).each do |prop|
74
+ shirt_prototype.properties << Spree::Property.find_by_name(prop)
75
+ end
76
+
77
+ visit spree.admin_path
78
+ click_link "Products"
79
+ click_link "Prototypes"
80
+
81
+ click_icon :edit
82
+ property_ids = find_field("prototype_property_ids").value.map(&:to_i)
83
+ expect(property_ids).to match_array [model_property.id, brand_property.id]
84
+
85
+ unselect "Brand", from: "prototype_property_ids"
86
+ unselect "Model", from: "prototype_property_ids"
87
+
88
+ click_button 'Update'
89
+
90
+ click_icon :edit
91
+
92
+ expect(find_field("prototype_property_ids").value).to be_empty
93
+ end
94
+ end
95
+
96
+ it 'should be deletable' do
97
+ shirt_prototype = create(:prototype, name: "Shirt", properties: [])
98
+ shirt_prototype.taxons << create(:taxon)
99
+
100
+ visit spree.admin_path
101
+ click_link "Products"
102
+ click_link "Prototypes"
103
+
104
+ within("#spree_prototype_#{shirt_prototype.id}") do
105
+ page.find('.delete-resource').click
106
+ end
107
+
108
+ accept_alert do
109
+ expect(page).to have_content("Prototype \"#{shirt_prototype.name}\" has been successfully removed!")
110
+ end
111
+ end
112
+ end
@@ -0,0 +1,124 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Stock Management", type: :feature, js: true do
4
+ stub_authorization!
5
+
6
+ context "given a product with a variant and a stock location" do
7
+ let!(:stock_location) { create(:stock_location, name: 'Default') }
8
+ let!(:product) { create(:product, name: 'apache baseball cap', price: 10) }
9
+ let!(:variant) { product.master }
10
+
11
+ before do
12
+ stock_location.stock_item(variant).update_column(:count_on_hand, 10)
13
+ visit spree.stock_admin_product_path(product)
14
+ end
15
+
16
+ context "toggle backorderable for a variant's stock item" do
17
+ let(:backorderable) { find ".stock_item_backorderable" }
18
+
19
+ before do
20
+ expect(backorderable).to be_checked
21
+ backorderable.set(false)
22
+ wait_for_ajax
23
+ end
24
+
25
+ it "persists the value when page reload" do
26
+ visit current_path
27
+ expect(backorderable).not_to be_checked
28
+ end
29
+ end
30
+
31
+ context "toggle track inventory for a variant's stock item" do
32
+ let(:track_inventory) { find ".track_inventory_checkbox" }
33
+
34
+ before do
35
+ expect(track_inventory).to be_checked
36
+ track_inventory.set(false)
37
+ wait_for_ajax
38
+ end
39
+
40
+ it "persists the value when page reloaded" do
41
+ visit current_path
42
+ expect(track_inventory).not_to be_checked
43
+ end
44
+ end
45
+
46
+ # Regression test for #2896
47
+ # The regression was that unchecking the last checkbox caused a redirect
48
+ # to happen. By ensuring that we're still on an /admin/products URL, we
49
+ # assert that the redirect is *not* happening.
50
+ it "can toggle backorderable for the second variant stock item" do
51
+ new_location = create(:stock_location, name: "Another Location")
52
+ visit current_url
53
+
54
+ new_location_backorderable = find "#stock_item_backorderable_#{new_location.id}"
55
+ new_location_backorderable.set(false)
56
+ wait_for_ajax
57
+
58
+ expect(page.current_url).to include("/admin/products")
59
+ end
60
+
61
+ it "can create a new stock movement" do
62
+ fill_in "stock_movement_quantity", with: 5
63
+ select2 "default", from: "Stock Location"
64
+ click_button "Add Stock"
65
+
66
+ expect(page).to have_content('successfully created')
67
+
68
+ within(:css, '.stock_location_info table') do
69
+ expect(column_text(2)).to eq '15'
70
+ end
71
+ end
72
+
73
+ it "can create a new negative stock movement" do
74
+ fill_in "stock_movement_quantity", with: -5
75
+ select2 "default", from: "Stock Location"
76
+ click_button "Add Stock"
77
+
78
+ expect(page).to have_content('successfully created')
79
+
80
+ within(:css, '.stock_location_info table') do
81
+ expect(column_text(2)).to eq '5'
82
+ end
83
+ end
84
+
85
+ context "with multiple variants" do
86
+ let!(:variant) { create(:variant, product: product, sku: 'SPREEC') }
87
+ before do
88
+ variant.stock_items.first.update_column(:count_on_hand, 30)
89
+ visit current_url
90
+ end
91
+
92
+ it "can create a new stock movement for the specified variant" do
93
+ fill_in "stock_movement_quantity", with: 10
94
+ select2 "SPREEC", from: "Variant"
95
+ click_button "Add Stock"
96
+
97
+ expect(page).to have_content('successfully created')
98
+
99
+ within("#listing_product_stock tr", text: "SPREEC") do
100
+ within("table") do
101
+ expect(column_text(2)).to eq '40'
102
+ end
103
+ end
104
+ end
105
+ end
106
+
107
+ # Regression test for #3304
108
+ context "with no stock location" do
109
+ let(:product) { create(:product, name: 'apache baseball cap', price: 10) }
110
+ let(:variant) { create(:variant, product: product, sku: 'FOOBAR') }
111
+
112
+ before do
113
+ Spree::StockLocation.delete_all
114
+
115
+ visit spree.stock_admin_product_path(product)
116
+ end
117
+
118
+ it "redirects to stock locations page", js: false do
119
+ expect(page).to have_content(Spree.t(:stock_management_requires_a_stock_location))
120
+ expect(page.current_url).to include("admin/stock_locations")
121
+ end
122
+ end
123
+ end
124
+ end
@@ -0,0 +1,52 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Taxonomies", type: :feature, js: true do
4
+ stub_authorization!
5
+
6
+ before(:each) do
7
+ visit spree.admin_path
8
+ click_link "Products"
9
+ end
10
+
11
+ context "show" do
12
+ it 'should display existing taxonomies' do
13
+ create(:taxonomy, name: 'Brand')
14
+ create(:taxonomy, name: 'Categories')
15
+ visit spree.admin_taxonomies_path
16
+ within_row(1) { expect(page).to have_content('Brand') }
17
+ within_row(2) { expect(page).to have_content('Categories') }
18
+ end
19
+ end
20
+
21
+ context "create" do
22
+ before(:each) do
23
+ click_link "Taxonomies"
24
+ click_link "admin_new_taxonomy_link"
25
+ end
26
+
27
+ it "should allow an admin to create a new taxonomy" do
28
+ expect(page).to have_content("New Taxonomy")
29
+ fill_in "taxonomy_name", with: "sports"
30
+ click_button "Create"
31
+ expect(page).to have_content("successfully created!")
32
+ end
33
+
34
+ it "should display validation errors" do
35
+ fill_in "taxonomy_name", with: ""
36
+ click_button "Create"
37
+ expect(page).to have_content("can't be blank")
38
+ end
39
+ end
40
+
41
+ context "edit" do
42
+ it "should allow an admin to update an existing taxonomy" do
43
+ create(:taxonomy)
44
+ click_link "Taxonomies"
45
+ within_row(1) { click_icon :edit }
46
+ fill_in "taxonomy_name", with: "sports 99"
47
+ click_button "Update"
48
+ expect(page).to have_content("successfully updated!")
49
+ expect(page).to have_content("sports 99")
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,50 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe "Variants", type: :feature do
5
+ stub_authorization!
6
+
7
+ let(:product) { create(:product_with_option_types, price: "1.99", cost_price: "1.00", weight: "2.5", height: "3.0", width: "1.0", depth: "1.5") }
8
+
9
+ context "creating a new variant" do
10
+ it "should allow an admin to create a new variant", js: true do
11
+ product.options.each do |option|
12
+ create(:option_value, option_type: option.option_type)
13
+ end
14
+
15
+ visit spree.admin_products_path
16
+ within_row(1) { click_icon :edit }
17
+ click_link "Variants"
18
+ click_on "Add One"
19
+ expect(find('input#variant_price').value).to eq("1.99")
20
+ expect(find('input#variant_cost_price').value).to eq("1.00")
21
+ expect(find('input#variant_weight').value).to eq("2.50")
22
+ expect(find('input#variant_height').value).to eq("3.00")
23
+ expect(find('input#variant_width').value).to eq("1.00")
24
+ expect(find('input#variant_depth').value).to eq("1.50")
25
+ expect(page).to have_select('variant[tax_category_id]')
26
+ end
27
+ end
28
+
29
+ context "listing variants" do
30
+ context "currency displaying" do
31
+ context "using Russian Rubles" do
32
+ before do
33
+ Spree::Config[:currency] = "RUB"
34
+ end
35
+
36
+ let!(:variant) do
37
+ create(:variant, product: product, price: 19.99)
38
+ end
39
+
40
+ # Regression test for #2737
41
+ context "uses руб as the currency symbol" do
42
+ it "on the products listing page" do
43
+ visit spree.admin_product_variants_path(product)
44
+ within_row(1) { expect(page).to have_content("19.99 ₽") }
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,259 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Promotion Adjustments", type: :feature, js: true do
4
+ stub_authorization!
5
+
6
+ context "coupon promotions" do
7
+ before(:each) do
8
+ visit spree.admin_promotions_path
9
+ click_on "New Promotion"
10
+ end
11
+
12
+ it "should allow an admin to create a flat rate discount coupon promo" do
13
+ fill_in "Name", with: "Promotion"
14
+ fill_in "Code", with: "order"
15
+ click_button "Create"
16
+ promotion = Spree::Promotion.find_by_name("Promotion")
17
+ expect(page).to have_content(promotion.name)
18
+
19
+ select2 "Item total", from: "Add rule of type"
20
+ within('#rule_fields') { click_button "Add" }
21
+
22
+ eventually_fill_in "promotion_promotion_rules_attributes_#{Spree::Promotion.count}_preferred_amount_min", with: 30
23
+ eventually_fill_in "promotion_promotion_rules_attributes_#{Spree::Promotion.count}_preferred_amount_max", with: 60
24
+ within('#rule_fields') { click_button "Update" }
25
+
26
+ select2 "Create whole-order adjustment", from: "Add action of type"
27
+ within('#action_fields') { click_button "Add" }
28
+ select2 "Flat Rate", from: "Calculator"
29
+ within('#actions_container') { click_button "Update" }
30
+
31
+ within('.calculator-fields') { fill_in "Amount", with: 5 }
32
+ within('#actions_container') { click_button "Update" }
33
+
34
+ expect(promotion.code).to eq("order")
35
+
36
+ first_rule = promotion.rules.first
37
+ expect(first_rule.class).to eq(Spree::Promotion::Rules::ItemTotal)
38
+ expect(first_rule.preferred_amount_min).to eq(30)
39
+ expect(first_rule.preferred_amount_max).to eq(60)
40
+
41
+ first_action = promotion.actions.first
42
+ expect(first_action.class).to eq(Spree::Promotion::Actions::CreateAdjustment)
43
+ first_action_calculator = first_action.calculator
44
+ expect(first_action_calculator.class).to eq(Spree::Calculator::FlatRate)
45
+ expect(first_action_calculator.preferred_amount).to eq(5)
46
+ end
47
+
48
+ it "should allow an admin to create a single user coupon promo with flat rate discount" do
49
+ fill_in "Name", with: "Promotion"
50
+ fill_in "Usage Limit", with: "1"
51
+ fill_in "Code", with: "single_use"
52
+ click_button "Create"
53
+ promotion = Spree::Promotion.find_by_name("Promotion")
54
+ expect(page).to have_content(promotion.name)
55
+
56
+ select2 "Create whole-order adjustment", from: "Add action of type"
57
+ within('#action_fields') { click_button "Add" }
58
+ select2 "Flat Rate", from: "Calculator"
59
+ within('#actions_container') { click_button "Update" }
60
+ within('#action_fields') { fill_in "Amount", with: "5" }
61
+ within('#actions_container') { click_button "Update" }
62
+
63
+ expect(promotion.usage_limit).to eq(1)
64
+ expect(promotion.code).to eq("single_use")
65
+
66
+ first_action = promotion.actions.first
67
+ expect(first_action.class).to eq(Spree::Promotion::Actions::CreateAdjustment)
68
+ first_action_calculator = first_action.calculator
69
+ expect(first_action_calculator.class).to eq(Spree::Calculator::FlatRate)
70
+ expect(first_action_calculator.preferred_amount).to eq(5)
71
+ end
72
+
73
+ it "should allow an admin to create an automatic promo with flat percent discount" do
74
+ fill_in "Name", with: "Promotion"
75
+ click_button "Create"
76
+ promotion = Spree::Promotion.find_by_name("Promotion")
77
+
78
+ expect(page).to have_content(promotion.name)
79
+
80
+ select2 "Item total", from: "Add rule of type"
81
+ within('#rule_fields') { click_button "Add" }
82
+
83
+ eventually_fill_in "promotion_promotion_rules_attributes_1_preferred_amount_min", with: 30
84
+ eventually_fill_in "promotion_promotion_rules_attributes_1_preferred_amount_max", with: 60
85
+ within('#rule_fields') { click_button "Update" }
86
+
87
+ select2 "Create whole-order adjustment", from: "Add action of type"
88
+ within('#action_fields') { click_button "Add" }
89
+ select2 "Flat Percent", from: "Calculator"
90
+ within('#actions_container') { click_button "Update" }
91
+ within('.calculator-fields') { fill_in "Flat Percent", with: "10" }
92
+ within('#actions_container') { click_button "Update" }
93
+
94
+ expect(promotion.code).to be_blank
95
+
96
+ first_rule = promotion.rules.first
97
+ expect(first_rule.class).to eq(Spree::Promotion::Rules::ItemTotal)
98
+ expect(first_rule.preferred_amount_min).to eq(30)
99
+ expect(first_rule.preferred_amount_max).to eq(60)
100
+
101
+ first_action = promotion.actions.first
102
+ expect(first_action.class).to eq(Spree::Promotion::Actions::CreateAdjustment)
103
+ first_action_calculator = first_action.calculator
104
+ expect(first_action_calculator.class).to eq(Spree::Calculator::FlatPercentItemTotal)
105
+ expect(first_action_calculator.preferred_flat_percent).to eq(10)
106
+ end
107
+
108
+ it "should allow an admin to create an product promo with percent per item discount" do
109
+ create(:product, name: "RoR Mug")
110
+
111
+ fill_in "Name", with: "Promotion"
112
+ click_button "Create"
113
+ promotion = Spree::Promotion.find_by_name("Promotion")
114
+
115
+ expect(page).to have_content(promotion.name)
116
+
117
+ select2 "Product(s)", from: "Add rule of type"
118
+ within("#rule_fields") { click_button "Add" }
119
+ select2_search "RoR Mug", from: "Choose products"
120
+ within('#rule_fields') { click_button "Update" }
121
+
122
+ select2 "Create per-line-item adjustment", from: "Add action of type"
123
+ within('#action_fields') { click_button "Add" }
124
+ select2 "Percent Per Item", from: "Calculator"
125
+ within('#actions_container') { click_button "Update" }
126
+ within('.calculator-fields') { fill_in "Percent", with: "10" }
127
+ within('#actions_container') { click_button "Update" }
128
+
129
+ expect(promotion.code).to be_blank
130
+
131
+ first_rule = promotion.rules.first
132
+ expect(first_rule.class).to eq(Spree::Promotion::Rules::Product)
133
+ expect(first_rule.products.map(&:name)).to include("RoR Mug")
134
+
135
+ first_action = promotion.actions.first
136
+ expect(first_action.class).to eq(Spree::Promotion::Actions::CreateItemAdjustments)
137
+ first_action_calculator = first_action.calculator
138
+ expect(first_action_calculator.class).to eq(Spree::Calculator::PercentOnLineItem)
139
+ expect(first_action_calculator.preferred_percent).to eq(10)
140
+ end
141
+
142
+ xit "should allow an admin to create an automatic promotion with free shipping (no code)" do
143
+ fill_in "Name", with: "Promotion"
144
+ click_button "Create"
145
+ expect(page).to have_content("Editing Promotion")
146
+
147
+ select2 "Item total", from: "Add rule of type"
148
+ within('#rule_fields') { click_button "Add" }
149
+ eventually_fill_in "promotion_promotion_rules_attributes_1_preferred_amount", with: "30"
150
+ within('#rule_fields') { click_button "Update" }
151
+
152
+ select2 "Create whole-order adjustment", from: "Add action of type"
153
+ within('#action_fields') { click_button "Add" }
154
+ select2 "Free Shipping", from: "Calculator"
155
+ within('#actions_container') { click_button "Update" }
156
+
157
+ promotion = Spree::Promotion.find_by_name("Promotion")
158
+ expect(promotion.code).to be_blank
159
+
160
+ first_rule = promotion.rules.first
161
+ expect(first_rule.class).to eq(Spree::Promotion::Rules::ItemTotal)
162
+
163
+ first_action = promotion.actions.first
164
+ expect(first_action.class).to eq(Spree::Promotion::Actions::CreateAdjustment)
165
+ first_action_calculator = first_action.calculator
166
+ expect(first_action_calculator.class).to eq(Spree::Calculator::FreeShipping)
167
+ end
168
+
169
+ it "should allow an admin to create an automatic promo requiring a landing page to be visited" do
170
+ fill_in "Name", with: "Promotion"
171
+ fill_in "Path", with: "content/cvv"
172
+ click_button "Create"
173
+ promotion = Spree::Promotion.find_by_name("Promotion")
174
+
175
+ expect(page).to have_content(promotion.name)
176
+
177
+ select2 "Create whole-order adjustment", from: "Add action of type"
178
+ within('#action_fields') { click_button "Add" }
179
+ select2 "Flat Rate", from: "Calculator"
180
+ within('#actions_container') { click_button "Update" }
181
+ within('.calculator-fields') { fill_in "Amount", with: "4" }
182
+ within('#actions_container') { click_button "Update" }
183
+
184
+ expect(promotion.path).to eq("content/cvv")
185
+ expect(promotion.code).to be_blank
186
+ expect(promotion.rules).to be_blank
187
+
188
+ first_action = promotion.actions.first
189
+ expect(first_action.class).to eq(Spree::Promotion::Actions::CreateAdjustment)
190
+ first_action_calculator = first_action.calculator
191
+ expect(first_action_calculator.class).to eq(Spree::Calculator::FlatRate)
192
+ expect(first_action_calculator.preferred_amount).to eq(4)
193
+ end
194
+
195
+ it "should allow an admin to create a promotion that adds a 'free' item to the cart" do
196
+ create(:product, name: "RoR Mug")
197
+ fill_in "Name", with: "Promotion"
198
+ fill_in "Code", with: "complex"
199
+ click_button "Create"
200
+ promotion = Spree::Promotion.find_by_name("Promotion")
201
+
202
+ expect(page).to have_content(promotion.name)
203
+
204
+ select2 "Create line items", from: "Add action of type"
205
+
206
+ within('#action_fields') { click_button "Add" }
207
+
208
+ page.find('.create_line_items .select2-choice').click
209
+ page.find('.select2-input').set('RoR Mug')
210
+ page.find('.select2-highlighted').click
211
+
212
+ within('#actions_container') { click_button "Update" }
213
+
214
+ select2 "Create whole-order adjustment", from: "Add action of type"
215
+ within('#new_promotion_action_form') { click_button "Add" }
216
+ select2 "Flat Rate", from: "Calculator"
217
+ within('#actions_container') { click_button "Update" }
218
+ within('.create_adjustment .calculator-fields') { fill_in "Amount", with: "40.00" }
219
+ within('#actions_container') { click_button "Update" }
220
+
221
+ expect(promotion.code).to eq("complex")
222
+
223
+ first_action = promotion.actions.first
224
+ expect(first_action.class).to eq(Spree::Promotion::Actions::CreateLineItems)
225
+ line_item = expect(first_action.promotion_action_line_items).not_to be_empty
226
+ end
227
+
228
+ it "ceasing to be eligible for a promotion with item total rule then becoming eligible again" do
229
+ fill_in "Name", with: "Promotion"
230
+ click_button "Create"
231
+ promotion = Spree::Promotion.find_by_name("Promotion")
232
+
233
+ expect(page).to have_content(promotion.name)
234
+
235
+ select2 "Item total", from: "Add rule of type"
236
+ within('#rule_fields') { click_button "Add" }
237
+ eventually_fill_in "promotion_promotion_rules_attributes_1_preferred_amount_min", with: "50"
238
+ eventually_fill_in "promotion_promotion_rules_attributes_1_preferred_amount_max", with: "150"
239
+ within('#rule_fields') { click_button "Update" }
240
+
241
+ select2 "Create whole-order adjustment", from: "Add action of type"
242
+ within('#action_fields') { click_button "Add" }
243
+ select2 "Flat Rate", from: "Calculator"
244
+ within('#actions_container') { click_button "Update" }
245
+ within('.calculator-fields') { fill_in "Amount", with: "5" }
246
+ within('#actions_container') { click_button "Update" }
247
+
248
+ first_rule = promotion.rules.first
249
+ expect(first_rule.class).to eq(Spree::Promotion::Rules::ItemTotal)
250
+ expect(first_rule.preferred_amount_min).to eq(50)
251
+ expect(first_rule.preferred_amount_max).to eq(150)
252
+
253
+ first_action = promotion.actions.first
254
+ expect(first_action.class).to eq(Spree::Promotion::Actions::CreateAdjustment)
255
+ expect(first_action.calculator.class).to eq(Spree::Calculator::FlatRate)
256
+ expect(first_action.calculator.preferred_amount).to eq(5)
257
+ end
258
+ end
259
+ end
@@ -0,0 +1,70 @@
1
+ require 'spec_helper'
2
+
3
+ feature 'Promotion with option value rule' do
4
+ stub_authorization!
5
+
6
+ given(:variant) { create :variant }
7
+ given!(:product) { variant.product }
8
+ given!(:option_value) { variant.option_values.first }
9
+
10
+ given(:promotion) { create :promotion }
11
+
12
+ background do
13
+ visit spree.edit_admin_promotion_path(promotion)
14
+ end
15
+
16
+ scenario "adding an option value rule", js: true do
17
+ select2 "Option Value(s)", from: "Add rule of type"
18
+ within("#rule_fields") { click_button "Add" }
19
+
20
+ within("#rules .promotion-block") do
21
+ click_button "Add"
22
+
23
+ expect(page.body).to have_content("Product")
24
+ expect(page.body).to have_content("Option Values")
25
+ end
26
+
27
+ within('.promo-rule-option-value') do
28
+ targetted_select2_search product.name, from: '.js-promo-rule-option-value-product-select'
29
+ targetted_select2_search(
30
+ option_value.name,
31
+ from: '.js-promo-rule-option-value-option-values-select'
32
+ )
33
+ end
34
+
35
+ within('#rules_container') { click_button "Update" }
36
+
37
+ first_rule = promotion.rules.reload.first
38
+ expect(first_rule.class).to eq Spree::Promotion::Rules::OptionValue
39
+ expect(first_rule.preferred_eligible_values).to eq Hash[product.id => [option_value.id]]
40
+ end
41
+
42
+ context "with an existing option value rule" do
43
+ given(:variant1) { create :variant }
44
+ given(:variant2) { create :variant }
45
+ background do
46
+ rule = Spree::Promotion::Rules::OptionValue.new
47
+ rule.promotion = promotion
48
+ rule.preferred_eligible_values = Hash[
49
+ variant1.product_id => variant1.option_values.pluck(:id),
50
+ variant2.product_id => variant2.option_values.pluck(:id)
51
+ ]
52
+ rule.save!
53
+
54
+ visit spree.edit_admin_promotion_path(promotion)
55
+ end
56
+
57
+ scenario "deleting a product", js: true do
58
+ within(".promo-rule-option-value:last-child") do
59
+ find(".delete").click
60
+ end
61
+
62
+ within('#rule_fields') { click_button "Update" }
63
+
64
+ first_rule = promotion.rules.reload.first
65
+ expect(first_rule.preferred_eligible_values).to eq(
66
+ Hash[variant1.product_id => variant1.option_values.pluck(:id)]
67
+ )
68
+ end
69
+ end
70
+ end