solidus_starter_frontend 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (301) hide show
  1. checksums.yaml +7 -0
  2. data/.circleci/config.yml +57 -0
  3. data/.erb-lint.yml +22 -0
  4. data/.eslintrc +5 -0
  5. data/.gem_release.yml +5 -0
  6. data/.github/pull_request_template.md +28 -0
  7. data/.github/stale.yml +17 -0
  8. data/.gitignore +17 -0
  9. data/.hound.yml +16 -0
  10. data/.rspec +2 -0
  11. data/.rubocop.yml +19 -0
  12. data/.rubocop_todo.yml +229 -0
  13. data/.scss-lint.yml +4 -0
  14. data/Gemfile +34 -0
  15. data/LICENSE +26 -0
  16. data/README.md +69 -0
  17. data/Rakefile +6 -0
  18. data/app/assets/config/solidus_starter_frontend_manifest.js +2 -0
  19. data/app/assets/javascripts/spree/frontend.js +6 -0
  20. data/app/assets/javascripts/spree/frontend/cart.js +26 -0
  21. data/app/assets/javascripts/spree/frontend/checkout.js +34 -0
  22. data/app/assets/javascripts/spree/frontend/checkout/address.js +124 -0
  23. data/app/assets/javascripts/spree/frontend/checkout/payment.js +44 -0
  24. data/app/assets/javascripts/spree/frontend/locale_selector.js +9 -0
  25. data/app/assets/javascripts/spree/frontend/product.js +21 -0
  26. data/app/assets/javascripts/spree/frontend/solidus_starter_frontend.js +9 -0
  27. data/app/assets/javascripts/spree/frontend/utils.js.erb +18 -0
  28. data/app/assets/stylesheets/spree/frontend.css +8 -0
  29. data/app/assets/stylesheets/spree/frontend/base/_base.scss +29 -0
  30. data/app/assets/stylesheets/spree/frontend/base/_reset.scss +179 -0
  31. data/app/assets/stylesheets/spree/frontend/base/_responsive.scss +21 -0
  32. data/app/assets/stylesheets/spree/frontend/components/account/_account_order.scss +23 -0
  33. data/app/assets/stylesheets/spree/frontend/components/account/_account_summary.scss +17 -0
  34. data/app/assets/stylesheets/spree/frontend/components/auth/_auth_container.scss +11 -0
  35. data/app/assets/stylesheets/spree/frontend/components/auth/_auth_form.scss +5 -0
  36. data/app/assets/stylesheets/spree/frontend/components/brand/_logo.scss +4 -0
  37. data/app/assets/stylesheets/spree/frontend/components/buttons/_button_inline.scss +8 -0
  38. data/app/assets/stylesheets/spree/frontend/components/buttons/_button_primary.scss +26 -0
  39. data/app/assets/stylesheets/spree/frontend/components/cart/_cart_adjustments.scss +6 -0
  40. data/app/assets/stylesheets/spree/frontend/components/cart/_cart_amount_row.scss +11 -0
  41. data/app/assets/stylesheets/spree/frontend/components/cart/_cart_empty.scss +10 -0
  42. data/app/assets/stylesheets/spree/frontend/components/cart/_cart_footer.scss +20 -0
  43. data/app/assets/stylesheets/spree/frontend/components/cart/_cart_header.scss +12 -0
  44. data/app/assets/stylesheets/spree/frontend/components/cart/_cart_item.scss +86 -0
  45. data/app/assets/stylesheets/spree/frontend/components/cart/_cart_link.scss +22 -0
  46. data/app/assets/stylesheets/spree/frontend/components/cart/_cart_page.scss +15 -0
  47. data/app/assets/stylesheets/spree/frontend/components/cart/_cart_secondary_actions.scss +19 -0
  48. data/app/assets/stylesheets/spree/frontend/components/cart/_coupon_code.scss +8 -0
  49. data/app/assets/stylesheets/spree/frontend/components/cart/_item_info.scss +19 -0
  50. data/app/assets/stylesheets/spree/frontend/components/checkout/_checkout.scss +27 -0
  51. data/app/assets/stylesheets/spree/frontend/components/checkout/_checkout_header.scss +19 -0
  52. data/app/assets/stylesheets/spree/frontend/components/checkout/_checkout_summary.scss +31 -0
  53. data/app/assets/stylesheets/spree/frontend/components/checkout/_existing_cards.scss +27 -0
  54. data/app/assets/stylesheets/spree/frontend/components/checkout/_payment_method_controls.scss +5 -0
  55. data/app/assets/stylesheets/spree/frontend/components/checkout/_payment_method_selector.scss +14 -0
  56. data/app/assets/stylesheets/spree/frontend/components/checkout/_progress_steps.scss +38 -0
  57. data/app/assets/stylesheets/spree/frontend/components/checkout/_proposed_shipment.scss +18 -0
  58. data/app/assets/stylesheets/spree/frontend/components/checkout/_shipment_items.scss +50 -0
  59. data/app/assets/stylesheets/spree/frontend/components/checkout/_shipping_methods.scss +9 -0
  60. data/app/assets/stylesheets/spree/frontend/components/checkout/payments/_gateway_payment_method.scss +11 -0
  61. data/app/assets/stylesheets/spree/frontend/components/checkout/steps/_address_step.scss +20 -0
  62. data/app/assets/stylesheets/spree/frontend/components/checkout/steps/_confirm_step.scss +13 -0
  63. data/app/assets/stylesheets/spree/frontend/components/checkout/steps/_delivery_step.scss +13 -0
  64. data/app/assets/stylesheets/spree/frontend/components/checkout/steps/_payment_step.scss +13 -0
  65. data/app/assets/stylesheets/spree/frontend/components/forms/_address_inputs.scss +13 -0
  66. data/app/assets/stylesheets/spree/frontend/components/forms/inputs/_checkbox_input.scss +3 -0
  67. data/app/assets/stylesheets/spree/frontend/components/forms/inputs/_radio_input.scss +3 -0
  68. data/app/assets/stylesheets/spree/frontend/components/forms/inputs/_select_input.scss +27 -0
  69. data/app/assets/stylesheets/spree/frontend/components/forms/inputs/_text.scss +32 -0
  70. data/app/assets/stylesheets/spree/frontend/components/forms/inputs/_textarea_input.scss +25 -0
  71. data/app/assets/stylesheets/spree/frontend/components/general/_flash.scss +20 -0
  72. data/app/assets/stylesheets/spree/frontend/components/layout/_aside.scss +4 -0
  73. data/app/assets/stylesheets/spree/frontend/components/layout/_breadcrumbs.scss +16 -0
  74. data/app/assets/stylesheets/spree/frontend/components/layout/_category_navigation.scss +3 -0
  75. data/app/assets/stylesheets/spree/frontend/components/layout/_footer.scss +8 -0
  76. data/app/assets/stylesheets/spree/frontend/components/layout/_header.scss +12 -0
  77. data/app/assets/stylesheets/spree/frontend/components/layout/_horizontal_input_group.scss +7 -0
  78. data/app/assets/stylesheets/spree/frontend/components/layout/_top_bar.scss +44 -0
  79. data/app/assets/stylesheets/spree/frontend/components/navigation/_auth_link.scss +11 -0
  80. data/app/assets/stylesheets/spree/frontend/components/navigation/_categories.scss +29 -0
  81. data/app/assets/stylesheets/spree/frontend/components/navigation/_locale_selector.scss +21 -0
  82. data/app/assets/stylesheets/spree/frontend/components/navigation/_taxonomies.scss +7 -0
  83. data/app/assets/stylesheets/spree/frontend/components/navigation/_taxonomy.scss +28 -0
  84. data/app/assets/stylesheets/spree/frontend/components/orders/_address_overview.scss +27 -0
  85. data/app/assets/stylesheets/spree/frontend/components/orders/_coupon_codes.scss +4 -0
  86. data/app/assets/stylesheets/spree/frontend/components/orders/_line_items.scss +20 -0
  87. data/app/assets/stylesheets/spree/frontend/components/orders/_order_details.scss +18 -0
  88. data/app/assets/stylesheets/spree/frontend/components/orders/_order_item.scss +85 -0
  89. data/app/assets/stylesheets/spree/frontend/components/orders/_order_page.scss +41 -0
  90. data/app/assets/stylesheets/spree/frontend/components/orders/_order_shipments.scss +27 -0
  91. data/app/assets/stylesheets/spree/frontend/components/orders/_payment_info.scss +29 -0
  92. data/app/assets/stylesheets/spree/frontend/components/presentation/_hero.scss +18 -0
  93. data/app/assets/stylesheets/spree/frontend/components/products/_product_card.scss +35 -0
  94. data/app/assets/stylesheets/spree/frontend/components/products/_product_image.scss +7 -0
  95. data/app/assets/stylesheets/spree/frontend/components/products/_product_info.scss +14 -0
  96. data/app/assets/stylesheets/spree/frontend/components/products/_product_page.scss +31 -0
  97. data/app/assets/stylesheets/spree/frontend/components/products/_product_properties.scss +23 -0
  98. data/app/assets/stylesheets/spree/frontend/components/products/_product_submit.scss +9 -0
  99. data/app/assets/stylesheets/spree/frontend/components/products/_product_taxons.scss +27 -0
  100. data/app/assets/stylesheets/spree/frontend/components/products/_product_thumbnails.scss +7 -0
  101. data/app/assets/stylesheets/spree/frontend/components/products/_product_variants.scss +20 -0
  102. data/app/assets/stylesheets/spree/frontend/components/products/_products.scss +13 -0
  103. data/app/assets/stylesheets/spree/frontend/components/products/_products_by_taxon.scss +6 -0
  104. data/app/assets/stylesheets/spree/frontend/components/products/_products_grid.scss +18 -0
  105. data/app/assets/stylesheets/spree/frontend/components/search/_filter.scss +32 -0
  106. data/app/assets/stylesheets/spree/frontend/components/search/_search_bar.scss +34 -0
  107. data/app/assets/stylesheets/spree/frontend/components/typography/_hero_title.scss +6 -0
  108. data/app/assets/stylesheets/spree/frontend/components/typography/_subtitle.scss +7 -0
  109. data/app/assets/stylesheets/spree/frontend/placeholders/main.scss +5 -0
  110. data/app/assets/stylesheets/spree/frontend/screen.scss +89 -0
  111. data/app/assets/stylesheets/spree/frontend/solidus_starter_frontend.css +7 -0
  112. data/app/assets/stylesheets/spree/frontend/variables/_colors.scss +20 -0
  113. data/app/controllers/concerns/solidus_starter_frontend/auth_views.rb +16 -0
  114. data/app/controllers/concerns/solidus_starter_frontend/taxonomies.rb +16 -0
  115. data/app/controllers/spree/checkout_controller.rb +249 -0
  116. data/app/controllers/spree/coupon_codes_controller.rb +35 -0
  117. data/app/controllers/spree/home_controller.rb +13 -0
  118. data/app/controllers/spree/locale_controller.rb +20 -0
  119. data/app/controllers/spree/orders_controller.rb +126 -0
  120. data/app/controllers/spree/products_controller.rb +51 -0
  121. data/app/controllers/spree/store_controller.rb +31 -0
  122. data/app/controllers/spree/taxons_controller.rb +30 -0
  123. data/app/helpers/spree/orders_helper.rb +18 -0
  124. data/app/helpers/spree/taxon_filters_helper.rb +13 -0
  125. data/app/views/spree/address/_form_hidden.html.erb +12 -0
  126. data/app/views/spree/checkout/_terms_and_conditions.en.html.erb +1 -0
  127. data/app/views/spree/checkout/edit.html.erb +16 -0
  128. data/app/views/spree/checkout/existing_payment/_gateway.html.erb +9 -0
  129. data/app/views/spree/checkout/payment/_check.html.erb +0 -0
  130. data/app/views/spree/checkout/payment/_gateway.html.erb +43 -0
  131. data/app/views/spree/components/auth/_change_form.html.erb +40 -0
  132. data/app/views/spree/components/auth/_forgot_form.html.erb +28 -0
  133. data/app/views/spree/components/auth/_guest_form.html.erb +31 -0
  134. data/app/views/spree/components/auth/_login_form.html.erb +42 -0
  135. data/app/views/spree/components/auth/_signup_form.html.erb +48 -0
  136. data/app/views/spree/components/brand/_logo.html.erb +3 -0
  137. data/app/views/spree/components/buttons/_button_inline.html.erb +23 -0
  138. data/app/views/spree/components/buttons/_button_primary.html.erb +29 -0
  139. data/app/views/spree/components/cart/_cart_adjustment.html.erb +15 -0
  140. data/app/views/spree/components/cart/_cart_adjustments.html.erb +47 -0
  141. data/app/views/spree/components/cart/_cart_amount_row.html.erb +12 -0
  142. data/app/views/spree/components/cart/_cart_empty.html.erb +9 -0
  143. data/app/views/spree/components/cart/_cart_footer.html.erb +15 -0
  144. data/app/views/spree/components/cart/_cart_header.html.erb +17 -0
  145. data/app/views/spree/components/cart/_cart_item.html.erb +52 -0
  146. data/app/views/spree/components/cart/_cart_items.html.erb +23 -0
  147. data/app/views/spree/components/cart/_cart_link.html.erb +9 -0
  148. data/app/views/spree/components/cart/_cart_secondary_actions.html.erb +17 -0
  149. data/app/views/spree/components/cart/_item_info.html.erb +26 -0
  150. data/app/views/spree/components/checkout/_checkout_header.html.erb +8 -0
  151. data/app/views/spree/components/checkout/_checkout_step.html.erb +21 -0
  152. data/app/views/spree/components/checkout/_checkout_summary.html.erb +70 -0
  153. data/app/views/spree/components/checkout/_existing_cards.html.erb +39 -0
  154. data/app/views/spree/components/checkout/_payment_method_controls.html.erb +10 -0
  155. data/app/views/spree/components/checkout/_payment_method_selector.html.erb +14 -0
  156. data/app/views/spree/components/checkout/_proposed_shipment.erb +18 -0
  157. data/app/views/spree/components/checkout/_shipment_items.html.erb +22 -0
  158. data/app/views/spree/components/checkout/_shipping_methods.html.erb +20 -0
  159. data/app/views/spree/components/checkout/_unshippable_items.html.erb +7 -0
  160. data/app/views/spree/components/checkout/steps/_address_step.html.erb +60 -0
  161. data/app/views/spree/components/checkout/steps/_confirm_step.html.erb +31 -0
  162. data/app/views/spree/components/checkout/steps/_delivery_step.html.erb +31 -0
  163. data/app/views/spree/components/checkout/steps/_payment_step.html.erb +25 -0
  164. data/app/views/spree/components/forms/_address_inputs.html.erb +152 -0
  165. data/app/views/spree/components/forms/inputs/_checkbox_input.html.erb +29 -0
  166. data/app/views/spree/components/forms/inputs/_collection_select.html.erb +42 -0
  167. data/app/views/spree/components/forms/inputs/_radio_input.html.erb +29 -0
  168. data/app/views/spree/components/forms/inputs/_select_input.html.erb +31 -0
  169. data/app/views/spree/components/forms/inputs/_text.html.erb +54 -0
  170. data/app/views/spree/components/forms/inputs/_textarea_input.html.erb +42 -0
  171. data/app/views/spree/components/layout/_category_navigation.html.erb +3 -0
  172. data/app/views/spree/components/layout/_footer.html.erb +7 -0
  173. data/app/views/spree/components/layout/_header.html.erb +8 -0
  174. data/app/views/spree/components/layout/_top_bar.html.erb +8 -0
  175. data/app/views/spree/components/navigation/_auth_link.html.erb +1 -0
  176. data/app/views/spree/components/navigation/_breadcrumbs.html.erb +47 -0
  177. data/app/views/spree/components/navigation/_categories.html.erb +12 -0
  178. data/app/views/spree/components/navigation/_locale_selector.html.erb +25 -0
  179. data/app/views/spree/components/navigation/_taxonomies.html.erb +17 -0
  180. data/app/views/spree/components/navigation/_taxons.html.erb +17 -0
  181. data/app/views/spree/components/navigation/_taxons_tree.html.erb +29 -0
  182. data/app/views/spree/components/orders/_address_overview.html.erb +40 -0
  183. data/app/views/spree/components/orders/_coupon_code.html.erb +22 -0
  184. data/app/views/spree/components/orders/_line_items.html.erb +55 -0
  185. data/app/views/spree/components/orders/_order_details.html.erb +35 -0
  186. data/app/views/spree/components/orders/_order_item.html.erb +33 -0
  187. data/app/views/spree/components/orders/_order_items.html.erb +5 -0
  188. data/app/views/spree/components/orders/_order_shipments.html.erb +25 -0
  189. data/app/views/spree/components/orders/_payment_info.html.erb +31 -0
  190. data/app/views/spree/components/presentation/_hero.html.erb +14 -0
  191. data/app/views/spree/components/products/_product-card.html.erb +36 -0
  192. data/app/views/spree/components/products/_product_availability.html.erb +19 -0
  193. data/app/views/spree/components/products/_product_form.html.erb +21 -0
  194. data/app/views/spree/components/products/_product_image.html.erb +6 -0
  195. data/app/views/spree/components/products/_product_info.html.erb +9 -0
  196. data/app/views/spree/components/products/_product_promotions.html.erb +25 -0
  197. data/app/views/spree/components/products/_product_properties.html.erb +19 -0
  198. data/app/views/spree/components/products/_product_submit.html.erb +39 -0
  199. data/app/views/spree/components/products/_product_taxons.html.erb +15 -0
  200. data/app/views/spree/components/products/_product_thumbnails.html.erb +19 -0
  201. data/app/views/spree/components/products/_product_variants.html.erb +36 -0
  202. data/app/views/spree/components/products/_products-grid.html.erb +13 -0
  203. data/app/views/spree/components/products/_products.html.erb +28 -0
  204. data/app/views/spree/components/products/_products_by_taxon.html.erb +7 -0
  205. data/app/views/spree/components/products/_variants_list.html.erb +12 -0
  206. data/app/views/spree/components/search/_filter.html.erb +42 -0
  207. data/app/views/spree/components/search/_filters.html.erb +20 -0
  208. data/app/views/spree/components/search/_form.html.erb +12 -0
  209. data/app/views/spree/components/search/_products_search.html.erb +36 -0
  210. data/app/views/spree/components/search/_search_bar.html.erb +36 -0
  211. data/app/views/spree/components/typography/_hero_title.html.erb +11 -0
  212. data/app/views/spree/components/typography/_subtitle.html.erb +11 -0
  213. data/app/views/spree/home/index.html.erb +7 -0
  214. data/app/views/spree/layouts/spree_application.html.erb +27 -0
  215. data/app/views/spree/orders/edit.html.erb +21 -0
  216. data/app/views/spree/orders/show.html.erb +29 -0
  217. data/app/views/spree/products/index.html.erb +22 -0
  218. data/app/views/spree/products/show.html.erb +18 -0
  219. data/app/views/spree/shared/_image.html.erb +12 -0
  220. data/app/views/spree/shared/_link_to_cart.html.erb +1 -0
  221. data/app/views/spree/shared/_login_bar_items.html.erb +1 -0
  222. data/app/views/spree/shared/_shipment_tracking.html.erb +11 -0
  223. data/app/views/spree/shared/unauthorized.html.erb +0 -0
  224. data/app/views/spree/taxons/show.html.erb +17 -0
  225. data/bin/console +17 -0
  226. data/bin/r +13 -0
  227. data/bin/rails +7 -0
  228. data/bin/rake +7 -0
  229. data/bin/rspec +29 -0
  230. data/bin/sandbox +84 -0
  231. data/bin/sandbox_rails +18 -0
  232. data/bin/setup +8 -0
  233. data/bin/solidus_compare +155 -0
  234. data/config/initializers/assets.rb +1 -0
  235. data/config/initializers/canonical_rails.rb +16 -0
  236. data/config/locales/en.yml +5 -0
  237. data/config/routes.rb +33 -0
  238. data/config/solidus_compare.yml +33 -0
  239. data/docs/development.md +28 -0
  240. data/exe/solidus_starter_frontend +9 -0
  241. data/lib/generators/solidus_starter_frontend/install/install_generator.rb +15 -0
  242. data/lib/generators/solidus_starter_frontend/solidus_starter_frontend_generator.rb +30 -0
  243. data/lib/generators/solidus_starter_frontend/views/override_generator.rb +50 -0
  244. data/lib/solidus_starter_frontend.rb +12 -0
  245. data/lib/solidus_starter_frontend/config.rb +7 -0
  246. data/lib/solidus_starter_frontend/engine.rb +34 -0
  247. data/lib/solidus_starter_frontend/factories.rb +4 -0
  248. data/lib/solidus_starter_frontend/solidus_support_extensions.rb +9 -0
  249. data/lib/solidus_starter_frontend/version.rb +5 -0
  250. data/lib/solidus_starter_frontend_configuration.rb +8 -0
  251. data/lib/views/auth/spree/checkout/registration.html.erb +7 -0
  252. data/lib/views/auth/spree/components/navigation/_auth_link.html.erb +5 -0
  253. data/lib/views/auth/spree/user_passwords/edit.html.erb +7 -0
  254. data/lib/views/auth/spree/user_passwords/new.html.erb +5 -0
  255. data/lib/views/auth/spree/user_registrations/new.html.erb +7 -0
  256. data/lib/views/auth/spree/user_sessions/guest.html.erb +5 -0
  257. data/lib/views/auth/spree/user_sessions/new.html.erb +7 -0
  258. data/lib/views/auth/spree/users/edit.html.erb +45 -0
  259. data/lib/views/auth/spree/users/show.html.erb +55 -0
  260. data/solidus_starter_frontend.gemspec +43 -0
  261. data/spec/controllers/controller_helpers_spec.rb +29 -0
  262. data/spec/controllers/locale_controller_spec.rb +57 -0
  263. data/spec/controllers/spree/checkout_controller_spec.rb +563 -0
  264. data/spec/controllers/spree/checkout_controller_with_views_spec.rb +37 -0
  265. data/spec/controllers/spree/current_order_tracking_spec.rb +33 -0
  266. data/spec/controllers/spree/home_controller_spec.rb +29 -0
  267. data/spec/controllers/spree/orders_controller_ability_spec.rb +90 -0
  268. data/spec/controllers/spree/orders_controller_spec.rb +241 -0
  269. data/spec/controllers/spree/orders_controller_transitions_spec.rb +33 -0
  270. data/spec/controllers/spree/products_controller_spec.rb +38 -0
  271. data/spec/controllers/spree/taxons_controller_spec.rb +14 -0
  272. data/spec/fixtures/thinking-cat.jpg +0 -0
  273. data/spec/generators/solidus/views/override_generator_spec.rb +50 -0
  274. data/spec/helpers/base_helper_spec.rb +13 -0
  275. data/spec/helpers/order_helper_spec.rb +14 -0
  276. data/spec/helpers/taxon_filters_helper_spec.rb +12 -0
  277. data/spec/spec_helper.rb +64 -0
  278. data/spec/support/shared_contexts/checkout_setup.rb +12 -0
  279. data/spec/support/shared_contexts/custom_products.rb +28 -0
  280. data/spec/support/shared_contexts/locales.rb +16 -0
  281. data/spec/system/address_spec.rb +87 -0
  282. data/spec/system/automatic_promotion_adjustments_spec.rb +49 -0
  283. data/spec/system/caching/products_spec.rb +48 -0
  284. data/spec/system/caching/taxons_spec.rb +35 -0
  285. data/spec/system/cart_spec.rb +81 -0
  286. data/spec/system/checkout_confirm_insufficient_stock_spec.rb +71 -0
  287. data/spec/system/checkout_spec.rb +699 -0
  288. data/spec/system/checkout_unshippable_spec.rb +37 -0
  289. data/spec/system/coupon_code_spec.rb +267 -0
  290. data/spec/system/currency_spec.rb +20 -0
  291. data/spec/system/first_order_promotion_spec.rb +59 -0
  292. data/spec/system/free_shipping_promotions_spec.rb +60 -0
  293. data/spec/system/locale_spec.rb +26 -0
  294. data/spec/system/order_spec.rb +57 -0
  295. data/spec/system/products_spec.rb +302 -0
  296. data/spec/system/promotion_code_invalidation_spec.rb +54 -0
  297. data/spec/system/quantity_promotions_spec.rb +130 -0
  298. data/spec/system/taxons_spec.rb +158 -0
  299. data/spec/system/template_rendering_spec.rb +20 -0
  300. data/spec/views/spree/checkout/_summary_spec.rb +11 -0
  301. metadata +542 -0
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ # This spec is useful for when we just want to make sure a view is rendering correctly
6
+ # Walking through the entire checkout process is rather tedious, don't you think?
7
+ describe Spree::CheckoutController, type: :controller do
8
+ render_views
9
+ let(:token) { 'some_token' }
10
+ let(:user) { stub_model(Spree::LegacyUser) }
11
+
12
+ before do
13
+ allow(controller).to receive_messages try_spree_current_user: user
14
+ end
15
+
16
+ # Regression test for https://github.com/spree/spree/issues/3246
17
+ context "when using GBP" do
18
+ before do
19
+ stub_spree_preferences(currency: "GBP")
20
+ end
21
+
22
+ context "when order is in delivery" do
23
+ before do
24
+ # Using a let block won't acknowledge the currency setting
25
+ # Therefore we just do it like this...
26
+ order = Spree::TestingSupport::OrderWalkthrough.up_to(:address)
27
+ allow(controller).to receive_messages current_order: order
28
+ end
29
+
30
+ it "displays rate cost in correct currency" do
31
+ get :edit
32
+ html = Nokogiri::HTML(response.body)
33
+ expect(html.css('.shipping-methods__rate').text.strip).to have_content("£10.00")
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe 'current order tracking', type: :controller do
6
+ let!(:store) { create(:store) }
7
+ let(:user) { create(:user) }
8
+
9
+ controller(Spree::StoreController) do
10
+ def index
11
+ head :ok
12
+ end
13
+ end
14
+
15
+ let(:order) { FactoryBot.create(:order) }
16
+
17
+ it 'automatically tracks who the order was created by & IP address' do
18
+ allow(controller).to receive_messages(try_spree_current_user: user)
19
+ get :index
20
+ expect(controller.current_order(create_order_if_necessary: true).created_by).to eq controller.try_spree_current_user
21
+ expect(controller.current_order.last_ip_address).to eq "0.0.0.0"
22
+ end
23
+
24
+ context "current order creation" do
25
+ before { allow(controller).to receive_messages(try_spree_current_user: user) }
26
+
27
+ it "doesn't create a new order out of the blue" do
28
+ expect {
29
+ get :index
30
+ }.not_to change { Spree::Order.count }
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Spree::HomeController, type: :controller do
6
+ it "provides current user to the searcher class" do
7
+ user = mock_model(Spree.user_class, last_incomplete_spree_order: nil, spree_api_key: 'fake')
8
+ allow(controller).to receive_messages try_spree_current_user: user
9
+ expect_any_instance_of(Spree::Config.searcher_class).to receive(:current_user=).with(user)
10
+ get :index
11
+ expect(response.status).to eq(200)
12
+ end
13
+
14
+ context "layout" do
15
+ it "renders default layout" do
16
+ get :index
17
+ expect(response).to render_template(layout: 'spree/layouts/spree_application')
18
+ end
19
+
20
+ context "different layout specified in config" do
21
+ before { stub_spree_preferences(layout: 'layouts/application') }
22
+
23
+ it "renders specified layout" do
24
+ get :index
25
+ expect(response).to render_template(layout: 'layouts/application')
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,90 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ module Spree
6
+ describe OrdersController, type: :controller do
7
+ ORDER_TOKEN = 'ORDER_TOKEN'
8
+
9
+ let!(:store) { create(:store) }
10
+ let(:order) { Spree::Order.create }
11
+ let(:variant) { create(:variant) }
12
+
13
+ it 'should understand order routes with token' do
14
+ expect(spree.token_order_path('R123456', 'ABCDEF')).to eq('/orders/R123456/token/ABCDEF')
15
+ end
16
+
17
+ context 'when an order exists in the cookies.signed' do
18
+ let(:token) { 'some_token' }
19
+
20
+ before do
21
+ allow(controller).to receive_messages current_order: order
22
+ end
23
+
24
+ context '#populate' do
25
+ it 'should check if user is authorized for :update' do
26
+ expect(controller).to receive(:authorize!).with(:update, order, token)
27
+ post :populate, params: { variant_id: variant.id, token: token }
28
+ end
29
+ end
30
+
31
+ context '#edit' do
32
+ it 'should check if user is authorized for :read' do
33
+ expect(controller).to receive(:authorize!).with(:read, order, token)
34
+ get :edit, params: { token: token }
35
+ end
36
+ end
37
+
38
+ context '#update' do
39
+ it 'should check if user is authorized for :update' do
40
+ allow(order).to receive :update
41
+ expect(controller).to receive(:authorize!).with(:update, order, token)
42
+ post :update, params: { order: { email: "foo@bar.com" }, token: token }
43
+ end
44
+ end
45
+
46
+ context '#empty' do
47
+ it 'should check if user is authorized for :update' do
48
+ expect(controller).to receive(:authorize!).with(:update, order, token)
49
+ post :empty, params: { token: token }
50
+ end
51
+ end
52
+
53
+ context "#show" do
54
+ let(:specified_order) { create(:order) }
55
+
56
+ it "should check against the specified order" do
57
+ expect(controller).to receive(:authorize!).with(:read, specified_order, token)
58
+ get :show, params: { id: specified_order.number, token: token }
59
+ end
60
+ end
61
+ end
62
+
63
+ context 'when no authenticated user' do
64
+ let(:order) { create(:order, number: 'R123') }
65
+
66
+ context '#show' do
67
+ context 'when token parameter present' do
68
+ it 'always ooverride existing token when passing a new one' do
69
+ cookies.signed[:guest_token] = "soo wrong"
70
+ get :show, params: { id: 'R123', token: order.guest_token }
71
+ expect(cookies.signed[:guest_token]).to eq(order.guest_token)
72
+ end
73
+
74
+ it 'should store as guest_token in session' do
75
+ get :show, params: { id: 'R123', token: order.guest_token }
76
+ expect(cookies.signed[:guest_token]).to eq(order.guest_token)
77
+ end
78
+ end
79
+
80
+ context 'when no token present' do
81
+ it 'should respond with 404' do
82
+ expect {
83
+ get :show, params: { id: 'R123' }
84
+ }.to raise_error(ActiveRecord::RecordNotFound)
85
+ end
86
+ end
87
+ end
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,241 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Spree::OrdersController, type: :controller do
6
+ let!(:store) { create(:store) }
7
+ let(:user) { create(:user) }
8
+
9
+ context "Order model mock" do
10
+ let(:order) do
11
+ Spree::Order.create!
12
+ end
13
+ let(:variant) { create(:variant) }
14
+
15
+ before do
16
+ allow(controller).to receive_messages(try_spree_current_user: user)
17
+ end
18
+
19
+ context "#populate" do
20
+ it "should create a new order when none specified" do
21
+ post :populate, params: { variant_id: variant.id }
22
+ expect(response).to be_redirect
23
+ expect(cookies.signed[:guest_token]).not_to be_blank
24
+
25
+ order_by_token = Spree::Order.find_by(guest_token: cookies.signed[:guest_token])
26
+ assigned_order = assigns[:order]
27
+
28
+ expect(assigned_order).to eq order_by_token
29
+ expect(assigned_order).to be_persisted
30
+ end
31
+
32
+ context "with Variant" do
33
+ it "should handle population" do
34
+ expect do
35
+ post :populate, params: { variant_id: variant.id, quantity: 5 }
36
+ end.to change { user.orders.count }.by(1)
37
+ order = user.orders.last
38
+ expect(response).to redirect_to spree.cart_path
39
+ expect(order.line_items.size).to eq(1)
40
+ line_item = order.line_items.first
41
+ expect(line_item.variant_id).to eq(variant.id)
42
+ expect(line_item.quantity).to eq(5)
43
+ end
44
+
45
+ it "shows an error when population fails" do
46
+ request.env["HTTP_REFERER"] = spree.root_path
47
+ allow_any_instance_of(Spree::LineItem).to(
48
+ receive(:valid?).and_return(false)
49
+ )
50
+ allow_any_instance_of(Spree::LineItem).to(
51
+ receive_message_chain(:errors, :full_messages).
52
+ and_return(["Order population failed"])
53
+ )
54
+
55
+ post :populate, params: { variant_id: variant.id, quantity: 5 }
56
+
57
+ expect(response).to redirect_to(spree.root_path)
58
+ expect(flash[:error]).to eq("Order population failed")
59
+ end
60
+
61
+ it "shows an error when quantity is invalid" do
62
+ request.env["HTTP_REFERER"] = spree.root_path
63
+
64
+ post(
65
+ :populate,
66
+ params: { variant_id: variant.id, quantity: -1 }
67
+ )
68
+
69
+ expect(response).to redirect_to(spree.root_path)
70
+ expect(flash[:error]).to eq(
71
+ I18n.t('spree.please_enter_reasonable_quantity')
72
+ )
73
+ end
74
+
75
+ context "when quantity is empty string" do
76
+ it "should populate order with 1 of given variant" do
77
+ expect do
78
+ post :populate, params: { variant_id: variant.id, quantity: '' }
79
+ end.to change { Spree::Order.count }.by(1)
80
+ order = Spree::Order.last
81
+ expect(response).to redirect_to spree.cart_path
82
+ expect(order.line_items.size).to eq(1)
83
+ line_item = order.line_items.first
84
+ expect(line_item.variant_id).to eq(variant.id)
85
+ expect(line_item.quantity).to eq(1)
86
+ end
87
+ end
88
+
89
+ context "when quantity is nil" do
90
+ it "should populate order with 1 of given variant" do
91
+ expect do
92
+ post :populate, params: { variant_id: variant.id, quantity: nil }
93
+ end.to change { Spree::Order.count }.by(1)
94
+ order = Spree::Order.last
95
+ expect(response).to redirect_to spree.cart_path
96
+ expect(order.line_items.size).to eq(1)
97
+ line_item = order.line_items.first
98
+ expect(line_item.variant_id).to eq(variant.id)
99
+ expect(line_item.quantity).to eq(1)
100
+ end
101
+ end
102
+ end
103
+ end
104
+
105
+ context '#edit' do
106
+ before do
107
+ allow(controller).to receive :authorize!
108
+ allow(controller).to receive_messages current_order: order
109
+ end
110
+
111
+ it 'should render cart' do
112
+ get :edit, params: { id: order.number }
113
+
114
+ expect(flash[:error]).to be_nil
115
+ expect(response).to be_ok
116
+ end
117
+
118
+ context 'with another order number than the current_order' do
119
+ let(:other_order) { create(:completed_order_with_totals) }
120
+
121
+ it 'should display error message' do
122
+ get :edit, params: { id: other_order.number }
123
+
124
+ expect(flash[:error]).to eq "You may only edit your current shopping cart."
125
+ expect(response).to redirect_to cart_path
126
+ end
127
+ end
128
+ end
129
+
130
+ context "#update" do
131
+ context "with authorization" do
132
+ before do
133
+ allow(controller).to receive :authorize!
134
+ allow(controller).to receive_messages current_order: order
135
+ end
136
+
137
+ it "should render the edit view (on failure)" do
138
+ # email validation is only after address state
139
+ order.update_column(:state, "delivery")
140
+ put :update, params: { order: { email: "" } }
141
+ expect(response).to render_template :edit
142
+ end
143
+
144
+ it "should redirect to cart path (on success)" do
145
+ allow(order).to receive(:update).and_return true
146
+ put :update
147
+ expect(response).to redirect_to(spree.cart_path)
148
+ end
149
+
150
+ it "should advance the order if :checkout button is pressed" do
151
+ allow(order).to receive(:update).and_return true
152
+ expect(order).to receive(:next)
153
+ put :update, params: { checkout: true }
154
+ expect(response).to redirect_to checkout_state_path('address')
155
+ end
156
+
157
+ context 'trying to apply a coupon code' do
158
+ let(:order) { create(:order_with_line_items, state: 'cart') }
159
+ let(:coupon_code) { "coupon_code" }
160
+
161
+ context "when coupon code is empty" do
162
+ let(:coupon_code) { "" }
163
+
164
+ it 'does not try to apply coupon code' do
165
+ expect(Spree::PromotionHandler::Coupon).not_to receive :new
166
+
167
+ put :update, params: { state: order.state, order: { coupon_code: coupon_code } }
168
+
169
+ expect(response).to redirect_to(spree.cart_path)
170
+ end
171
+ end
172
+ end
173
+ end
174
+ end
175
+
176
+ context "#empty" do
177
+ before do
178
+ allow(controller).to receive :authorize!
179
+ end
180
+
181
+ it "should destroy line items in the current order" do
182
+ allow(controller).to receive(:current_order).and_return(order)
183
+ expect(order).to receive(:empty!)
184
+ put :empty
185
+ expect(response).to redirect_to(spree.cart_path)
186
+ end
187
+ end
188
+
189
+ # Regression test for https://github.com/spree/spree/issues/2750
190
+ context "#update" do
191
+ before do
192
+ allow(user).to receive :last_incomplete_spree_order
193
+ allow(controller).to receive :set_current_order
194
+ end
195
+
196
+ it "cannot update a blank order" do
197
+ put :update, params: { order: { email: "foo" } }
198
+ expect(flash[:error]).to eq(I18n.t('spree.order_not_found'))
199
+ expect(response).to redirect_to(spree.root_path)
200
+ end
201
+ end
202
+ end
203
+
204
+ context "line items quantity is 0" do
205
+ let(:order) { Spree::Order.create(store: store) }
206
+ let(:variant) { create(:variant) }
207
+ let!(:line_item) { order.contents.add(variant, 1) }
208
+
209
+ before do
210
+ allow(controller).to receive :authorize!
211
+ allow(controller).to receive_messages(current_order: order)
212
+ end
213
+
214
+ it "removes line items on update" do
215
+ expect(order.line_items.count).to eq 1
216
+ put :update, params: { order: { line_items_attributes: { "0" => { id: line_item.id, quantity: 0 } } } }
217
+ expect(order.reload.line_items.count).to eq 0
218
+ end
219
+ end
220
+
221
+ describe '#edit' do
222
+ subject { get :edit }
223
+ let(:user) { build :user }
224
+
225
+ it "builds a new valid order with complete meta-data" do
226
+ allow(controller).to receive_messages(try_spree_current_user: user)
227
+
228
+ subject
229
+
230
+ order = controller.instance_variable_get(:@order)
231
+
232
+ aggregate_failures do
233
+ expect(order).to be_valid
234
+ expect(order).not_to be_persisted
235
+ expect(order.store).to be_present
236
+ expect(order.user).to eq(user)
237
+ expect(order.created_by).to eq(user)
238
+ end
239
+ end
240
+ end
241
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ Spree::Order.class_eval do
6
+ attr_accessor :did_transition
7
+ end
8
+
9
+ module Spree
10
+ describe OrdersController, type: :controller do
11
+ # Regression test for https://github.com/spree/spree/issues/2004
12
+ context "with a transition callback on first state" do
13
+ let(:order) { Spree::Order.new }
14
+
15
+ before do
16
+ allow(controller).to receive_messages current_order: order
17
+ expect(controller).to receive(:authorize!).at_least(:once).and_return(true)
18
+
19
+ first_state, = Spree::Order.checkout_steps.first
20
+ Spree::Order.state_machine.after_transition to: first_state do |order|
21
+ order.did_transition = true
22
+ end
23
+ end
24
+
25
+ it "correctly calls the transition callback" do
26
+ expect(order.did_transition).to be_nil
27
+ order.line_items << FactoryBot.create(:line_item)
28
+ put :update, params: { checkout: "checkout" }
29
+ expect(order.did_transition).to be true
30
+ end
31
+ end
32
+ end
33
+ end