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,74 @@
1
+ require 'spec_helper'
2
+
3
+ describe Spree::Admin::ReimbursementsController, type: :controller do
4
+ stub_authorization!
5
+
6
+ let!(:default_refund_reason) do
7
+ Spree::RefundReason.find_or_create_by!(name: Spree::RefundReason::RETURN_PROCESSING_REASON, mutable: false)
8
+ end
9
+
10
+ describe '#create' do
11
+ let(:customer_return) { create(:customer_return, line_items_count: 1) }
12
+ let(:order) { customer_return.order }
13
+ let(:return_item) { customer_return.return_items.first }
14
+ let(:payment) { order.payments.first }
15
+
16
+ subject do
17
+ spree_post :create, order_id: order.to_param, build_from_customer_return_id: customer_return.id
18
+ end
19
+
20
+ it 'creates the reimbursement' do
21
+ expect { subject }.to change { order.reimbursements.count }.by(1)
22
+ expect(assigns(:reimbursement).return_items.to_a).to eq customer_return.return_items.to_a
23
+ end
24
+
25
+ it 'redirects to the edit page' do
26
+ subject
27
+ expect(response).to redirect_to(spree.edit_admin_order_reimbursement_path(order, assigns(:reimbursement)))
28
+ end
29
+ end
30
+
31
+ describe "#perform" do
32
+ let(:reimbursement) { create(:reimbursement) }
33
+ let(:customer_return) { reimbursement.customer_return }
34
+ let(:order) { reimbursement.order }
35
+ let(:return_items) { reimbursement.return_items }
36
+ let(:payment) { order.payments.first }
37
+
38
+ subject do
39
+ spree_post :perform, order_id: order.to_param, id: reimbursement.to_param
40
+ end
41
+
42
+ it 'redirects to customer return page' do
43
+ subject
44
+ expect(response).to redirect_to spree.admin_order_reimbursement_path(order, reimbursement)
45
+ end
46
+
47
+ it 'performs the reimbursement' do
48
+ expect {
49
+ subject
50
+ }.to change { payment.refunds.count }.by(1)
51
+ expect(payment.refunds.last.amount).to be > 0
52
+ expect(payment.refunds.last.amount).to eq return_items.to_a.sum(&:total)
53
+ end
54
+
55
+ context "a Spree::Core::GatewayError is raised" do
56
+ before(:each) do
57
+ def controller.perform
58
+ raise Spree::Core::GatewayError.new('An error has occurred')
59
+ end
60
+ end
61
+
62
+ it "sets an error message with the correct text" do
63
+ subject
64
+ expect(flash[:error]).to eq 'An error has occurred'
65
+ end
66
+
67
+ it 'redirects to the edit page' do
68
+ subject
69
+ redirect_path = spree.edit_admin_order_reimbursement_path(order, assigns(:reimbursement))
70
+ expect(response).to redirect_to(redirect_path)
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,42 @@
1
+ require 'spec_helper'
2
+
3
+ describe Spree::Admin::ReportsController, type: :controller do
4
+ stub_authorization!
5
+
6
+ describe 'ReportsController.available_reports' do
7
+ it 'should contain sales_total' do
8
+ expect(Spree::Admin::ReportsController.available_reports.keys.include?(:sales_total)).to be true
9
+ end
10
+
11
+ it 'should have the proper sales total report description' do
12
+ expect(Spree::Admin::ReportsController.available_reports[:sales_total][:description]).to eql('Sales Total For All Orders')
13
+ end
14
+
15
+ end
16
+
17
+ describe 'ReportsController.add_available_report!' do
18
+ context 'when adding the report name' do
19
+ it 'should contain the report' do
20
+ Spree::Admin::ReportsController.add_available_report!(:some_report)
21
+ expect(Spree::Admin::ReportsController.available_reports.keys.include?(:some_report)).to be true
22
+ end
23
+ end
24
+ end
25
+
26
+ describe 'GET index' do
27
+ it 'should be ok' do
28
+ spree_get :index
29
+ expect(response).to be_ok
30
+ end
31
+ end
32
+
33
+ it 'should respond to model_class as Spree::AdminReportsController' do
34
+ expect(controller.send(:model_class)).to eql(Spree::Admin::ReportsController)
35
+ end
36
+
37
+ after(:each) do
38
+ Spree::Admin::ReportsController.available_reports.delete_if do |key, value|
39
+ key != :sales_total
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,252 @@
1
+ require 'spec_helper'
2
+
3
+ module Spree
4
+ module Admin
5
+ class WidgetsController < Spree::Admin::ResourceController
6
+ prepend_view_path('spec/test_views')
7
+
8
+ def model_class
9
+ Widget
10
+ end
11
+ end
12
+ end
13
+ end
14
+
15
+ describe Spree::Admin::WidgetsController, type: :controller do
16
+ stub_authorization!
17
+
18
+ after(:all) do
19
+ # Spree::Core::Engine.routes.reload_routes!
20
+ Rails.application.reload_routes!
21
+ end
22
+
23
+ with_model 'Widget', scope: :all do
24
+ table do |t|
25
+ t.string :name
26
+ t.integer :position
27
+ t.timestamps null: false
28
+ end
29
+
30
+ model do
31
+ acts_as_list
32
+ validates :name, presence: true
33
+ end
34
+ end
35
+
36
+ before do
37
+ Spree::Core::Engine.routes.draw do
38
+ namespace :admin do
39
+ resources :widgets do
40
+ post :update_positions, on: :member
41
+ end
42
+ end
43
+ end
44
+ stub_const('Spree::Widget', Widget)
45
+ end
46
+
47
+ describe '#new' do
48
+ subject do
49
+ spree_get :new
50
+ end
51
+
52
+ it 'succeeds' do
53
+ subject
54
+ expect(response).to be_success
55
+ end
56
+ end
57
+
58
+ describe '#edit' do
59
+ let(:widget) { Widget.create!(name: 'a widget') }
60
+
61
+ subject do
62
+ spree_get :edit, id: widget.to_param
63
+ end
64
+
65
+ it 'succeeds' do
66
+ subject
67
+ expect(response).to be_success
68
+ end
69
+ end
70
+
71
+ describe '#create' do
72
+ let(:params) do
73
+ {widget: {name: 'a widget'}}
74
+ end
75
+
76
+ subject { spree_post :create, params }
77
+
78
+ it 'creates the resource' do
79
+ expect { subject }.to change { Widget.count }.by(1)
80
+ end
81
+
82
+ context 'without any parameters' do
83
+ let(:params) { {} }
84
+
85
+ before do
86
+ allow_any_instance_of(Widget).to receive(:name).and_return('some name')
87
+ end
88
+
89
+ it 'creates the resource' do
90
+ expect { subject }.to change { Widget.count }.by(1)
91
+ end
92
+ end
93
+ end
94
+
95
+ describe '#update' do
96
+ let(:widget) { Widget.create!(name: 'a widget') }
97
+
98
+ let(:params) do
99
+ {
100
+ id: widget.to_param,
101
+ widget: {name: 'widget renamed'},
102
+ }
103
+ end
104
+
105
+ subject { spree_put :update, params }
106
+
107
+ it 'updates the resource' do
108
+ expect { subject }.to change { widget.reload.name }.from('a widget').to('widget renamed')
109
+ end
110
+ end
111
+
112
+ describe '#destroy' do
113
+ let!(:widget) { Widget.create!(name: 'a widget') }
114
+ let(:params) { {id: widget.id} }
115
+
116
+ subject {
117
+ spree_delete :destroy, params
118
+ }
119
+
120
+ it 'destroys the resource' do
121
+ expect { subject }.to change { Widget.count }.from(1).to(0)
122
+ end
123
+ end
124
+
125
+ describe '#update_positions' do
126
+ let(:widget_1) { Widget.create!(name: 'widget 1', position: 1) }
127
+ let(:widget_2) { Widget.create!(name: 'widget 2', position: 2) }
128
+
129
+ subject do
130
+ spree_post :update_positions, id: widget_1.to_param,
131
+ positions: { widget_1.id => '2', widget_2.id => '1' }, format: 'js'
132
+ end
133
+
134
+ it 'updates the position of widget 1' do
135
+ expect { subject }.to change { widget_1.reload.position }.from(1).to(2)
136
+ end
137
+
138
+ it 'updates the position of widget 2' do
139
+ expect { subject }.to change { widget_2.reload.position }.from(2).to(1)
140
+ end
141
+
142
+ it 'touches updated_at' do
143
+ Timecop.scale(3600) do
144
+ expect { subject }.to change { widget_1.reload.updated_at }
145
+ end
146
+ end
147
+ end
148
+ end
149
+
150
+ module Spree
151
+ module Submodule
152
+ class Post < Spree::Base
153
+ end
154
+ end
155
+ module Admin
156
+ module Submodule
157
+ class PostsController < Spree::Admin::ResourceController
158
+ prepend_view_path('spec/test_views')
159
+
160
+ def model_class
161
+ Spree::Submodule::Post
162
+ end
163
+ end
164
+ end
165
+ end
166
+ end
167
+
168
+ describe Spree::Admin::Submodule::PostsController, type: :controller do
169
+ stub_authorization!
170
+
171
+ after(:all) do
172
+ # Spree::Core::Engine.routes.reload_routes!
173
+ Rails.application.reload_routes!
174
+ end
175
+
176
+ with_table 'spree_posts', scope: :all do |t|
177
+ t.string :name
178
+ t.integer :position
179
+ t.timestamps null: false
180
+ end
181
+
182
+ before do
183
+ Spree::Core::Engine.routes.draw do
184
+ namespace :admin do
185
+ namespace :submodule do
186
+ resources :posts
187
+ end
188
+ end
189
+ end
190
+ end
191
+
192
+ describe '#new' do
193
+ subject do
194
+ spree_get :new
195
+ end
196
+
197
+ it 'succeeds' do
198
+ subject
199
+ expect(response).to be_success
200
+ end
201
+ end
202
+
203
+ describe '#edit' do
204
+ let(:submodule_post) { Spree::Submodule::Post.create!(name: 'a post') }
205
+
206
+ subject do
207
+ spree_get :edit, id: submodule_post.to_param
208
+ end
209
+
210
+ it 'succeeds' do
211
+ subject
212
+ expect(response).to be_success
213
+ end
214
+ end
215
+
216
+ describe '#create' do
217
+ let(:params) do
218
+ { submodule_post: { name: 'a post' } }
219
+ end
220
+
221
+ subject { spree_post :create, params }
222
+
223
+ it 'creates the resource' do
224
+ expect { subject }.to change { Spree::Submodule::Post.count }.by(1)
225
+ end
226
+ end
227
+
228
+ describe '#update' do
229
+ let(:post) { Spree::Submodule::Post.create!(name: 'a post') }
230
+
231
+ let(:params) do
232
+ { id: post.to_param, submodule_post: { name: 'post renamed' } }
233
+ end
234
+
235
+ subject { spree_put :update, params }
236
+
237
+ it 'updates the resource' do
238
+ expect { subject }.to change { post.reload.name }.from('a post').to('post renamed')
239
+ end
240
+ end
241
+
242
+ describe '#destroy' do
243
+ let!(:post) { Spree::Submodule::Post.create!(name: 'a post') }
244
+ let(:params) { { id: post.id } }
245
+
246
+ subject { spree_delete :destroy, params }
247
+
248
+ it 'destroys the resource' do
249
+ expect { subject }.to change { Spree::Submodule::Post.count }.from(1).to(0)
250
+ end
251
+ end
252
+ end
@@ -0,0 +1,225 @@
1
+ require 'spec_helper'
2
+
3
+ describe Spree::Admin::ReturnAuthorizationsController, type: :controller do
4
+ stub_authorization!
5
+
6
+ # Regression test for #1370 #3
7
+ let!(:order) { create(:shipped_order, line_items_count: 3) }
8
+ let!(:return_authorization_reason) { create(:return_authorization_reason) }
9
+ let(:inventory_unit_1) { order.inventory_units.order('id asc')[0] }
10
+ let(:inventory_unit_2) { order.inventory_units.order('id asc')[1] }
11
+ let(:inventory_unit_3) { order.inventory_units.order('id asc')[2] }
12
+
13
+ describe "#load_return_authorization_reasons" do
14
+ let!(:inactive_rma_reason) { create(:return_authorization_reason, active: false) }
15
+
16
+ context "return authorization has an associated inactive reason" do
17
+ let!(:other_inactive_rma_reason) { create(:return_authorization_reason, active: false) }
18
+ let(:return_authorization) { create(:return_authorization, reason: inactive_rma_reason) }
19
+
20
+ it "loads all the active rma reasons" do
21
+ spree_get :edit, id: return_authorization.to_param, order_id: return_authorization.order.to_param
22
+ expect(assigns(:reasons)).to include(return_authorization_reason)
23
+ expect(assigns(:reasons)).to include(inactive_rma_reason)
24
+ expect(assigns(:reasons)).not_to include(other_inactive_rma_reason)
25
+ end
26
+ end
27
+
28
+ context "return authorization has an associated active reason" do
29
+ let(:return_authorization) { create(:return_authorization, reason: return_authorization_reason) }
30
+
31
+ it "loads all the active rma reasons" do
32
+ spree_get :edit, id: return_authorization.to_param, order_id: return_authorization.order.to_param
33
+ expect(assigns(:reasons)).to eq [return_authorization_reason]
34
+ end
35
+ end
36
+
37
+ context "return authorization doesn't have an associated reason" do
38
+ it "loads all the active rma reasons" do
39
+ spree_get :new, order_id: order.to_param
40
+ expect(assigns(:reasons)).to eq [return_authorization_reason]
41
+ end
42
+ end
43
+ end
44
+
45
+ describe "#load_return_items" do
46
+ shared_context 'without existing return items' do
47
+ context 'without existing return items' do
48
+ it 'has 3 new @form_return_items' do
49
+ subject
50
+ expect(assigns(:form_return_items).size).to eq 3
51
+ expect(assigns(:form_return_items).select(&:new_record?).size).to eq 3
52
+ end
53
+ end
54
+ end
55
+
56
+ shared_context 'with existing return items' do
57
+ context 'with existing return items' do
58
+ let!(:return_item_1) { create(:return_item, inventory_unit: inventory_unit_1, return_authorization: return_authorization) }
59
+
60
+ it 'has 1 existing return item and 2 new return items' do
61
+ subject
62
+ expect(assigns(:form_return_items).size).to eq 3
63
+ expect(assigns(:form_return_items).select(&:persisted?)).to eq [return_item_1]
64
+ expect(assigns(:form_return_items).select(&:new_record?).size).to eq 2
65
+ end
66
+ end
67
+ end
68
+
69
+ context '#new' do
70
+ subject { spree_get :new, order_id: order.to_param }
71
+
72
+ include_context 'without existing return items'
73
+ end
74
+
75
+ context '#edit' do
76
+ subject do
77
+ spree_get :edit, {
78
+ id: return_authorization.to_param,
79
+ order_id: order.to_param,
80
+ }
81
+ end
82
+
83
+ let(:return_authorization) { create(:return_authorization, order: order) }
84
+
85
+ include_context 'without existing return items'
86
+ include_context 'with existing return items'
87
+ end
88
+
89
+ context '#create failed' do
90
+ subject do
91
+ spree_post :create, {
92
+ return_authorization: {return_authorization_reason_id: -1}, # invalid reason_id
93
+ order_id: order.to_param,
94
+ }
95
+ end
96
+
97
+ include_context 'without existing return items'
98
+ end
99
+
100
+ context '#update failed' do
101
+ subject do
102
+ spree_put :update, {
103
+ return_authorization: {return_authorization_reason_id: -1}, # invalid reason_id
104
+ id: return_authorization.to_param,
105
+ order_id: order.to_param,
106
+ }
107
+ end
108
+
109
+ let(:return_authorization) { create(:return_authorization, order: order) }
110
+
111
+ include_context 'without existing return items'
112
+ include_context 'with existing return items'
113
+ end
114
+ end
115
+
116
+ describe "#load_reimbursement_types" do
117
+ let(:order) { create(:order) }
118
+ let!(:inactive_reimbursement_type) { create(:reimbursement_type, active: false) }
119
+ let!(:first_active_reimbursement_type) { create(:reimbursement_type) }
120
+ let!(:second_active_reimbursement_type) { create(:reimbursement_type) }
121
+
122
+ before do
123
+ spree_get :new, order_id: order.to_param
124
+ end
125
+
126
+ it "loads all the active reimbursement types" do
127
+ expect(assigns(:reimbursement_types)).to include(first_active_reimbursement_type)
128
+ expect(assigns(:reimbursement_types)).to include(second_active_reimbursement_type)
129
+ expect(assigns(:reimbursement_types)).not_to include(inactive_reimbursement_type)
130
+ end
131
+ end
132
+
133
+ context '#create' do
134
+ let(:stock_location) { create(:stock_location) }
135
+
136
+ subject { spree_post :create, params }
137
+
138
+ let(:params) do
139
+ {
140
+ order_id: order.to_param,
141
+ return_authorization: return_authorization_params,
142
+ }
143
+ end
144
+
145
+ let(:return_authorization_params) do
146
+ {
147
+ memo: "",
148
+ stock_location_id: stock_location.id,
149
+ return_authorization_reason_id: return_authorization_reason.id,
150
+ }
151
+ end
152
+
153
+ it "can create a return authorization" do
154
+ subject
155
+ expect(response).to redirect_to spree.admin_order_return_authorizations_path(order)
156
+ end
157
+ end
158
+
159
+ context '#update' do
160
+ let(:return_authorization) { create(:return_authorization, order: order) }
161
+
162
+ let(:params) do
163
+ {
164
+ id: return_authorization.to_param,
165
+ order_id: order.to_param,
166
+ return_authorization: return_authorization_params,
167
+ }
168
+ end
169
+ let(:return_authorization_params) do
170
+ {
171
+ memo: "",
172
+ return_items_attributes: return_items_params,
173
+ }
174
+ end
175
+
176
+ subject { spree_put :update, params }
177
+
178
+ context "adding an item" do
179
+ let(:return_items_params) do
180
+ {
181
+ '0' => {inventory_unit_id: inventory_unit_1.to_param}
182
+ }
183
+ end
184
+
185
+ context 'without existing items' do
186
+ it 'creates a new item' do
187
+ expect { subject }.to change { Spree::ReturnItem.count }.by(1)
188
+ end
189
+ end
190
+
191
+ context 'with existing completed items' do
192
+ let!(:completed_return_item) do
193
+ create(:return_item, {
194
+ return_authorization: return_authorization,
195
+ inventory_unit: inventory_unit_1,
196
+ reception_status: 'received',
197
+ })
198
+ end
199
+
200
+ it 'does not create new items' do
201
+ expect { subject }.to_not change { Spree::ReturnItem.count }
202
+ expect(assigns[:return_authorization].errors['return_items.inventory_unit']).to eq ["#{inventory_unit_1.id} has already been taken by return item #{completed_return_item.id}"]
203
+ end
204
+ end
205
+ end
206
+
207
+ context "removing an item" do
208
+ let!(:return_item) do
209
+ create(:return_item, return_authorization: return_authorization, inventory_unit: inventory_unit_1)
210
+ end
211
+
212
+ let(:return_items_params) do
213
+ {
214
+ '0' => {id: return_item.to_param, _destroy: '1'}
215
+ }
216
+ end
217
+
218
+ context 'with existing items' do
219
+ it 'removes the item' do
220
+ expect { subject }.to change { Spree::ReturnItem.count }.by(-1)
221
+ end
222
+ end
223
+ end
224
+ end
225
+ end
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+
3
+ module Spree
4
+ module Admin
5
+ describe ReturnIndexController, type: :controller do
6
+ stub_authorization!
7
+
8
+ describe "#return_authorizations" do
9
+ let(:return_authorization) { create(:return_authorization) }
10
+
11
+ subject do
12
+ spree_get :return_authorizations
13
+ end
14
+
15
+ before { subject }
16
+
17
+ it "loads return authorizations" do
18
+ expect(assigns(:collection)).to include(return_authorization)
19
+ end
20
+ end
21
+
22
+ describe "#customer_returns" do
23
+ let(:customer_return) { create(:customer_return) }
24
+
25
+ subject do
26
+ spree_get :customer_returns
27
+ end
28
+
29
+ before { subject }
30
+
31
+ it "loads customer returns" do
32
+ expect(assigns(:collection)).to include(customer_return)
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe Spree::Admin::ReturnItemsController, type: :controller do
4
+ stub_authorization!
5
+
6
+ describe '#update' do
7
+ let(:customer_return) { create(:customer_return) }
8
+ let(:return_item) { customer_return.return_items.first }
9
+ let(:old_acceptance_status) { 'accepted' }
10
+ let(:new_acceptance_status) { 'rejected' }
11
+
12
+ subject do
13
+ spree_put :update, id: return_item.to_param, return_item: {acceptance_status: new_acceptance_status}
14
+ end
15
+
16
+ it 'updates the return item' do
17
+ expect {
18
+ subject
19
+ }.to change { return_item.reload.acceptance_status }.from(old_acceptance_status).to(new_acceptance_status)
20
+ end
21
+
22
+ it 'redirects to the custome return' do
23
+ subject
24
+ expect(response).to redirect_to spree.edit_admin_order_customer_return_path(customer_return.order, customer_return)
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ describe Spree::Admin::ShippingMethodsController, type: :controller do
4
+ stub_authorization!
5
+
6
+ # Regression test for #1240
7
+ it "should not hard-delete shipping methods" do
8
+ shipping_method = stub_model(Spree::ShippingMethod)
9
+ allow(Spree::ShippingMethod).to receive_messages find: shipping_method
10
+ expect(shipping_method.deleted_at).to be_nil
11
+ spree_delete :destroy, id: 1
12
+ expect(shipping_method.reload.deleted_at).not_to be_nil
13
+ end
14
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ module Spree
4
+ module Admin
5
+ describe StockItemsController, type: :controller do
6
+ stub_authorization!
7
+
8
+ context "formats" do
9
+ let!(:stock_item) { create(:variant).stock_items.first }
10
+
11
+ it "destroy stock item via js" do
12
+ expect {
13
+ spree_delete :destroy, format: :js, id: stock_item
14
+ }.to change{ StockItem.count }.by(-1)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end