spree_frontend 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 (336) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/logo/spree_50.png +0 -0
  3. data/app/assets/javascripts/spree/frontend/cart.js.coffee +14 -1
  4. data/app/assets/javascripts/spree/frontend/checkout/payment.js.coffee +11 -35
  5. data/app/assets/javascripts/spree/frontend/checkout/shipment.js.coffee +38 -0
  6. data/app/assets/javascripts/spree/frontend/coupon_manager.js.coffee +37 -0
  7. data/app/assets/stylesheets/spree/frontend/frontend_bootstrap.css.scss +3 -3
  8. data/app/controllers/spree/checkout_controller.rb +0 -14
  9. data/app/controllers/spree/content_controller.rb +3 -3
  10. data/app/controllers/spree/orders_controller.rb +7 -2
  11. data/app/controllers/spree/products_controller.rb +3 -2
  12. data/app/controllers/spree/store_controller.rb +0 -18
  13. data/app/helpers/spree/frontend_helper.rb +1 -1
  14. data/app/helpers/spree/orders_helper.rb +0 -9
  15. data/app/views/kaminari/twitter-bootstrap-3/_first_page.html.erb +1 -1
  16. data/app/views/kaminari/twitter-bootstrap-3/_last_page.html.erb +1 -1
  17. data/app/views/kaminari/twitter-bootstrap-3/_next_page.html.erb +1 -1
  18. data/app/views/kaminari/twitter-bootstrap-3/_page.html.erb +1 -1
  19. data/app/views/kaminari/twitter-bootstrap-3/_prev_page.html.erb +1 -1
  20. data/app/views/spree/address/_form.html.erb +16 -16
  21. data/app/views/spree/checkout/_address.html.erb +4 -4
  22. data/app/views/spree/checkout/_confirm.html.erb +2 -2
  23. data/app/views/spree/checkout/_delivery.html.erb +5 -3
  24. data/app/views/spree/checkout/_payment.html.erb +3 -3
  25. data/app/views/spree/checkout/_summary.html.erb +3 -3
  26. data/app/views/spree/checkout/edit.html.erb +1 -0
  27. data/app/views/spree/checkout/payment/_gateway.html.erb +8 -8
  28. data/app/views/spree/home/index.html.erb +3 -2
  29. data/app/views/spree/orders/_adjustment_row.html.erb +1 -1
  30. data/app/views/spree/orders/_adjustments.html.erb +3 -3
  31. data/app/views/spree/orders/edit.html.erb +15 -2
  32. data/app/views/spree/products/_properties.html.erb +1 -1
  33. data/app/views/spree/products/index.html.erb +5 -5
  34. data/app/views/spree/products/show.html.erb +6 -6
  35. data/app/views/spree/shared/_address.html.erb +3 -1
  36. data/app/views/spree/shared/_error_messages.html.erb +1 -1
  37. data/app/views/spree/shared/_filters.html.erb +2 -2
  38. data/app/views/spree/shared/_google_add_items.js.erb +5 -5
  39. data/app/views/spree/shared/_head.html.erb +2 -0
  40. data/app/views/spree/shared/_header.html.erb +2 -2
  41. data/app/views/spree/shared/_login.html.erb +4 -4
  42. data/app/views/spree/shared/_nav_bar.html.erb +1 -1
  43. data/app/views/spree/shared/_order_details.html.erb +2 -2
  44. data/app/views/spree/shared/_search.html.erb +3 -3
  45. data/app/views/spree/shared/_translations.html.erb +7 -0
  46. data/config/initializers/assets.rb +1 -1
  47. data/config/routes.rb +1 -6
  48. data/lib/tasks/taxon.rake +2 -2
  49. data/spec/controllers/controller_extension_spec.rb +126 -0
  50. data/spec/controllers/controller_helpers_spec.rb +122 -0
  51. data/spec/controllers/spree/checkout_controller_spec.rb +462 -0
  52. data/spec/controllers/spree/checkout_controller_with_views_spec.rb +36 -0
  53. data/spec/controllers/spree/content_controller_spec.rb +12 -0
  54. data/spec/controllers/spree/current_order_tracking_spec.rb +44 -0
  55. data/spec/controllers/spree/home_controller_spec.rb +47 -0
  56. data/spec/controllers/spree/orders_controller_ability_spec.rb +96 -0
  57. data/spec/controllers/spree/orders_controller_spec.rb +134 -0
  58. data/spec/controllers/spree/orders_controller_transitions_spec.rb +31 -0
  59. data/spec/controllers/spree/products_controller_spec.rb +87 -0
  60. data/spec/controllers/spree/taxons_controller_spec.rb +12 -0
  61. data/spec/features/address_spec.rb +93 -0
  62. data/spec/features/automatic_promotion_adjustments_spec.rb +47 -0
  63. data/spec/features/caching/products_spec.rb +59 -0
  64. data/spec/features/caching/taxons_spec.rb +22 -0
  65. data/spec/features/cart_spec.rb +132 -0
  66. data/spec/features/checkout_spec.rb +572 -0
  67. data/spec/features/checkout_unshippable_spec.rb +34 -0
  68. data/spec/features/coupon_code_spec.rb +88 -0
  69. data/spec/features/currency_spec.rb +18 -0
  70. data/spec/features/delivery_spec.rb +64 -0
  71. data/spec/features/free_shipping_promotions_spec.rb +59 -0
  72. data/spec/features/locale_spec.rb +60 -0
  73. data/spec/features/microdata_spec.rb +0 -0
  74. data/spec/features/order_spec.rb +107 -0
  75. data/spec/features/page_promotions_spec.rb +36 -0
  76. data/spec/features/products_spec.rb +334 -0
  77. data/spec/features/taxons_spec.rb +147 -0
  78. data/spec/features/template_rendering_spec.rb +19 -0
  79. data/spec/helpers/frontend_helper_spec.rb +57 -0
  80. data/spec/helpers/taxons_helper_spec.rb +17 -0
  81. data/spec/spec_helper.rb +126 -0
  82. data/spec/support/shared_contexts/checkout_setup.rb +10 -0
  83. data/spec/support/shared_contexts/custom_products.rb +25 -0
  84. data/spec/support/shared_contexts/product_prototypes.rb +30 -0
  85. data/spec/views/spree/checkout/_summary_spec.rb +11 -0
  86. data/spree_frontend.gemspec +6 -3
  87. metadata +92 -263
  88. data/app/assets/images/flags/ad.png +0 -0
  89. data/app/assets/images/flags/ae.png +0 -0
  90. data/app/assets/images/flags/af.png +0 -0
  91. data/app/assets/images/flags/ag.png +0 -0
  92. data/app/assets/images/flags/ai.png +0 -0
  93. data/app/assets/images/flags/al.png +0 -0
  94. data/app/assets/images/flags/am.png +0 -0
  95. data/app/assets/images/flags/an.png +0 -0
  96. data/app/assets/images/flags/ao.png +0 -0
  97. data/app/assets/images/flags/ar.png +0 -0
  98. data/app/assets/images/flags/as.png +0 -0
  99. data/app/assets/images/flags/at.png +0 -0
  100. data/app/assets/images/flags/au.png +0 -0
  101. data/app/assets/images/flags/aw.png +0 -0
  102. data/app/assets/images/flags/ax.png +0 -0
  103. data/app/assets/images/flags/az.png +0 -0
  104. data/app/assets/images/flags/ba.png +0 -0
  105. data/app/assets/images/flags/bb.png +0 -0
  106. data/app/assets/images/flags/bd.png +0 -0
  107. data/app/assets/images/flags/be.png +0 -0
  108. data/app/assets/images/flags/bf.png +0 -0
  109. data/app/assets/images/flags/bg.png +0 -0
  110. data/app/assets/images/flags/bh.png +0 -0
  111. data/app/assets/images/flags/bi.png +0 -0
  112. data/app/assets/images/flags/bj.png +0 -0
  113. data/app/assets/images/flags/bm.png +0 -0
  114. data/app/assets/images/flags/bn.png +0 -0
  115. data/app/assets/images/flags/bo.png +0 -0
  116. data/app/assets/images/flags/br.png +0 -0
  117. data/app/assets/images/flags/bs.png +0 -0
  118. data/app/assets/images/flags/bt.png +0 -0
  119. data/app/assets/images/flags/bv.png +0 -0
  120. data/app/assets/images/flags/bw.png +0 -0
  121. data/app/assets/images/flags/by.png +0 -0
  122. data/app/assets/images/flags/bz.png +0 -0
  123. data/app/assets/images/flags/ca.png +0 -0
  124. data/app/assets/images/flags/catalonia.png +0 -0
  125. data/app/assets/images/flags/cc.png +0 -0
  126. data/app/assets/images/flags/cd.png +0 -0
  127. data/app/assets/images/flags/cf.png +0 -0
  128. data/app/assets/images/flags/cg.png +0 -0
  129. data/app/assets/images/flags/ch.png +0 -0
  130. data/app/assets/images/flags/ci.png +0 -0
  131. data/app/assets/images/flags/ck.png +0 -0
  132. data/app/assets/images/flags/cl.png +0 -0
  133. data/app/assets/images/flags/cm.png +0 -0
  134. data/app/assets/images/flags/cn.png +0 -0
  135. data/app/assets/images/flags/co.png +0 -0
  136. data/app/assets/images/flags/cr.png +0 -0
  137. data/app/assets/images/flags/cs.png +0 -0
  138. data/app/assets/images/flags/cu.png +0 -0
  139. data/app/assets/images/flags/cv.png +0 -0
  140. data/app/assets/images/flags/cx.png +0 -0
  141. data/app/assets/images/flags/cy.png +0 -0
  142. data/app/assets/images/flags/cz.png +0 -0
  143. data/app/assets/images/flags/de.png +0 -0
  144. data/app/assets/images/flags/dj.png +0 -0
  145. data/app/assets/images/flags/dk.png +0 -0
  146. data/app/assets/images/flags/dm.png +0 -0
  147. data/app/assets/images/flags/do.png +0 -0
  148. data/app/assets/images/flags/dz.png +0 -0
  149. data/app/assets/images/flags/ec.png +0 -0
  150. data/app/assets/images/flags/ee.png +0 -0
  151. data/app/assets/images/flags/eg.png +0 -0
  152. data/app/assets/images/flags/eh.png +0 -0
  153. data/app/assets/images/flags/england.png +0 -0
  154. data/app/assets/images/flags/er.png +0 -0
  155. data/app/assets/images/flags/es.png +0 -0
  156. data/app/assets/images/flags/et.png +0 -0
  157. data/app/assets/images/flags/europeanunion.png +0 -0
  158. data/app/assets/images/flags/fam.png +0 -0
  159. data/app/assets/images/flags/fi.png +0 -0
  160. data/app/assets/images/flags/fj.png +0 -0
  161. data/app/assets/images/flags/fk.png +0 -0
  162. data/app/assets/images/flags/fm.png +0 -0
  163. data/app/assets/images/flags/fo.png +0 -0
  164. data/app/assets/images/flags/fr.png +0 -0
  165. data/app/assets/images/flags/ga.png +0 -0
  166. data/app/assets/images/flags/gb.png +0 -0
  167. data/app/assets/images/flags/gd.png +0 -0
  168. data/app/assets/images/flags/ge.png +0 -0
  169. data/app/assets/images/flags/gf.png +0 -0
  170. data/app/assets/images/flags/gh.png +0 -0
  171. data/app/assets/images/flags/gi.png +0 -0
  172. data/app/assets/images/flags/gl.png +0 -0
  173. data/app/assets/images/flags/gm.png +0 -0
  174. data/app/assets/images/flags/gn.png +0 -0
  175. data/app/assets/images/flags/gp.png +0 -0
  176. data/app/assets/images/flags/gq.png +0 -0
  177. data/app/assets/images/flags/gr.png +0 -0
  178. data/app/assets/images/flags/gs.png +0 -0
  179. data/app/assets/images/flags/gt.png +0 -0
  180. data/app/assets/images/flags/gu.png +0 -0
  181. data/app/assets/images/flags/gw.png +0 -0
  182. data/app/assets/images/flags/gy.png +0 -0
  183. data/app/assets/images/flags/hk.png +0 -0
  184. data/app/assets/images/flags/hm.png +0 -0
  185. data/app/assets/images/flags/hn.png +0 -0
  186. data/app/assets/images/flags/hr.png +0 -0
  187. data/app/assets/images/flags/ht.png +0 -0
  188. data/app/assets/images/flags/hu.png +0 -0
  189. data/app/assets/images/flags/id.png +0 -0
  190. data/app/assets/images/flags/ie.png +0 -0
  191. data/app/assets/images/flags/il.png +0 -0
  192. data/app/assets/images/flags/in.png +0 -0
  193. data/app/assets/images/flags/io.png +0 -0
  194. data/app/assets/images/flags/iq.png +0 -0
  195. data/app/assets/images/flags/ir.png +0 -0
  196. data/app/assets/images/flags/is.png +0 -0
  197. data/app/assets/images/flags/it.png +0 -0
  198. data/app/assets/images/flags/ja.png +0 -0
  199. data/app/assets/images/flags/jm.png +0 -0
  200. data/app/assets/images/flags/jo.png +0 -0
  201. data/app/assets/images/flags/ke.png +0 -0
  202. data/app/assets/images/flags/kg.png +0 -0
  203. data/app/assets/images/flags/kh.png +0 -0
  204. data/app/assets/images/flags/ki.png +0 -0
  205. data/app/assets/images/flags/km.png +0 -0
  206. data/app/assets/images/flags/kn.png +0 -0
  207. data/app/assets/images/flags/kp.png +0 -0
  208. data/app/assets/images/flags/kr.png +0 -0
  209. data/app/assets/images/flags/kw.png +0 -0
  210. data/app/assets/images/flags/ky.png +0 -0
  211. data/app/assets/images/flags/kz.png +0 -0
  212. data/app/assets/images/flags/la.png +0 -0
  213. data/app/assets/images/flags/lb.png +0 -0
  214. data/app/assets/images/flags/lc.png +0 -0
  215. data/app/assets/images/flags/li.png +0 -0
  216. data/app/assets/images/flags/lk.png +0 -0
  217. data/app/assets/images/flags/lr.png +0 -0
  218. data/app/assets/images/flags/ls.png +0 -0
  219. data/app/assets/images/flags/lt.png +0 -0
  220. data/app/assets/images/flags/lu.png +0 -0
  221. data/app/assets/images/flags/lv.png +0 -0
  222. data/app/assets/images/flags/ly.png +0 -0
  223. data/app/assets/images/flags/ma.png +0 -0
  224. data/app/assets/images/flags/mc.png +0 -0
  225. data/app/assets/images/flags/md.png +0 -0
  226. data/app/assets/images/flags/me.png +0 -0
  227. data/app/assets/images/flags/mg.png +0 -0
  228. data/app/assets/images/flags/mh.png +0 -0
  229. data/app/assets/images/flags/mk.png +0 -0
  230. data/app/assets/images/flags/ml.png +0 -0
  231. data/app/assets/images/flags/mm.png +0 -0
  232. data/app/assets/images/flags/mn.png +0 -0
  233. data/app/assets/images/flags/mo.png +0 -0
  234. data/app/assets/images/flags/mp.png +0 -0
  235. data/app/assets/images/flags/mq.png +0 -0
  236. data/app/assets/images/flags/mr.png +0 -0
  237. data/app/assets/images/flags/ms.png +0 -0
  238. data/app/assets/images/flags/mt.png +0 -0
  239. data/app/assets/images/flags/mu.png +0 -0
  240. data/app/assets/images/flags/mv.png +0 -0
  241. data/app/assets/images/flags/mw.png +0 -0
  242. data/app/assets/images/flags/mx.png +0 -0
  243. data/app/assets/images/flags/my.png +0 -0
  244. data/app/assets/images/flags/mz.png +0 -0
  245. data/app/assets/images/flags/na.png +0 -0
  246. data/app/assets/images/flags/nc.png +0 -0
  247. data/app/assets/images/flags/ne.png +0 -0
  248. data/app/assets/images/flags/nf.png +0 -0
  249. data/app/assets/images/flags/ng.png +0 -0
  250. data/app/assets/images/flags/ni.png +0 -0
  251. data/app/assets/images/flags/nl.png +0 -0
  252. data/app/assets/images/flags/no.png +0 -0
  253. data/app/assets/images/flags/np.png +0 -0
  254. data/app/assets/images/flags/nr.png +0 -0
  255. data/app/assets/images/flags/nu.png +0 -0
  256. data/app/assets/images/flags/nz.png +0 -0
  257. data/app/assets/images/flags/om.png +0 -0
  258. data/app/assets/images/flags/pa.png +0 -0
  259. data/app/assets/images/flags/pe.png +0 -0
  260. data/app/assets/images/flags/pf.png +0 -0
  261. data/app/assets/images/flags/pg.png +0 -0
  262. data/app/assets/images/flags/ph.png +0 -0
  263. data/app/assets/images/flags/pk.png +0 -0
  264. data/app/assets/images/flags/pl.png +0 -0
  265. data/app/assets/images/flags/pm.png +0 -0
  266. data/app/assets/images/flags/pn.png +0 -0
  267. data/app/assets/images/flags/pr.png +0 -0
  268. data/app/assets/images/flags/ps.png +0 -0
  269. data/app/assets/images/flags/pt.png +0 -0
  270. data/app/assets/images/flags/pw.png +0 -0
  271. data/app/assets/images/flags/py.png +0 -0
  272. data/app/assets/images/flags/qa.png +0 -0
  273. data/app/assets/images/flags/re.png +0 -0
  274. data/app/assets/images/flags/ro.png +0 -0
  275. data/app/assets/images/flags/rs.png +0 -0
  276. data/app/assets/images/flags/ru.png +0 -0
  277. data/app/assets/images/flags/rw.png +0 -0
  278. data/app/assets/images/flags/sa.png +0 -0
  279. data/app/assets/images/flags/sb.png +0 -0
  280. data/app/assets/images/flags/sc.png +0 -0
  281. data/app/assets/images/flags/scotland.png +0 -0
  282. data/app/assets/images/flags/sd.png +0 -0
  283. data/app/assets/images/flags/se.png +0 -0
  284. data/app/assets/images/flags/sg.png +0 -0
  285. data/app/assets/images/flags/sh.png +0 -0
  286. data/app/assets/images/flags/si.png +0 -0
  287. data/app/assets/images/flags/sj.png +0 -0
  288. data/app/assets/images/flags/sk.png +0 -0
  289. data/app/assets/images/flags/sl.png +0 -0
  290. data/app/assets/images/flags/sm.png +0 -0
  291. data/app/assets/images/flags/sn.png +0 -0
  292. data/app/assets/images/flags/so.png +0 -0
  293. data/app/assets/images/flags/sr.png +0 -0
  294. data/app/assets/images/flags/st.png +0 -0
  295. data/app/assets/images/flags/sv.png +0 -0
  296. data/app/assets/images/flags/sy.png +0 -0
  297. data/app/assets/images/flags/sz.png +0 -0
  298. data/app/assets/images/flags/tc.png +0 -0
  299. data/app/assets/images/flags/td.png +0 -0
  300. data/app/assets/images/flags/tf.png +0 -0
  301. data/app/assets/images/flags/tg.png +0 -0
  302. data/app/assets/images/flags/th.png +0 -0
  303. data/app/assets/images/flags/tj.png +0 -0
  304. data/app/assets/images/flags/tk.png +0 -0
  305. data/app/assets/images/flags/tl.png +0 -0
  306. data/app/assets/images/flags/tm.png +0 -0
  307. data/app/assets/images/flags/tn.png +0 -0
  308. data/app/assets/images/flags/to.png +0 -0
  309. data/app/assets/images/flags/tr.png +0 -0
  310. data/app/assets/images/flags/tt.png +0 -0
  311. data/app/assets/images/flags/tv.png +0 -0
  312. data/app/assets/images/flags/tw.png +0 -0
  313. data/app/assets/images/flags/tz.png +0 -0
  314. data/app/assets/images/flags/ua.png +0 -0
  315. data/app/assets/images/flags/ug.png +0 -0
  316. data/app/assets/images/flags/um.png +0 -0
  317. data/app/assets/images/flags/us.png +0 -0
  318. data/app/assets/images/flags/uy.png +0 -0
  319. data/app/assets/images/flags/uz.png +0 -0
  320. data/app/assets/images/flags/va.png +0 -0
  321. data/app/assets/images/flags/vc.png +0 -0
  322. data/app/assets/images/flags/ve.png +0 -0
  323. data/app/assets/images/flags/vg.png +0 -0
  324. data/app/assets/images/flags/vi.png +0 -0
  325. data/app/assets/images/flags/vn.png +0 -0
  326. data/app/assets/images/flags/vu.png +0 -0
  327. data/app/assets/images/flags/wales.png +0 -0
  328. data/app/assets/images/flags/wf.png +0 -0
  329. data/app/assets/images/flags/ws.png +0 -0
  330. data/app/assets/images/flags/ye.png +0 -0
  331. data/app/assets/images/flags/yt.png +0 -0
  332. data/app/assets/images/flags/za.png +0 -0
  333. data/app/assets/images/flags/zm.png +0 -0
  334. data/app/assets/images/flags/zw.png +0 -0
  335. data/app/assets/images/spree_header.jpg +0 -0
  336. data/app/views/spree/products/_image.html.erb +0 -5
