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,46 @@
1
+ # Spree's rpsec controller tests get the Spree::ControllerHacks
2
+ # we don't need those for the anonymous controller here, so
3
+ # we call process directly instead of get
4
+ require 'spec_helper'
5
+
6
+ describe Spree::Admin::BaseController, type: :controller do
7
+ controller(Spree::Admin::BaseController) do
8
+ def index
9
+ authorize! :update, Spree::Order
10
+ render plain: 'test'
11
+ end
12
+ end
13
+
14
+ context "unauthorized request" do
15
+ before do
16
+ allow_any_instance_of(Spree::Admin::BaseController).to receive(:spree_current_user).and_return(nil)
17
+ end
18
+
19
+ it "redirects to root" do
20
+ allow(controller).to receive_message_chain(:spree, :root_path).and_return('/root')
21
+ get :index
22
+ expect(response).to redirect_to '/root'
23
+ end
24
+ end
25
+
26
+ context "#generate_api_key" do
27
+ let(:user) { mock_model(Spree.user_class, has_spree_role?: true) }
28
+
29
+ before do
30
+ allow(controller).to receive(:authorize_admin) { true }
31
+ allow(controller).to receive(:try_spree_current_user) { user }
32
+ end
33
+
34
+ it "generates the API key for a user when they visit" do
35
+ expect(user).to receive(:spree_api_key).and_return(nil)
36
+ expect(user).to receive(:generate_spree_api_key!)
37
+ get :index
38
+ end
39
+
40
+ it "does not attempt to regenerate the API key if the key is already set" do
41
+ expect(user).to receive(:spree_api_key).and_return('fake')
42
+ expect(user).not_to receive(:generate_spree_api_key!)
43
+ get :index
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,185 @@
1
+ require 'spec_helper'
2
+
3
+ module Spree
4
+ module Admin
5
+ describe CustomerReturnsController, type: :controller do
6
+ stub_authorization!
7
+
8
+ describe "#index" do
9
+ let(:order) { customer_return.order }
10
+ let(:customer_return) { create(:customer_return) }
11
+
12
+ subject do
13
+ spree_get :index, { order_id: customer_return.order.to_param }
14
+ end
15
+
16
+ before { subject }
17
+
18
+ it "loads the order" do
19
+ expect(assigns(:order)).to eq order
20
+ end
21
+
22
+ it "loads the customer return" do
23
+ expect(assigns(:customer_returns)).to include(customer_return)
24
+ end
25
+ end
26
+
27
+ describe "#new" do
28
+ let(:order) { create(:shipped_order, line_items_count: 1) }
29
+ let!(:rma) { create :return_authorization, order: order, return_items: [create(:return_item, inventory_unit: order.inventory_units.first)] }
30
+ let!(:inactive_reimbursement_type) { create(:reimbursement_type, active: false) }
31
+ let!(:first_active_reimbursement_type) { create(:reimbursement_type) }
32
+ let!(:second_active_reimbursement_type) { create(:reimbursement_type) }
33
+
34
+ subject do
35
+ spree_get :new, { order_id: order.to_param }
36
+ end
37
+
38
+ it "loads the order" do
39
+ subject
40
+ expect(assigns(:order)).to eq order
41
+ end
42
+
43
+ it "creates a new customer return" do
44
+ subject
45
+ expect(assigns(:customer_return)).to_not be_persisted
46
+ end
47
+
48
+ context "with previous customer return" do
49
+ let(:order) { create(:shipped_order, line_items_count: 4) }
50
+ let(:rma) { create(:return_authorization, order: order) }
51
+
52
+ let!(:rma_return_item) { create(:return_item, return_authorization: rma, inventory_unit: order.inventory_units.first) }
53
+ let!(:customer_return_return_item) { create(:return_item, return_authorization: rma, inventory_unit: order.inventory_units.last) }
54
+
55
+ context "there is a return item associated with an rma but not a customer return" do
56
+ let!(:previous_customer_return) { create(:customer_return_without_return_items, return_items: [customer_return_return_item]) }
57
+
58
+ before do
59
+ subject
60
+ end
61
+
62
+ it "loads the persisted rma return items" do
63
+ expect(assigns(:rma_return_items).all? { |return_item| return_item.persisted? }).to eq true
64
+ end
65
+
66
+ it "has one rma return item" do
67
+ expect(assigns(:rma_return_items)).to include(rma_return_item)
68
+ end
69
+ end
70
+ end
71
+ end
72
+
73
+ describe "#edit" do
74
+ let(:order) { customer_return.order }
75
+ let(:customer_return) { create(:customer_return, line_items_count: 3) }
76
+
77
+ let!(:accepted_return_item) { customer_return.return_items.order('id').first.tap(&:accept!) }
78
+ let!(:rejected_return_item) { customer_return.return_items.order('id').second.tap(&:reject!)}
79
+ let!(:manual_intervention_return_item) { customer_return.return_items.order('id').third.tap(&:require_manual_intervention!) }
80
+
81
+ subject do
82
+ spree_get :edit, { order_id: order.to_param, id: customer_return.to_param }
83
+ end
84
+
85
+ before do
86
+ subject
87
+ end
88
+
89
+ it "loads the order" do
90
+ expect(assigns(:order)).to eq order
91
+ end
92
+
93
+ it "loads the customer return" do
94
+ expect(assigns(:customer_return)).to eq customer_return
95
+ end
96
+
97
+ it "loads the accepted return items" do
98
+ expect(assigns(:accepted_return_items)).to eq [accepted_return_item]
99
+ end
100
+
101
+ it "loads the rejected return items" do
102
+ expect(assigns(:rejected_return_items)).to eq [rejected_return_item]
103
+ end
104
+
105
+ it "loads the return items that require manual intervention" do
106
+ expect(assigns(:manual_intervention_return_items)).to eq [manual_intervention_return_item]
107
+ end
108
+
109
+ it "loads the return items that are still pending" do
110
+ expect(assigns(:pending_return_items)).to eq []
111
+ end
112
+
113
+ it "loads the reimbursements that are still pending" do
114
+ expect(assigns(:pending_reimbursements)).to eq []
115
+ end
116
+ end
117
+
118
+ describe "#create" do
119
+ let(:order) { create(:shipped_order, line_items_count: 1) }
120
+ let!(:return_authorization) { create :return_authorization, order: order, return_items: [create(:return_item, inventory_unit: order.inventory_units.shipped.last)] }
121
+
122
+ subject do
123
+ spree_post :create, customer_return_params
124
+ end
125
+
126
+ context "valid customer return" do
127
+ let(:stock_location) { order.shipments.last.stock_location }
128
+
129
+ let!(:customer_return_params) do
130
+ {
131
+ order_id: order.to_param,
132
+ customer_return: {
133
+ stock_location_id: stock_location.id,
134
+ return_items_attributes: {
135
+ "0" => {
136
+ id: return_authorization.return_items.first.id,
137
+ returned: "1",
138
+ "pre_tax_amount"=>"15.99",
139
+ inventory_unit_id: order.inventory_units.shipped.last.id
140
+ }
141
+ }
142
+ }
143
+ }
144
+ end
145
+
146
+ it "creates a customer return" do
147
+ expect{ subject }.to change { Spree::CustomerReturn.count }.by(1)
148
+ end
149
+
150
+ it "redirects to the index page" do
151
+ subject
152
+ expect(response).to redirect_to(spree.edit_admin_order_customer_return_path(order, assigns(:customer_return)))
153
+ end
154
+ end
155
+
156
+ context "invalid customer return" do
157
+ let!(:customer_return_params) do
158
+ {
159
+ order_id: order.to_param,
160
+ customer_return: {
161
+ stock_location_id: "",
162
+ return_items_attributes: {
163
+ "0" => {
164
+ returned: "1",
165
+ "pre_tax_amount"=>"15.99",
166
+ inventory_unit_id: order.inventory_units.shipped.last.id
167
+ }
168
+ }
169
+ }
170
+ }
171
+ end
172
+
173
+ it "doesn't create a customer return" do
174
+ expect{ subject }.to_not change { Spree::CustomerReturn.count }
175
+ end
176
+
177
+ it "renders the new page" do
178
+ subject
179
+ expect(response).to render_template(:new)
180
+ end
181
+ end
182
+ end
183
+ end
184
+ end
185
+ end
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ describe Spree::Admin::GeneralSettingsController, type: :controller do
4
+ let(:user) { create(:user) }
5
+
6
+ before do
7
+ allow(controller).to receive_messages spree_current_user: user
8
+ user.spree_roles << Spree::Role.find_or_create_by(name: 'admin')
9
+ end
10
+
11
+ describe '#clear_cache' do
12
+ subject { spree_post :clear_cache }
13
+
14
+ shared_examples 'a HTTP 204 response' do
15
+ it 'grant access to users with an admin role' do
16
+ subject
17
+ expect(response.status).to eq(204)
18
+ end
19
+ end
20
+
21
+ context 'when no callback' do
22
+ it_behaves_like 'a HTTP 204 response'
23
+ end
24
+
25
+ context 'when callback implemented' do
26
+ Spree::Admin::GeneralSettingsController.class_eval do
27
+ custom_callback(:clear_cache).after :foo
28
+
29
+ def foo
30
+ # Make a call to Akamai, CloudFlare, etc invalidation....
31
+ end
32
+ end
33
+
34
+ before do
35
+ expect(controller).to receive(:foo).once
36
+ end
37
+
38
+ it_behaves_like 'a HTTP 204 response'
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+ # This test exists in this file because in the standard admin/products_controller spec
3
+ # There is the stub_authorization call. This call is not triggered for this test because
4
+ # the load_resource filter in Spree::Admin::ResourceController is prepended to the filter chain
5
+ # this means this call is triggered before the authorize_admin call and in this case
6
+ # the load_resource filter halts the request meaning authorize_admin is not called at all.
7
+ describe Spree::Admin::ProductsController, type: :controller do
8
+ stub_authorization!
9
+
10
+ # Regression test for GH #538
11
+ it "cannot find a non-existent product" do
12
+ spree_get :edit, id: "non-existent-product"
13
+ expect(response).to redirect_to(spree.admin_products_path)
14
+ expect(flash[:error]).to eql("Product is not found")
15
+ end
16
+ end
17
+
18
+
@@ -0,0 +1,197 @@
1
+ require "spec_helper"
2
+ require "cancan"
3
+ require "spree/testing_support/bar_ability"
4
+
5
+ describe Spree::Admin::Orders::CustomerDetailsController, type: :controller do
6
+
7
+ context "with authorization" do
8
+ stub_authorization!
9
+
10
+ let(:order) do
11
+ mock_model(
12
+ Spree::Order,
13
+ total: 100,
14
+ number: "R123456789",
15
+ billing_address: mock_model(Spree::Address)
16
+ )
17
+ end
18
+
19
+ before do
20
+ allow(Spree::Order).to receive_message_chain(:friendly, :find).and_return(order)
21
+ end
22
+
23
+ describe '#update' do
24
+ let(:attributes) do
25
+ {
26
+ order_id: order.number,
27
+ order: {
28
+ email: "",
29
+ use_billing: "",
30
+ bill_address_attributes: { firstname: 'john' },
31
+ ship_address_attributes: { firstname: 'john' }
32
+ },
33
+ guest_checkout: 'true'
34
+ }
35
+ end
36
+
37
+ def send_request(params = {})
38
+ spree_put :update, params
39
+ end
40
+
41
+ context 'using guest checkout' do
42
+ context 'having valid parameters' do
43
+ before do
44
+ allow(order).to receive_messages(update_attributes: true)
45
+ allow(order).to receive_messages(next: false)
46
+ allow(order).to receive_messages(complete?: true)
47
+ allow(order).to receive_messages(refresh_shipment_rates: true)
48
+ end
49
+
50
+ context 'having successful response' do
51
+ before { send_request(attributes) }
52
+ it { expect(response).to have_http_status(302) }
53
+ it { expect(response).to redirect_to(edit_admin_order_url(order)) }
54
+ end
55
+
56
+ context 'with correct method flow' do
57
+ it { expect(order).to receive(:update_attributes).with(ActionController::Parameters.new(attributes[:order]).permit(permitted_order_attributes)) }
58
+ it { expect(order).to_not receive(:next) }
59
+ it { expect(order).to receive(:complete?) }
60
+ it 'does refresh the shipment rates with all shipping methods' do
61
+ expect(order).to receive(:refresh_shipment_rates).
62
+ with(Spree::ShippingMethod::DISPLAY_ON_FRONT_AND_BACK_END)
63
+ end
64
+ it { expect(controller).to receive(:load_order).and_call_original }
65
+ it { expect(controller).to receive(:guest_checkout?).twice.and_call_original }
66
+ it { expect(controller).to_not receive(:load_user).and_call_original }
67
+ after { send_request(attributes) }
68
+ end
69
+ end
70
+
71
+ context 'having invalid parameters' do
72
+ before do
73
+ allow(order).to receive_messages(update_attributes: false)
74
+ end
75
+
76
+ context 'having failure response' do
77
+ before { send_request(attributes) }
78
+ it { expect(response).to render_template(:edit) }
79
+ end
80
+
81
+ context 'with correct method flow' do
82
+ it { expect(order).to receive(:update_attributes).with(ActionController::Parameters.new(attributes[:order]).permit(permitted_order_attributes)) }
83
+ it { expect(controller).to receive(:load_order).and_call_original }
84
+ it { expect(controller).to receive(:guest_checkout?).and_call_original }
85
+ it { expect(controller).to_not receive(:load_user).and_call_original }
86
+ after { send_request(attributes) }
87
+ end
88
+ end
89
+ end
90
+
91
+ context 'without using guest checkout' do
92
+ let(:user) { mock_model(Spree.user_class) }
93
+ let(:changed_attributes) { attributes.merge(guest_checkout: 'false', user_id: user.id) }
94
+
95
+ context 'having valid parameters' do
96
+ before do
97
+ allow(Spree.user_class).to receive(:find_by).and_return(user)
98
+ allow(order).to receive_messages(update_attributes: true)
99
+ allow(order).to receive_messages(next: false)
100
+ allow(order).to receive_messages(complete?: true)
101
+ allow(order).to receive_messages(refresh_shipment_rates: true)
102
+ allow(order).to receive_messages(associate_user!: true)
103
+ allow(controller).to receive(:guest_checkout?).and_return(false)
104
+ allow(order).to receive(:associate_user!)
105
+ end
106
+
107
+ context 'having successful response' do
108
+ before { send_request(changed_attributes) }
109
+ it { expect(response).to have_http_status(302) }
110
+ it { expect(response).to redirect_to(edit_admin_order_url(order)) }
111
+ end
112
+
113
+ context 'with correct method flow' do
114
+ it { expect(order).to receive(:update_attributes).with(ActionController::Parameters.new(attributes[:order]).permit(permitted_order_attributes)) }
115
+ it { expect(order).to receive(:associate_user!).with(user, order.email.blank?) }
116
+ it { expect(order).to_not receive(:next) }
117
+ it { expect(order).to receive(:complete?) }
118
+ it 'does refresh the shipment rates with all shipping methods' do
119
+ expect(order).to receive(:refresh_shipment_rates).
120
+ with(Spree::ShippingMethod::DISPLAY_ON_FRONT_AND_BACK_END)
121
+ end
122
+ it { expect(controller).to receive(:load_order).and_call_original }
123
+ it { expect(controller).to receive(:guest_checkout?).twice.and_call_original }
124
+ it { expect(controller).to receive(:load_user).and_call_original }
125
+ after { send_request(changed_attributes) }
126
+ end
127
+ end
128
+
129
+ context 'having invalid parameters' do
130
+ before do
131
+ allow(Spree.user_class).to receive(:find_by).and_return(false)
132
+ allow(controller).to receive(:guest_checkout?).and_return(false)
133
+ end
134
+
135
+ context 'having failure response' do
136
+ before { send_request(changed_attributes) }
137
+ it { expect(response).to render_template(:edit) }
138
+ end
139
+
140
+ context 'with correct method flow' do
141
+ it { expect(order).to_not receive(:update_attributes).with(ActionController::Parameters.new(attributes[:order]).permit(permitted_order_attributes)) }
142
+ it { expect(controller).to receive(:load_order).and_call_original }
143
+ it { expect(controller).to receive(:guest_checkout?).and_call_original }
144
+ it { expect(controller).to receive(:load_user).and_call_original }
145
+ after { send_request(changed_attributes) }
146
+ end
147
+ end
148
+
149
+ describe '#load_user' do
150
+ context 'having valid parameters' do
151
+ before do
152
+ allow(Spree.user_class).to receive(:find_by).and_return(user)
153
+ allow(order).to receive_messages(update_attributes: true)
154
+ allow(order).to receive_messages(next: false)
155
+ allow(order).to receive_messages(complete?: true)
156
+ allow(order).to receive_messages(refresh_shipment_rates: true)
157
+ allow(order).to receive_messages(associate_user!: true)
158
+ allow(controller).to receive(:guest_checkout?).and_return(false)
159
+ allow(order).to receive(:associate_user!)
160
+ end
161
+
162
+ it "expects to assign user" do
163
+ send_request(changed_attributes)
164
+ expect(assigns[:user]).to eq(user)
165
+ end
166
+
167
+ context 'with correct method flow' do
168
+ it { expect(Spree.user_class).to receive(:find_by).with(id: user.id.to_s).and_return(user) }
169
+ after { send_request(changed_attributes) }
170
+ end
171
+ end
172
+
173
+ context 'with invalid parameters' do
174
+ before do
175
+ allow(Spree.user_class).to receive(:find_by).and_return(nil)
176
+ allow(controller).to receive(:guest_checkout?).and_return(false)
177
+ end
178
+
179
+ it "expects to not assign user" do
180
+ send_request(changed_attributes)
181
+ expect(assigns[:user]).to_not eq(user)
182
+ end
183
+
184
+ context 'with correct method flow' do
185
+ it { expect(Spree.user_class).to receive(:find_by).with(id: user.id.to_s).and_return(nil) }
186
+ it "expects user class to receive find_by with email" do
187
+ expect(Spree.user_class).to receive(:find_by).
188
+ with(email: changed_attributes[:order][:email]).and_return(nil)
189
+ end
190
+ after { send_request(changed_attributes) }
191
+ end
192
+ end
193
+ end
194
+ end
195
+ end
196
+ end
197
+ end