@@ -1,7 +1,7 @@
1
1
  <nav class="navbar col-md-8 col-sm-9" id="top-nav-bar">
2
2
  <ul id="nav-bar" class="nav navbar-nav navbar-right" data-hook>
3
3
  <li id="search-bar" data-hook>
4
- <%= render :partial => 'spree/shared/search' %>
4
+ <%= render partial: 'spree/shared/search' %>
5
5
  </li>
6
6
  </ul>
7
7
  </nav>
@@ -67,8 +67,8 @@
67
67
  <% end %>
68
68
  </td>
69
69
  <td data-hook="order_item_description">
70
- <h4><%= item.variant.product.name %></h4>
71
- <%= truncated_product_description(item.variant.product) %>
70
+ <h4><%= item.name %></h4>
71
+ <%= truncate(item.description, length: 100) %>
72
72
  <%= "(" + item.variant.options_text + ")" unless item.variant.option_values.empty? %>
73
73
  </td>
74
74
  <td data-hook="order_item_price" class="lead text-primary price"><span><%= item.single_money.to_html %></span></td>
@@ -1,6 +1,6 @@
1
1
  <% @taxons = @taxon && @taxon.parent ? @taxon.parent.children : Spree::Taxon.roots %>
2
2
 
3
- <%= form_tag spree.products_path, :method => :get, class: "navbar-form" do %>
3
+ <%= form_tag spree.products_path, method: :get, class: "navbar-form" do %>
4
4
  <div class="form-group">
5
5
  <% cache(cache_key_for_taxons) do %>
6
6
  <%= select_tag :taxon,
@@ -10,7 +10,7 @@
10
10
  <% end %>
11
11
  </div>
12
12
  <div class="form-group">
13
- <%= search_field_tag :keywords, params[:keywords], :placeholder => Spree.t(:search), class: "form-control" %>
13
+ <%= search_field_tag :keywords, params[:keywords], placeholder: Spree.t(:search), class: "form-control" %>
14
14
  </div>
15
- <%= submit_tag Spree.t(:search), :name => nil, class: "btn btn-success" %>
15
+ <%= submit_tag Spree.t(:search), name: nil, class: "btn btn-success" %>
16
16
  <% end %>
@@ -0,0 +1,7 @@
1
+ <script>
2
+ Spree.translations = <%==
3
+ {
4
+ coupon_code_applied: Spree.t(:coupon_code_applied)
5
+ }.to_json
6
+ %>
7
+ </script>
@@ -1 +1 @@
1
- Rails.application.config.assets.precompile += %w( favicon.ico credit_cards/* flags/* )
1
+ Rails.application.config.assets.precompile += %w( favicon.ico credit_cards/* spree/frontend/checkout/shipment )
@@ -7,12 +7,7 @@ Spree::Core::Engine.add_routes do
7
7
  get '/checkout/:state', to: 'checkout#edit', as: :checkout_state
8
8
  get '/checkout', to: 'checkout#edit', as: :checkout
9
9
 
10
- populate_redirect = redirect do |params, request|
11
- request.flash[:error] = Spree.t(:populate_get_error)
12
- request.referer || '/cart'
13
- end
14
-
15
- get '/orders/populate', to: populate_redirect
10
+ get '/orders/populate', to: 'orders#populate_redirect'
16
11
 
17
12
  resources :orders, except: [:index, :new, :create, :destroy] do
18
13
  post :populate, on: :collection
@@ -1,7 +1,7 @@
1
1
  namespace :spree do
2
2
  desc "Resets all taxon permalinks"
3
- task :reset_taxon_permalinks => :environment do
4
- Spree::Taxon.where(:parent_id => nil).each {|taxon| redo_permalinks(taxon) }
3
+ task reset_taxon_permalinks: :environment do
4
+ Spree::Taxon.where(parent_id: nil).each {|taxon| redo_permalinks(taxon) }
5
5
  end
6
6
 
7
7
  def redo_permalinks(taxon)
@@ -0,0 +1,126 @@
1
+ require 'spec_helper'
2
+
3
+ # This test tests the functionality within
4
+ # spree/core/controller_helpers/respond_with.rb
5
+ # Rather than duck-punching the existing controllers, let's define a custom one:
6
+ class Spree::CustomController < Spree::BaseController
7
+ def index
8
+ respond_with(Spree::Address.new) do |format|
9
+ format.html { render plain: "neutral" }
10
+ end
11
+ end
12
+
13
+ def create
14
+ # Just need a model with validations
15
+ # Address is good enough, so let's go with that
16
+ address = Spree::Address.new(params[:address])
17
+ respond_with(address)
18
+ end
19
+ end
20
+
21
+ describe Spree::CustomController, type: :controller do
22
+ after do
23
+ Spree::CustomController.clear_overrides!
24
+ end
25
+
26
+ before do
27
+ @routes = ActionDispatch::Routing::RouteSet.new.tap do |r|
28
+ r.draw {
29
+ get 'index', to: 'spree/custom#index'
30
+ post 'create', to: 'spree/custom#create'
31
+ }
32
+ end
33
+ end
34
+
35
+ context "extension testing" do
36
+ context "index" do
37
+ context "specify symbol for handler instead of Proc" do
38
+ before do
39
+ Spree::CustomController.class_eval do
40
+ respond_override({index: {html: {success: :success_method}}})
41
+
42
+ private
43
+
44
+ def success_method
45
+ render plain: 'success!!!'
46
+ end
47
+ end
48
+ end
49
+
50
+ describe "GET" do
51
+ it "has value success" do
52
+ spree_get :index
53
+ expect(response).to be_success
54
+ assert (response.body =~ /success!!!/)
55
+ end
56
+ end
57
+ end
58
+
59
+ context "render" do
60
+ before do
61
+ Spree::CustomController.instance_eval do
62
+ respond_override(index: { html: { success: lambda { render(plain: 'success!!!') } } })
63
+ respond_override(index: { html: { failure: lambda { render(plain: 'failure!!!') } } })
64
+ end
65
+ end
66
+
67
+ describe "GET" do
68
+ it "has value success" do
69
+ spree_get :index
70
+ expect(response).to be_success
71
+ assert (response.body =~ /success!!!/)
72
+ end
73
+ end
74
+ end
75
+
76
+ context "redirect" do
77
+ before do
78
+ Spree::CustomController.instance_eval do
79
+ respond_override({index: {html: {success: lambda { redirect_to('/cart') }}}})
80
+ respond_override(index: { html: { failure: lambda { render(plain: 'failure!!!') } } })
81
+ end
82
+ end
83
+
84
+ describe "GET" do
85
+ it "has value success" do
86
+ spree_get :index
87
+ expect(response).to be_redirect
88
+ end
89
+ end
90
+ end
91
+
92
+ context "validation error" do
93
+ before do
94
+ Spree::CustomController.instance_eval do
95
+ respond_to :html
96
+ respond_override(create: { html: { success: lambda { render(plain: 'success!!!') } } })
97
+ respond_override(create: { html: { failure: lambda { render(plain: 'failure!!!') } } })
98
+ end
99
+ end
100
+
101
+ describe "POST" do
102
+ it "has value success" do
103
+ spree_post :create
104
+ expect(response).to be_success
105
+ assert (response.body =~ /success!/)
106
+ end
107
+ end
108
+ end
109
+
110
+ context 'A different controllers respond_override. Regression test for #1301' do
111
+ before do
112
+ Spree::CheckoutController.instance_eval do
113
+ respond_override(index: { html: { success: lambda { render(plain: 'success!!!') } } })
114
+ end
115
+ end
116
+
117
+ describe "POST" do
118
+ it "should not effect the wrong controller" do
119
+ spree_get :index
120
+ assert (response.body =~ /neutral/)
121
+ end
122
+ end
123
+ end
124
+ end
125
+ end
126
+ end
@@ -0,0 +1,122 @@
1
+ require 'spec_helper'
2
+
3
+ # In this file, we want to test that the controller helpers function correctly
4
+ # So we need to use one of the controllers inside Spree.
5
+ # ProductsController is good.
6
+ describe Spree::ProductsController, type: :controller do
7
+
8
+ let!(:available_locales) { [:en, :de] }
9
+ let!(:available_locale) { :de }
10
+ let!(:unavailable_locale) { :ru }
11
+
12
+ before do
13
+ I18n.enforce_available_locales = false
14
+ expect(I18n).to receive(:available_locales).and_return(available_locales)
15
+ end
16
+
17
+ after do
18
+ Spree::Frontend::Config[:locale] = :en
19
+ Rails.application.config.i18n.default_locale = :en
20
+ I18n.locale = :en
21
+ I18n.enforce_available_locales = true
22
+ end
23
+
24
+ # Regression test for #1184
25
+ context 'when session locale not set' do
26
+ before(:each) do
27
+ session[:locale] = nil
28
+ end
29
+
30
+ context 'when Spree::Frontend::Config[:locale] not present' do
31
+ before(:each) do
32
+ Spree::Frontend::Config[:locale] = nil
33
+ end
34
+
35
+ context 'when rails application default locale not set' do
36
+ before(:each) do
37
+ Rails.application.config.i18n.default_locale = nil
38
+ end
39
+
40
+ it "sets the I18n default locale" do
41
+ spree_get :index
42
+ expect(I18n.locale).to eq(I18n.default_locale)
43
+ end
44
+ end
45
+
46
+ context 'when rails application default locale is set' do
47
+ context 'and not in available_locales' do
48
+ before(:each) do
49
+ Rails.application.config.i18n.default_locale = unavailable_locale
50
+ end
51
+
52
+ it "sets the I18n default locale" do
53
+ spree_get :index
54
+ expect(I18n.locale).to eq(I18n.default_locale)
55
+ end
56
+ end
57
+
58
+ context 'and in available_locales' do
59
+ before(:each) do
60
+ Rails.application.config.i18n.default_locale = available_locale
61
+ end
62
+
63
+ it "sets the rails app locale" do
64
+ expect(I18n.locale).to eq(:en)
65
+ spree_get :index
66
+ expect(I18n.locale).to eq(available_locale)
67
+ end
68
+ end
69
+ end
70
+ end
71
+
72
+ context 'when Spree::Frontend::Config[:locale] is present' do
73
+ context 'and not in available_locales' do
74
+ before(:each) do
75
+ Spree::Frontend::Config[:locale] = unavailable_locale
76
+ end
77
+
78
+ it "sets the I18n default locale" do
79
+ spree_get :index
80
+ expect(I18n.locale).to eq(I18n.default_locale)
81
+ end
82
+ end
83
+
84
+ context 'and not in available_locales' do
85
+ before(:each) do
86
+ Spree::Frontend::Config[:locale] = available_locale
87
+ end
88
+
89
+ it "sets the default locale based on Spree::Frontend::Config[:locale]" do
90
+ expect(I18n.locale).to eq(:en)
91
+ spree_get :index
92
+ expect(I18n.locale).to eq(available_locale)
93
+ end
94
+ end
95
+ end
96
+ end
97
+
98
+ context 'when session locale is set' do
99
+ context 'and not in available_locales' do
100
+ before(:each) do
101
+ session[:locale] = unavailable_locale
102
+ end
103
+
104
+ it "sets the I18n default locale" do
105
+ spree_get :index
106
+ expect(I18n.locale).to eq(I18n.default_locale)
107
+ end
108
+ end
109
+
110
+ context 'and in available_locales' do
111
+ before(:each) do
112
+ session[:locale] = available_locale
113
+ end
114
+
115
+ it "sets the session locale" do
116
+ expect(I18n.locale).to eq(:en)
117
+ spree_get :index
118
+ expect(I18n.locale).to eq(available_locale)
119
+ end
120
+ end
121
+ end
122
+ end
@@ -0,0 +1,462 @@
1
+ require 'spec_helper'
2
+
3
+ describe Spree::CheckoutController, type: :controller do
4
+ let(:token) { 'some_token' }
5
+ let(:user) { stub_model(Spree::LegacyUser) }
6
+ let(:order) { FactoryGirl.create(:order_with_totals) }
7
+
8
+ let(:address_params) do
9
+ address = FactoryGirl.build(:address)
10
+ address.attributes.except("created_at", "updated_at")
11
+ end
12
+
13
+ before do
14
+ allow(controller).to receive_messages try_spree_current_user: user
15
+ allow(controller).to receive_messages spree_current_user: user
16
+ allow(controller).to receive_messages current_order: order
17
+ end
18
+
19
+ context "#edit" do
20
+ it 'should check if the user is authorized for :edit' do
21
+ expect(controller).to receive(:authorize!).with(:edit, order, token)
22
+ request.cookie_jar.signed[:guest_token] = token
23
+ spree_get :edit, state: 'address'
24
+ end
25
+
26
+ it "should redirect to the cart path unless checkout_allowed?" do
27
+ allow(order).to receive_messages checkout_allowed?: false
28
+ spree_get :edit, state: "delivery"
29
+ expect(response).to redirect_to(spree.cart_path)
30
+ end
31
+
32
+ it "should redirect to the cart path if current_order is nil" do
33
+ allow(controller).to receive(:current_order).and_return(nil)
34
+ spree_get :edit, state: "delivery"
35
+ expect(response).to redirect_to(spree.cart_path)
36
+ end
37
+
38
+ it "should redirect to cart if order is completed" do
39
+ allow(order).to receive_messages(completed?: true)
40
+ spree_get :edit, state: "address"
41
+ expect(response).to redirect_to(spree.cart_path)
42
+ end
43
+
44
+ # Regression test for #2280
45
+ it "should redirect to current step trying to access a future step" do
46
+ order.update_column(:state, "address")
47
+ spree_get :edit, state: "delivery"
48
+ expect(response).to redirect_to spree.checkout_state_path("address")
49
+ end
50
+
51
+ context "when entering the checkout" do
52
+ before do
53
+ # The first step for checkout controller is address
54
+ # Transitioning into this state first is required
55
+ order.update_column(:state, "address")
56
+ end
57
+
58
+ it "should associate the order with a user" do
59
+ order.update_column :user_id, nil
60
+ expect(order).to receive(:associate_user!).with(user)
61
+ spree_get :edit, {}, order_id: 1
62
+ end
63
+ end
64
+ end
65
+
66
+ context "#update" do
67
+ it 'should check if the user is authorized for :edit' do
68
+ expect(controller).to receive(:authorize!).with(:edit, order, token)
69
+ request.cookie_jar.signed[:guest_token] = token
70
+ spree_post :update, state: 'address'
71
+ end
72
+
73
+ context "save successful" do
74
+ def spree_post_address
75
+ spree_post :update,
76
+ state: "address",
77
+ order: {
78
+ bill_address_attributes: address_params,
79
+ use_billing: true
80
+ }
81
+ end
82
+
83
+ before do
84
+ # Must have *a* shipping method and a payment method so updating from address works
85
+ allow(order).to receive(:available_shipping_methods).
86
+ and_return [stub_model(Spree::ShippingMethod)]
87
+ allow(order).to receive(:available_payment_methods).
88
+ and_return [stub_model(Spree::PaymentMethod)]
89
+ allow(order).to receive(:ensure_available_shipping_rates).
90
+ and_return true
91
+ order.line_items << FactoryGirl.create(:line_item)
92
+ end
93
+
94
+ context "with the order in the cart state" do
95
+ before do
96
+ order.update_column(:state, "cart")
97
+ allow(order).to receive_messages user: user
98
+ end
99
+
100
+ it "should assign order" do
101
+ spree_post :update, state: "address"
102
+ expect(assigns[:order]).not_to be_nil
103
+ end
104
+
105
+ it "should advance the state" do
106
+ spree_post_address
107
+ expect(order.reload.state).to eq("delivery")
108
+ end
109
+
110
+ it "should redirect the next state" do
111
+ spree_post_address
112
+ expect(response).to redirect_to spree.checkout_state_path("delivery")
113
+ end
114
+
115
+ context "current_user respond to save address method" do
116
+ it "calls persist order address on user" do
117
+ expect(user).to receive(:persist_order_address)
118
+ spree_post :update,
119
+ state: "address",
120
+ order: {
121
+ bill_address_attributes: address_params,
122
+ use_billing: true
123
+ },
124
+ save_user_address: "1"
125
+ end
126
+ end
127
+
128
+ context "current_user doesnt respond to persist_order_address" do
129
+ it "doesnt raise any error" do
130
+ expect do
131
+ spree_post :update,
132
+ state: "address",
133
+ order: {
134
+ bill_address_attributes: address_params,
135
+ use_billing: true
136
+ },
137
+ save_user_address: "1"
138
+ end.to_not raise_error
139
+ end
140
+ end
141
+ end
142
+
143
+ context "with the order in the address state" do
144
+ before do
145
+ order.update_columns(ship_address_id: create(:address).id, state: "address")
146
+ allow(order).to receive_messages user: user
147
+ end
148
+
149
+ context "with a billing and shipping address" do
150
+ let(:bill_address_params) do
151
+ order.bill_address.attributes.except("created_at", "updated_at")
152
+ end
153
+ let(:ship_address_params) do
154
+ order.ship_address.attributes.except("created_at", "updated_at")
155
+ end
156
+ let(:update_params) do
157
+ {
158
+ state: "address",
159
+ order: {
160
+ bill_address_attributes: bill_address_params,
161
+ ship_address_attributes: ship_address_params,
162
+ use_billing: false
163
+ }
164
+ }
165
+ end
166
+
167
+ before do
168
+ @expected_bill_address_id = order.bill_address.id
169
+ @expected_ship_address_id = order.ship_address.id
170
+
171
+ spree_post :update, update_params
172
+ order.reload
173
+ end
174
+
175
+ it "updates the same billing and shipping address" do
176
+ expect(order.bill_address.id).to eq(@expected_bill_address_id)
177
+ expect(order.ship_address.id).to eq(@expected_ship_address_id)
178
+ end
179
+ end
180
+ end
181
+
182
+ context "when in the confirm state" do
183
+ before do
184
+ allow(order).to receive_messages confirmation_required?: true
185
+ order.update_column(:state, "confirm")
186
+ allow(order).to receive_messages user: user
187
+ # An order requires a payment to reach the complete state
188
+ # This is because payment_required? is true on the order
189
+ create(:payment, amount: order.total, order: order)
190
+ order.payments.reload
191
+ end
192
+
193
+ # This inadvertently is a regression test for #2694
194
+ it "should redirect to the order view" do
195
+ spree_post :update, state: "confirm"
196
+ expect(response).to redirect_to spree.order_path(order)
197
+ end
198
+
199
+ it "should populate the flash message" do
200
+ spree_post :update, state: "confirm"
201
+ expect(flash.notice).to eq(Spree.t(:order_processed_successfully))
202
+ end
203
+
204
+ it "should remove completed order from current_order" do
205
+ spree_post :update, { state: "confirm" }, order_id: "foofah"
206
+ expect(assigns(:current_order)).to be_nil
207
+ expect(assigns(:order)).to eql controller.current_order
208
+ end
209
+ end
210
+
211
+ # Regression test for #4190
212
+ context "state_lock_version" do
213
+ let(:post_params) do
214
+ {
215
+ state: "address",
216
+ order: {
217
+ bill_address_attributes: order.bill_address.attributes.except("created_at", "updated_at"),
218
+ state_lock_version: 0,
219
+ use_billing: true
220
+ }
221
+ }
222
+ end
223
+
224
+ context "correct" do
225
+ it "should properly update and increment version" do
226
+ spree_post :update, post_params
227
+ expect(order.state_lock_version).to eq 1
228
+ end
229
+ end
230
+
231
+ context "incorrect" do
232
+ before do
233
+ order.update_columns(state_lock_version: 1, state: "address")
234
+ end
235
+
236
+ it "order should receieve ensure_valid_order_version callback" do
237
+ expect_any_instance_of(described_class).to receive(:ensure_valid_state_lock_version)
238
+ spree_post :update, post_params
239
+ end
240
+
241
+ it "order should receieve with_lock message" do
242
+ expect(order).to receive(:with_lock)
243
+ spree_post :update, post_params
244
+ end
245
+
246
+ it "redirects back to current state" do
247
+ spree_post :update, post_params
248
+ expect(response).to redirect_to spree.checkout_state_path('address')
249
+ expect(flash[:error]).to eq "The order has already been updated."
250
+ end
251
+ end
252
+ end
253
+ end
254
+
255
+ context "save unsuccessful" do
256
+ before do
257
+ allow(order).to receive_messages user: user
258
+ allow(order).to receive_messages update_attributes: false
259
+ end
260
+
261
+ it "should not assign order" do
262
+ spree_post :update, state: "address"
263
+ expect(assigns[:order]).not_to be_nil
264
+ end
265
+
266
+ it "should not change the order state" do
267
+ spree_post :update, state: 'address'
268
+ end
269
+
270
+ it "should render the edit template" do
271
+ spree_post :update, state: 'address'
272
+ expect(response).to render_template :edit
273
+ end
274
+
275
+ it "should render order in payment state when payment fails" do
276
+ order.update_column(:state, 'confirm')
277
+ allow(controller).to receive(:insufficient_payment?).and_return(true)
278
+ spree_post :update, state: 'confirm'
279
+ expect(order.state).to eq('payment')
280
+ end
281
+ end
282
+
283
+ context "when current_order is nil" do
284
+ before { allow(controller).to receive_messages current_order: nil }
285
+
286
+ it "should not change the state if order is completed" do
287
+ expect(order).not_to receive(:update_attribute)
288
+ spree_post :update, state: "confirm"
289
+ end
290
+
291
+ it "should redirect to the cart_path" do
292
+ spree_post :update, state: "confirm"
293
+ expect(response).to redirect_to spree.cart_path
294
+ end
295
+ end
296
+
297
+ context "Spree::Core::GatewayError" do
298
+ before do
299
+ allow(order).to receive_messages user: user
300
+ allow(order).to receive(:update_attributes).and_raise(Spree::Core::GatewayError.new("Invalid something or other."))
301
+ spree_post :update, state: "address"
302
+ end
303
+
304
+ it "should render the edit template and display exception message" do
305
+ expect(response).to render_template :edit
306
+ expect(flash.now[:error]).to eq(Spree.t(:spree_gateway_error_flash_for_checkout))
307
+ expect(assigns(:order).errors[:base]).to include("Invalid something or other.")
308
+ end
309
+ end
310
+
311
+ context "fails to transition from address" do
312
+ let(:order) do
313
+ FactoryGirl.create(:order_with_line_items).tap do |order|
314
+ order.next!
315
+ expect(order.state).to eq('address')
316
+ end
317
+ end
318
+
319
+ before do
320
+ allow(controller).to receive_messages current_order: order
321
+ allow(controller).to receive_messages check_authorization: true
322
+ end
323
+
324
+ context "when the country is not a shippable country" do
325
+ before do
326
+ order.ship_address.tap do |address|
327
+ # A different country which is not included in the list of shippable countries
328
+ address.country = FactoryGirl.create(:country, name: "Australia")
329
+ address.state_name = 'Victoria'
330
+ address.save
331
+ end
332
+ end
333
+
334
+ it "due to no available shipping rates for any of the shipments" do
335
+ expect(order.shipments.count).to eq(1)
336
+ order.shipments.first.shipping_rates.delete_all
337
+
338
+ spree_put :update, state: order.state, order: {}
339
+ expect(flash[:error]).to eq(Spree.t(:items_cannot_be_shipped))
340
+ expect(response).to redirect_to(spree.checkout_state_path('address'))
341
+ end
342
+ end
343
+
344
+ context "when the order is invalid" do
345
+ before do
346
+ allow(order).to receive_messages(update_from_params: true, next: nil)
347
+ order.errors.add(:base, 'Base error')
348
+ order.errors.add(:adjustments, 'error')
349
+ end
350
+
351
+ it "due to the order having errors" do
352
+ spree_put :update, state: order.state, order: {}
353
+ expect(flash[:error]).to eql("Base error\nAdjustments error")
354
+ expect(response).to redirect_to(spree.checkout_state_path('address'))
355
+ end
356
+ end
357
+ end
358
+
359
+ context "fails to transition from payment to complete" do
360
+ let(:order) do
361
+ FactoryGirl.create(:order_with_line_items).tap do |order|
362
+ until order.state == 'payment'
363
+ order.next!
364
+ end
365
+ # So that the confirmation step is skipped and we get straight to the action.
366
+ payment_method = FactoryGirl.create(:simple_credit_card_payment_method)
367
+ payment = FactoryGirl.create(:payment, payment_method: payment_method)
368
+ order.payments << payment
369
+ end
370
+ end
371
+
372
+ before do
373
+ allow(controller).to receive_messages current_order: order
374
+ allow(controller).to receive_messages check_authorization: true
375
+ end
376
+
377
+ it "when GatewayError is raised" do
378
+ allow_any_instance_of(Spree::Payment).to receive(:process!).and_raise(Spree::Core::GatewayError.new(Spree.t(:payment_processing_failed)))
379
+ spree_put :update, state: order.state, order: {}
380
+ expect(flash[:error]).to eq(Spree.t(:payment_processing_failed))
381
+ end
382
+ end
383
+ end
384
+
385
+ context "When last inventory item has been purchased" do
386
+ let(:product) { mock_model(Spree::Product, name: "Amazing Object") }
387
+ let(:variant) { mock_model(Spree::Variant) }
388
+ let(:line_item) { mock_model Spree::LineItem, insufficient_stock?: true, amount: 0 }
389
+ let(:order) { create(:order) }
390
+
391
+ before do
392
+ allow(order).to receive_messages(line_items: [line_item], state: "payment")
393
+
394
+ configure_spree_preferences do |config|
395
+ config.track_inventory_levels = true
396
+ end
397
+ end
398
+
399
+ context "and back orders are not allowed" do
400
+ before do
401
+ spree_post :update, state: "payment"
402
+ end
403
+
404
+ it "should redirect to cart" do
405
+ expect(response).to redirect_to spree.cart_path
406
+ end
407
+
408
+ it "should set flash message for no inventory" do
409
+ expect(flash[:error]).to eq(
410
+ Spree.t(:inventory_error_flash_for_insufficient_quantity, names: "'#{product.name}'"))
411
+ end
412
+ end
413
+ end
414
+
415
+ context "order doesn't have a delivery step" do
416
+ before do
417
+ allow(order).to receive_messages(checkout_steps: ["cart", "address", "payment"])
418
+ allow(order).to receive_messages state: "address"
419
+ allow(controller).to receive_messages check_authorization: true
420
+ end
421
+
422
+ it "doesn't set shipping address on the order" do
423
+ expect(order).to_not receive(:ship_address=)
424
+ spree_post :update, state: order.state
425
+ end
426
+
427
+ it "doesn't remove unshippable items before payment" do
428
+ expect { spree_post :update, state: "payment" }.
429
+ to_not change { order.line_items }
430
+ end
431
+ end
432
+
433
+ it "does remove unshippable items before payment" do
434
+ allow(order).to receive_messages payment_required?: true
435
+ allow(controller).to receive_messages check_authorization: true
436
+
437
+ expect { spree_post :update, state: "payment" }.
438
+ to change { order.reload.line_items.length }
439
+ end
440
+
441
+ context 'in the payment step' do
442
+ let(:order) { OrderWalkthrough.up_to(:payment) }
443
+ let(:payment_method_id) { Spree::PaymentMethod.first.id }
444
+
445
+ before do
446
+ expect(order.state).to eq 'payment'
447
+ allow(order).to receive_messages user: user
448
+ allow(order).to receive_messages confirmation_required?: true
449
+ end
450
+
451
+ it 'does not advance the order extra even when called twice' do
452
+ spree_put :update, state: 'payment',
453
+ order: { payments_attributes: [{ payment_method_id: payment_method_id }] }
454
+ order.reload
455
+ expect(order.state).to eq 'confirm'
456
+ spree_put :update, state: 'payment',
457
+ order: { payments_attributes: [{ payment_method_id: payment_method_id }] }
458
+ order.reload
459
+ expect(order.state).to eq 'confirm'
460
+ end
461
+ end
462
+ end