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.
- checksums.yaml +4 -4
- data/app/assets/images/logo/spree_50.png +0 -0
- data/app/assets/javascripts/spree/frontend/cart.js.coffee +14 -1
- data/app/assets/javascripts/spree/frontend/checkout/payment.js.coffee +11 -35
- data/app/assets/javascripts/spree/frontend/checkout/shipment.js.coffee +38 -0
- data/app/assets/javascripts/spree/frontend/coupon_manager.js.coffee +37 -0
- data/app/assets/stylesheets/spree/frontend/frontend_bootstrap.css.scss +3 -3
- data/app/controllers/spree/checkout_controller.rb +0 -14
- data/app/controllers/spree/content_controller.rb +3 -3
- data/app/controllers/spree/orders_controller.rb +7 -2
- data/app/controllers/spree/products_controller.rb +3 -2
- data/app/controllers/spree/store_controller.rb +0 -18
- data/app/helpers/spree/frontend_helper.rb +1 -1
- data/app/helpers/spree/orders_helper.rb +0 -9
- data/app/views/kaminari/twitter-bootstrap-3/_first_page.html.erb +1 -1
- data/app/views/kaminari/twitter-bootstrap-3/_last_page.html.erb +1 -1
- data/app/views/kaminari/twitter-bootstrap-3/_next_page.html.erb +1 -1
- data/app/views/kaminari/twitter-bootstrap-3/_page.html.erb +1 -1
- data/app/views/kaminari/twitter-bootstrap-3/_prev_page.html.erb +1 -1
- data/app/views/spree/address/_form.html.erb +16 -16
- data/app/views/spree/checkout/_address.html.erb +4 -4
- data/app/views/spree/checkout/_confirm.html.erb +2 -2
- data/app/views/spree/checkout/_delivery.html.erb +5 -3
- data/app/views/spree/checkout/_payment.html.erb +3 -3
- data/app/views/spree/checkout/_summary.html.erb +3 -3
- data/app/views/spree/checkout/edit.html.erb +1 -0
- data/app/views/spree/checkout/payment/_gateway.html.erb +8 -8
- data/app/views/spree/home/index.html.erb +3 -2
- data/app/views/spree/orders/_adjustment_row.html.erb +1 -1
- data/app/views/spree/orders/_adjustments.html.erb +3 -3
- data/app/views/spree/orders/edit.html.erb +15 -2
- data/app/views/spree/products/_properties.html.erb +1 -1
- data/app/views/spree/products/index.html.erb +5 -5
- data/app/views/spree/products/show.html.erb +6 -6
- data/app/views/spree/shared/_address.html.erb +3 -1
- data/app/views/spree/shared/_error_messages.html.erb +1 -1
- data/app/views/spree/shared/_filters.html.erb +2 -2
- data/app/views/spree/shared/_google_add_items.js.erb +5 -5
- data/app/views/spree/shared/_head.html.erb +2 -0
- data/app/views/spree/shared/_header.html.erb +2 -2
- data/app/views/spree/shared/_login.html.erb +4 -4
- data/app/views/spree/shared/_nav_bar.html.erb +1 -1
- data/app/views/spree/shared/_order_details.html.erb +2 -2
- data/app/views/spree/shared/_search.html.erb +3 -3
- data/app/views/spree/shared/_translations.html.erb +7 -0
- data/config/initializers/assets.rb +1 -1
- data/config/routes.rb +1 -6
- data/lib/tasks/taxon.rake +2 -2
- data/spec/controllers/controller_extension_spec.rb +126 -0
- data/spec/controllers/controller_helpers_spec.rb +122 -0
- data/spec/controllers/spree/checkout_controller_spec.rb +462 -0
- data/spec/controllers/spree/checkout_controller_with_views_spec.rb +36 -0
- data/spec/controllers/spree/content_controller_spec.rb +12 -0
- data/spec/controllers/spree/current_order_tracking_spec.rb +44 -0
- data/spec/controllers/spree/home_controller_spec.rb +47 -0
- data/spec/controllers/spree/orders_controller_ability_spec.rb +96 -0
- data/spec/controllers/spree/orders_controller_spec.rb +134 -0
- data/spec/controllers/spree/orders_controller_transitions_spec.rb +31 -0
- data/spec/controllers/spree/products_controller_spec.rb +87 -0
- data/spec/controllers/spree/taxons_controller_spec.rb +12 -0
- data/spec/features/address_spec.rb +93 -0
- data/spec/features/automatic_promotion_adjustments_spec.rb +47 -0
- data/spec/features/caching/products_spec.rb +59 -0
- data/spec/features/caching/taxons_spec.rb +22 -0
- data/spec/features/cart_spec.rb +132 -0
- data/spec/features/checkout_spec.rb +572 -0
- data/spec/features/checkout_unshippable_spec.rb +34 -0
- data/spec/features/coupon_code_spec.rb +88 -0
- data/spec/features/currency_spec.rb +18 -0
- data/spec/features/delivery_spec.rb +64 -0
- data/spec/features/free_shipping_promotions_spec.rb +59 -0
- data/spec/features/locale_spec.rb +60 -0
- data/spec/features/microdata_spec.rb +0 -0
- data/spec/features/order_spec.rb +107 -0
- data/spec/features/page_promotions_spec.rb +36 -0
- data/spec/features/products_spec.rb +334 -0
- data/spec/features/taxons_spec.rb +147 -0
- data/spec/features/template_rendering_spec.rb +19 -0
- data/spec/helpers/frontend_helper_spec.rb +57 -0
- data/spec/helpers/taxons_helper_spec.rb +17 -0
- data/spec/spec_helper.rb +126 -0
- data/spec/support/shared_contexts/checkout_setup.rb +10 -0
- data/spec/support/shared_contexts/custom_products.rb +25 -0
- data/spec/support/shared_contexts/product_prototypes.rb +30 -0
- data/spec/views/spree/checkout/_summary_spec.rb +11 -0
- data/spree_frontend.gemspec +6 -3
- metadata +92 -263
- data/app/assets/images/flags/ad.png +0 -0
- data/app/assets/images/flags/ae.png +0 -0
- data/app/assets/images/flags/af.png +0 -0
- data/app/assets/images/flags/ag.png +0 -0
- data/app/assets/images/flags/ai.png +0 -0
- data/app/assets/images/flags/al.png +0 -0
- data/app/assets/images/flags/am.png +0 -0
- data/app/assets/images/flags/an.png +0 -0
- data/app/assets/images/flags/ao.png +0 -0
- data/app/assets/images/flags/ar.png +0 -0
- data/app/assets/images/flags/as.png +0 -0
- data/app/assets/images/flags/at.png +0 -0
- data/app/assets/images/flags/au.png +0 -0
- data/app/assets/images/flags/aw.png +0 -0
- data/app/assets/images/flags/ax.png +0 -0
- data/app/assets/images/flags/az.png +0 -0
- data/app/assets/images/flags/ba.png +0 -0
- data/app/assets/images/flags/bb.png +0 -0
- data/app/assets/images/flags/bd.png +0 -0
- data/app/assets/images/flags/be.png +0 -0
- data/app/assets/images/flags/bf.png +0 -0
- data/app/assets/images/flags/bg.png +0 -0
- data/app/assets/images/flags/bh.png +0 -0
- data/app/assets/images/flags/bi.png +0 -0
- data/app/assets/images/flags/bj.png +0 -0
- data/app/assets/images/flags/bm.png +0 -0
- data/app/assets/images/flags/bn.png +0 -0
- data/app/assets/images/flags/bo.png +0 -0
- data/app/assets/images/flags/br.png +0 -0
- data/app/assets/images/flags/bs.png +0 -0
- data/app/assets/images/flags/bt.png +0 -0
- data/app/assets/images/flags/bv.png +0 -0
- data/app/assets/images/flags/bw.png +0 -0
- data/app/assets/images/flags/by.png +0 -0
- data/app/assets/images/flags/bz.png +0 -0
- data/app/assets/images/flags/ca.png +0 -0
- data/app/assets/images/flags/catalonia.png +0 -0
- data/app/assets/images/flags/cc.png +0 -0
- data/app/assets/images/flags/cd.png +0 -0
- data/app/assets/images/flags/cf.png +0 -0
- data/app/assets/images/flags/cg.png +0 -0
- data/app/assets/images/flags/ch.png +0 -0
- data/app/assets/images/flags/ci.png +0 -0
- data/app/assets/images/flags/ck.png +0 -0
- data/app/assets/images/flags/cl.png +0 -0
- data/app/assets/images/flags/cm.png +0 -0
- data/app/assets/images/flags/cn.png +0 -0
- data/app/assets/images/flags/co.png +0 -0
- data/app/assets/images/flags/cr.png +0 -0
- data/app/assets/images/flags/cs.png +0 -0
- data/app/assets/images/flags/cu.png +0 -0
- data/app/assets/images/flags/cv.png +0 -0
- data/app/assets/images/flags/cx.png +0 -0
- data/app/assets/images/flags/cy.png +0 -0
- data/app/assets/images/flags/cz.png +0 -0
- data/app/assets/images/flags/de.png +0 -0
- data/app/assets/images/flags/dj.png +0 -0
- data/app/assets/images/flags/dk.png +0 -0
- data/app/assets/images/flags/dm.png +0 -0
- data/app/assets/images/flags/do.png +0 -0
- data/app/assets/images/flags/dz.png +0 -0
- data/app/assets/images/flags/ec.png +0 -0
- data/app/assets/images/flags/ee.png +0 -0
- data/app/assets/images/flags/eg.png +0 -0
- data/app/assets/images/flags/eh.png +0 -0
- data/app/assets/images/flags/england.png +0 -0
- data/app/assets/images/flags/er.png +0 -0
- data/app/assets/images/flags/es.png +0 -0
- data/app/assets/images/flags/et.png +0 -0
- data/app/assets/images/flags/europeanunion.png +0 -0
- data/app/assets/images/flags/fam.png +0 -0
- data/app/assets/images/flags/fi.png +0 -0
- data/app/assets/images/flags/fj.png +0 -0
- data/app/assets/images/flags/fk.png +0 -0
- data/app/assets/images/flags/fm.png +0 -0
- data/app/assets/images/flags/fo.png +0 -0
- data/app/assets/images/flags/fr.png +0 -0
- data/app/assets/images/flags/ga.png +0 -0
- data/app/assets/images/flags/gb.png +0 -0
- data/app/assets/images/flags/gd.png +0 -0
- data/app/assets/images/flags/ge.png +0 -0
- data/app/assets/images/flags/gf.png +0 -0
- data/app/assets/images/flags/gh.png +0 -0
- data/app/assets/images/flags/gi.png +0 -0
- data/app/assets/images/flags/gl.png +0 -0
- data/app/assets/images/flags/gm.png +0 -0
- data/app/assets/images/flags/gn.png +0 -0
- data/app/assets/images/flags/gp.png +0 -0
- data/app/assets/images/flags/gq.png +0 -0
- data/app/assets/images/flags/gr.png +0 -0
- data/app/assets/images/flags/gs.png +0 -0
- data/app/assets/images/flags/gt.png +0 -0
- data/app/assets/images/flags/gu.png +0 -0
- data/app/assets/images/flags/gw.png +0 -0
- data/app/assets/images/flags/gy.png +0 -0
- data/app/assets/images/flags/hk.png +0 -0
- data/app/assets/images/flags/hm.png +0 -0
- data/app/assets/images/flags/hn.png +0 -0
- data/app/assets/images/flags/hr.png +0 -0
- data/app/assets/images/flags/ht.png +0 -0
- data/app/assets/images/flags/hu.png +0 -0
- data/app/assets/images/flags/id.png +0 -0
- data/app/assets/images/flags/ie.png +0 -0
- data/app/assets/images/flags/il.png +0 -0
- data/app/assets/images/flags/in.png +0 -0
- data/app/assets/images/flags/io.png +0 -0
- data/app/assets/images/flags/iq.png +0 -0
- data/app/assets/images/flags/ir.png +0 -0
- data/app/assets/images/flags/is.png +0 -0
- data/app/assets/images/flags/it.png +0 -0
- data/app/assets/images/flags/ja.png +0 -0
- data/app/assets/images/flags/jm.png +0 -0
- data/app/assets/images/flags/jo.png +0 -0
- data/app/assets/images/flags/ke.png +0 -0
- data/app/assets/images/flags/kg.png +0 -0
- data/app/assets/images/flags/kh.png +0 -0
- data/app/assets/images/flags/ki.png +0 -0
- data/app/assets/images/flags/km.png +0 -0
- data/app/assets/images/flags/kn.png +0 -0
- data/app/assets/images/flags/kp.png +0 -0
- data/app/assets/images/flags/kr.png +0 -0
- data/app/assets/images/flags/kw.png +0 -0
- data/app/assets/images/flags/ky.png +0 -0
- data/app/assets/images/flags/kz.png +0 -0
- data/app/assets/images/flags/la.png +0 -0
- data/app/assets/images/flags/lb.png +0 -0
- data/app/assets/images/flags/lc.png +0 -0
- data/app/assets/images/flags/li.png +0 -0
- data/app/assets/images/flags/lk.png +0 -0
- data/app/assets/images/flags/lr.png +0 -0
- data/app/assets/images/flags/ls.png +0 -0
- data/app/assets/images/flags/lt.png +0 -0
- data/app/assets/images/flags/lu.png +0 -0
- data/app/assets/images/flags/lv.png +0 -0
- data/app/assets/images/flags/ly.png +0 -0
- data/app/assets/images/flags/ma.png +0 -0
- data/app/assets/images/flags/mc.png +0 -0
- data/app/assets/images/flags/md.png +0 -0
- data/app/assets/images/flags/me.png +0 -0
- data/app/assets/images/flags/mg.png +0 -0
- data/app/assets/images/flags/mh.png +0 -0
- data/app/assets/images/flags/mk.png +0 -0
- data/app/assets/images/flags/ml.png +0 -0
- data/app/assets/images/flags/mm.png +0 -0
- data/app/assets/images/flags/mn.png +0 -0
- data/app/assets/images/flags/mo.png +0 -0
- data/app/assets/images/flags/mp.png +0 -0
- data/app/assets/images/flags/mq.png +0 -0
- data/app/assets/images/flags/mr.png +0 -0
- data/app/assets/images/flags/ms.png +0 -0
- data/app/assets/images/flags/mt.png +0 -0
- data/app/assets/images/flags/mu.png +0 -0
- data/app/assets/images/flags/mv.png +0 -0
- data/app/assets/images/flags/mw.png +0 -0
- data/app/assets/images/flags/mx.png +0 -0
- data/app/assets/images/flags/my.png +0 -0
- data/app/assets/images/flags/mz.png +0 -0
- data/app/assets/images/flags/na.png +0 -0
- data/app/assets/images/flags/nc.png +0 -0
- data/app/assets/images/flags/ne.png +0 -0
- data/app/assets/images/flags/nf.png +0 -0
- data/app/assets/images/flags/ng.png +0 -0
- data/app/assets/images/flags/ni.png +0 -0
- data/app/assets/images/flags/nl.png +0 -0
- data/app/assets/images/flags/no.png +0 -0
- data/app/assets/images/flags/np.png +0 -0
- data/app/assets/images/flags/nr.png +0 -0
- data/app/assets/images/flags/nu.png +0 -0
- data/app/assets/images/flags/nz.png +0 -0
- data/app/assets/images/flags/om.png +0 -0
- data/app/assets/images/flags/pa.png +0 -0
- data/app/assets/images/flags/pe.png +0 -0
- data/app/assets/images/flags/pf.png +0 -0
- data/app/assets/images/flags/pg.png +0 -0
- data/app/assets/images/flags/ph.png +0 -0
- data/app/assets/images/flags/pk.png +0 -0
- data/app/assets/images/flags/pl.png +0 -0
- data/app/assets/images/flags/pm.png +0 -0
- data/app/assets/images/flags/pn.png +0 -0
- data/app/assets/images/flags/pr.png +0 -0
- data/app/assets/images/flags/ps.png +0 -0
- data/app/assets/images/flags/pt.png +0 -0
- data/app/assets/images/flags/pw.png +0 -0
- data/app/assets/images/flags/py.png +0 -0
- data/app/assets/images/flags/qa.png +0 -0
- data/app/assets/images/flags/re.png +0 -0
- data/app/assets/images/flags/ro.png +0 -0
- data/app/assets/images/flags/rs.png +0 -0
- data/app/assets/images/flags/ru.png +0 -0
- data/app/assets/images/flags/rw.png +0 -0
- data/app/assets/images/flags/sa.png +0 -0
- data/app/assets/images/flags/sb.png +0 -0
- data/app/assets/images/flags/sc.png +0 -0
- data/app/assets/images/flags/scotland.png +0 -0
- data/app/assets/images/flags/sd.png +0 -0
- data/app/assets/images/flags/se.png +0 -0
- data/app/assets/images/flags/sg.png +0 -0
- data/app/assets/images/flags/sh.png +0 -0
- data/app/assets/images/flags/si.png +0 -0
- data/app/assets/images/flags/sj.png +0 -0
- data/app/assets/images/flags/sk.png +0 -0
- data/app/assets/images/flags/sl.png +0 -0
- data/app/assets/images/flags/sm.png +0 -0
- data/app/assets/images/flags/sn.png +0 -0
- data/app/assets/images/flags/so.png +0 -0
- data/app/assets/images/flags/sr.png +0 -0
- data/app/assets/images/flags/st.png +0 -0
- data/app/assets/images/flags/sv.png +0 -0
- data/app/assets/images/flags/sy.png +0 -0
- data/app/assets/images/flags/sz.png +0 -0
- data/app/assets/images/flags/tc.png +0 -0
- data/app/assets/images/flags/td.png +0 -0
- data/app/assets/images/flags/tf.png +0 -0
- data/app/assets/images/flags/tg.png +0 -0
- data/app/assets/images/flags/th.png +0 -0
- data/app/assets/images/flags/tj.png +0 -0
- data/app/assets/images/flags/tk.png +0 -0
- data/app/assets/images/flags/tl.png +0 -0
- data/app/assets/images/flags/tm.png +0 -0
- data/app/assets/images/flags/tn.png +0 -0
- data/app/assets/images/flags/to.png +0 -0
- data/app/assets/images/flags/tr.png +0 -0
- data/app/assets/images/flags/tt.png +0 -0
- data/app/assets/images/flags/tv.png +0 -0
- data/app/assets/images/flags/tw.png +0 -0
- data/app/assets/images/flags/tz.png +0 -0
- data/app/assets/images/flags/ua.png +0 -0
- data/app/assets/images/flags/ug.png +0 -0
- data/app/assets/images/flags/um.png +0 -0
- data/app/assets/images/flags/us.png +0 -0
- data/app/assets/images/flags/uy.png +0 -0
- data/app/assets/images/flags/uz.png +0 -0
- data/app/assets/images/flags/va.png +0 -0
- data/app/assets/images/flags/vc.png +0 -0
- data/app/assets/images/flags/ve.png +0 -0
- data/app/assets/images/flags/vg.png +0 -0
- data/app/assets/images/flags/vi.png +0 -0
- data/app/assets/images/flags/vn.png +0 -0
- data/app/assets/images/flags/vu.png +0 -0
- data/app/assets/images/flags/wales.png +0 -0
- data/app/assets/images/flags/wf.png +0 -0
- data/app/assets/images/flags/ws.png +0 -0
- data/app/assets/images/flags/ye.png +0 -0
- data/app/assets/images/flags/yt.png +0 -0
- data/app/assets/images/flags/za.png +0 -0
- data/app/assets/images/flags/zm.png +0 -0
- data/app/assets/images/flags/zw.png +0 -0
- data/app/assets/images/spree_header.jpg +0 -0
- data/app/views/spree/products/_image.html.erb +0 -5
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "checkout with unshippable items", type: :feature, inaccessible: true do
|
4
|
+
let!(:stock_location) { create(:stock_location) }
|
5
|
+
let(:order) { OrderWalkthrough.up_to(:delivery) }
|
6
|
+
|
7
|
+
before do
|
8
|
+
OrderWalkthrough.add_line_item!(order)
|
9
|
+
line_item = order.line_items.last
|
10
|
+
stock_item = stock_location.stock_item(line_item.variant)
|
11
|
+
stock_item.adjust_count_on_hand -999
|
12
|
+
stock_item.backorderable = false
|
13
|
+
stock_item.save!
|
14
|
+
|
15
|
+
user = create(:user)
|
16
|
+
order.user = user
|
17
|
+
order.update_with_updater!
|
18
|
+
|
19
|
+
allow_any_instance_of(Spree::CheckoutController).to receive_messages(current_order: order)
|
20
|
+
allow_any_instance_of(Spree::CheckoutController).to receive_messages(try_spree_current_user: user)
|
21
|
+
allow_any_instance_of(Spree::CheckoutController).to receive_messages(skip_state_validation?: true)
|
22
|
+
allow_any_instance_of(Spree::CheckoutController).to receive_messages(ensure_sufficient_stock_lines: true)
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'displays and removes' do
|
26
|
+
visit spree.checkout_state_path(:delivery)
|
27
|
+
expect(page).to have_content('Unshippable Items')
|
28
|
+
|
29
|
+
click_button "Save and Continue"
|
30
|
+
|
31
|
+
order.reload
|
32
|
+
expect(order.line_items.count).to eq 1
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Coupon code promotions", type: :feature, js: true do
|
4
|
+
let!(:country) { create(:country, name: "United States of America", states_required: true) }
|
5
|
+
let!(:state) { create(:state, name: "Alabama", country: country) }
|
6
|
+
let!(:zone) { create(:zone) }
|
7
|
+
let!(:shipping_method) { create(:shipping_method) }
|
8
|
+
let!(:payment_method) { create(:check_payment_method) }
|
9
|
+
let!(:product) { create(:product, name: "RoR Mug", price: 20) }
|
10
|
+
let!(:store) { create(:store) }
|
11
|
+
|
12
|
+
context "visitor makes checkout as guest without registration" do
|
13
|
+
def create_basic_coupon_promotion(code)
|
14
|
+
promotion = Spree::Promotion.create!(name: code.titleize,
|
15
|
+
code: code,
|
16
|
+
starts_at: 1.day.ago,
|
17
|
+
expires_at: 1.day.from_now)
|
18
|
+
|
19
|
+
calculator = Spree::Calculator::FlatRate.new
|
20
|
+
calculator.preferred_amount = 10
|
21
|
+
|
22
|
+
action = Spree::Promotion::Actions::CreateItemAdjustments.new
|
23
|
+
action.calculator = calculator
|
24
|
+
action.promotion = promotion
|
25
|
+
action.save
|
26
|
+
|
27
|
+
promotion.reload # so that promotion.actions is available
|
28
|
+
end
|
29
|
+
|
30
|
+
let!(:promotion) { create_basic_coupon_promotion("onetwo") }
|
31
|
+
|
32
|
+
# OrdersController
|
33
|
+
context "on the payment page" do
|
34
|
+
before do
|
35
|
+
visit spree.root_path
|
36
|
+
click_link "RoR Mug"
|
37
|
+
click_button "add-to-cart-button"
|
38
|
+
click_button "Checkout"
|
39
|
+
fill_in "order_email", with: "spree@example.com"
|
40
|
+
fill_in "First Name", with: "John"
|
41
|
+
fill_in "Last Name", with: "Smith"
|
42
|
+
fill_in "Street Address", with: "1 John Street"
|
43
|
+
fill_in "City", with: "City of John"
|
44
|
+
fill_in "Zip", with: "01337"
|
45
|
+
select country.name, from: "Country"
|
46
|
+
select state.name, from: "order[bill_address_attributes][state_id]"
|
47
|
+
fill_in "Phone", with: "555-555-5555"
|
48
|
+
|
49
|
+
# To shipping method screen
|
50
|
+
click_button "Save and Continue"
|
51
|
+
# To payment screen
|
52
|
+
click_button "Save and Continue"
|
53
|
+
end
|
54
|
+
|
55
|
+
it "informs about an invalid coupon code" do
|
56
|
+
fill_in "order_coupon_code", with: "coupon_codes_rule_man"
|
57
|
+
click_button "Save and Continue"
|
58
|
+
expect(page).to have_content(Spree.t(:coupon_code_not_found))
|
59
|
+
end
|
60
|
+
|
61
|
+
it "informs the user about a coupon code which has exceeded its usage" do
|
62
|
+
promotion.update_column(:usage_limit, 5)
|
63
|
+
allow_any_instance_of(promotion.class).to receive_messages(credits_count: 10)
|
64
|
+
|
65
|
+
fill_in "order_coupon_code", with: "onetwo"
|
66
|
+
click_button "Save and Continue"
|
67
|
+
expect(page).to have_content(Spree.t(:coupon_code_max_usage))
|
68
|
+
end
|
69
|
+
|
70
|
+
it "can enter an invalid coupon code, then a real one" do
|
71
|
+
fill_in "order_coupon_code", with: "coupon_codes_rule_man"
|
72
|
+
click_button "Save and Continue"
|
73
|
+
expect(page).to have_content(Spree.t(:coupon_code_not_found))
|
74
|
+
fill_in "order_coupon_code", with: "onetwo"
|
75
|
+
click_button "Save and Continue"
|
76
|
+
expect(page).to have_content("Promotion (Onetwo) -$10.00")
|
77
|
+
end
|
78
|
+
|
79
|
+
context "with a promotion" do
|
80
|
+
it "applies a promotion to an order" do
|
81
|
+
fill_in "order_coupon_code", with: "onetwo"
|
82
|
+
click_button "Save and Continue"
|
83
|
+
expect(page).to have_content("Promotion (Onetwo) -$10.00")
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Switching currencies in backend", type: :feature do
|
4
|
+
before do
|
5
|
+
create(:base_product, name: "RoR Mug")
|
6
|
+
end
|
7
|
+
|
8
|
+
# Regression test for #2340
|
9
|
+
it "does not cause current_order to become nil", inaccessible: true do
|
10
|
+
visit spree.root_path
|
11
|
+
click_link "RoR Mug"
|
12
|
+
click_button "Add To Cart"
|
13
|
+
# Now that we have an order...
|
14
|
+
Spree::Config[:currency] = "AUD"
|
15
|
+
expect { visit spree.root_path }.not_to raise_error
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Delivery', type: :feature, inaccessible: true, js: true do
|
4
|
+
include_context 'checkout setup'
|
5
|
+
|
6
|
+
let(:country) { create(:country, name: 'United States of America', iso_name: 'UNITED STATES') }
|
7
|
+
let(:state) { create(:state, name: 'Alabama', abbr: 'AL', country: country) }
|
8
|
+
let!(:product2) { create(:product) }
|
9
|
+
let(:user) { create(:user) }
|
10
|
+
let!(:shipping_method2) do
|
11
|
+
sm = create(:shipping_method, name: 'Shipping Method2')
|
12
|
+
sm.calculator.preferred_amount = 20
|
13
|
+
sm.calculator.save
|
14
|
+
sm
|
15
|
+
end
|
16
|
+
|
17
|
+
before do
|
18
|
+
shipping_method.calculator.preferred_amount = 10
|
19
|
+
shipping_method.calculator.save
|
20
|
+
end
|
21
|
+
|
22
|
+
describe 'shipping total gets updated when shipping method is changed in the delivery step' do
|
23
|
+
before do
|
24
|
+
add_mug_to_cart
|
25
|
+
click_button 'Checkout'
|
26
|
+
|
27
|
+
fill_in 'order_email', with: 'test@example.com'
|
28
|
+
click_on 'Continue'
|
29
|
+
fill_in_address
|
30
|
+
|
31
|
+
click_button 'Save and Continue'
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should contain the shipping total' do
|
35
|
+
expect(page).to have_content('Shipping total: $10.00')
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'shipping method is changed' do
|
39
|
+
before { choose(shipping_method2.name) }
|
40
|
+
|
41
|
+
it 'shipping total and order total both are updates' do
|
42
|
+
expect(page).to have_content("Shipping total: $20.00")
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def fill_in_address
|
48
|
+
address = "order_bill_address_attributes"
|
49
|
+
fill_in "#{address}_firstname", with: FFaker::Name.first_name
|
50
|
+
fill_in "#{address}_lastname", with: FFaker::Name.last_name
|
51
|
+
fill_in "#{address}_address1", with: FFaker::Address.street_address
|
52
|
+
fill_in "#{address}_city", with: FFaker::Address.city
|
53
|
+
select country.name, from: "#{address}_country_id"
|
54
|
+
select state.name, from: "#{address}_state_id"
|
55
|
+
fill_in "#{address}_zipcode", with: FFaker::AddressUS.zip_code
|
56
|
+
fill_in "#{address}_phone", with: FFaker::PhoneNumber.phone_number
|
57
|
+
end
|
58
|
+
|
59
|
+
def add_mug_to_cart
|
60
|
+
visit spree.root_path
|
61
|
+
click_link mug.name
|
62
|
+
click_button "add-to-cart-button"
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Free shipping promotions", type: :feature, js: true do
|
4
|
+
let!(:country) { create(:country, name: "United States of America", states_required: true) }
|
5
|
+
let!(:state) { create(:state, name: "Alabama", country: country) }
|
6
|
+
let!(:zone) { create(:zone) }
|
7
|
+
let!(:shipping_method) do
|
8
|
+
sm = create(:shipping_method)
|
9
|
+
sm.calculator.preferred_amount = 10
|
10
|
+
sm.calculator.save
|
11
|
+
sm
|
12
|
+
end
|
13
|
+
|
14
|
+
let!(:payment_method) { create(:check_payment_method) }
|
15
|
+
let!(:product) { create(:product, name: "RoR Mug", price: 20) }
|
16
|
+
let!(:promotion) do
|
17
|
+
promotion = Spree::Promotion.create!(name: "Free Shipping",
|
18
|
+
starts_at: 1.day.ago,
|
19
|
+
expires_at: 1.day.from_now)
|
20
|
+
|
21
|
+
action = Spree::Promotion::Actions::FreeShipping.new
|
22
|
+
action.promotion = promotion
|
23
|
+
action.save
|
24
|
+
|
25
|
+
promotion.reload # so that promotion.actions is available
|
26
|
+
end
|
27
|
+
|
28
|
+
context "free shipping promotion automatically applied" do
|
29
|
+
before do
|
30
|
+
|
31
|
+
visit spree.root_path
|
32
|
+
click_link "RoR Mug"
|
33
|
+
click_button "add-to-cart-button"
|
34
|
+
click_button "Checkout"
|
35
|
+
fill_in "order_email", with: "spree@example.com"
|
36
|
+
fill_in "First Name", with: "John"
|
37
|
+
fill_in "Last Name", with: "Smith"
|
38
|
+
fill_in "Street Address", with: "1 John Street"
|
39
|
+
fill_in "City", with: "City of John"
|
40
|
+
fill_in "Zip", with: "01337"
|
41
|
+
select country.name, from: "Country"
|
42
|
+
select state.name, from: "order[bill_address_attributes][state_id]"
|
43
|
+
fill_in "Phone", with: "555-555-5555"
|
44
|
+
|
45
|
+
# To shipping method screen
|
46
|
+
click_button "Save and Continue"
|
47
|
+
# To payment screen
|
48
|
+
click_button "Save and Continue"
|
49
|
+
end
|
50
|
+
|
51
|
+
# Regression test for #4428
|
52
|
+
it "applies the free shipping promotion" do
|
53
|
+
within("#checkout-summary") do
|
54
|
+
expect(page).to have_content("Shipping total: $10.00")
|
55
|
+
expect(page).to have_content("Promotion (Free Shipping): -$10.00")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'setting locale', type: :feature do
|
4
|
+
def with_locale(locale)
|
5
|
+
I18n.locale = locale
|
6
|
+
Spree::Frontend::Config[:locale] = locale
|
7
|
+
yield
|
8
|
+
I18n.locale = 'en'
|
9
|
+
Spree::Frontend::Config[:locale] = 'en'
|
10
|
+
end
|
11
|
+
|
12
|
+
context 'shopping cart link and page' do
|
13
|
+
before do
|
14
|
+
I18n.backend.store_translations(:fr,
|
15
|
+
spree: {
|
16
|
+
cart: 'Panier',
|
17
|
+
shopping_cart: 'Panier'
|
18
|
+
})
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should be in french' do
|
22
|
+
with_locale('fr') do
|
23
|
+
visit spree.root_path
|
24
|
+
click_link 'Panier'
|
25
|
+
expect(page).to have_content('Panier')
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'checkout form validation messages' do
|
31
|
+
include_context 'checkout setup'
|
32
|
+
|
33
|
+
let(:error_messages) do
|
34
|
+
{
|
35
|
+
'en' => 'This field is required.',
|
36
|
+
'fr' => 'Ce champ est obligatoire.',
|
37
|
+
'de' => 'Dieses Feld ist ein Pflichtfeld.',
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
def check_error_text(text)
|
42
|
+
%w(firstname lastname address1 city).each do |attr|
|
43
|
+
expect(find("#b#{attr} label.error").text).to eq(text)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'shows translated jquery.validate error messages', js: true do
|
48
|
+
visit spree.root_path
|
49
|
+
click_link mug.name
|
50
|
+
click_button 'add-to-cart-button'
|
51
|
+
error_messages.each do |locale, message|
|
52
|
+
with_locale(locale) do
|
53
|
+
visit '/checkout/address'
|
54
|
+
find('.form-buttons input[type=submit]').click
|
55
|
+
check_error_text message
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
File without changes
|
@@ -0,0 +1,107 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'orders', type: :feature do
|
4
|
+
let(:order) { OrderWalkthrough.up_to(:complete) }
|
5
|
+
let(:user) { create(:user) }
|
6
|
+
|
7
|
+
before do
|
8
|
+
order.update_attribute(:user_id, user.id)
|
9
|
+
order.shipments.destroy_all
|
10
|
+
allow_any_instance_of(Spree::OrdersController).to receive_messages(try_spree_current_user: user)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "can visit an order" do
|
14
|
+
# Regression test for current_user call on orders/show
|
15
|
+
expect { visit spree.order_path(order) }.not_to raise_error
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should display line item price" do
|
19
|
+
# Regression test for #2772
|
20
|
+
line_item = order.line_items.first
|
21
|
+
line_item.target_shipment = create(:shipment)
|
22
|
+
line_item.price = 19.00
|
23
|
+
line_item.save!
|
24
|
+
|
25
|
+
visit spree.order_path(order)
|
26
|
+
|
27
|
+
# Tests view spree/shared/_order_details
|
28
|
+
within 'td.price' do
|
29
|
+
expect(page).to have_content "19.00"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should have credit card info if paid with credit card" do
|
34
|
+
create(:payment, order: order)
|
35
|
+
visit spree.order_path(order)
|
36
|
+
within '.payment-info' do
|
37
|
+
expect(page).to have_content "Ending in 1111"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should have payment method name visible if not paid with credit card" do
|
42
|
+
create(:check_payment, order: order)
|
43
|
+
visit spree.order_path(order)
|
44
|
+
within '.payment-info' do
|
45
|
+
expect(page).to have_content "Check"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# Regression test for #2282
|
50
|
+
context "can support a credit card with blank information" do
|
51
|
+
before do
|
52
|
+
credit_card = create(:credit_card)
|
53
|
+
credit_card.update_column(:cc_type, '')
|
54
|
+
payment = order.payments.first
|
55
|
+
payment.source = credit_card
|
56
|
+
payment.save!
|
57
|
+
end
|
58
|
+
|
59
|
+
specify do
|
60
|
+
visit spree.order_path(order)
|
61
|
+
within '.payment-info' do
|
62
|
+
expect { find("img") }.to raise_error(Capybara::ElementNotFound)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should return the correct title when displaying a completed order" do
|
68
|
+
visit spree.order_path(order)
|
69
|
+
|
70
|
+
within '#order_summary' do
|
71
|
+
expect(page).to have_content("#{Spree.t(:order)} #{order.number}")
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# Regression test for #6733
|
76
|
+
context "address_requires_state preference" do
|
77
|
+
context "when set to true" do
|
78
|
+
before do
|
79
|
+
configure_spree_preferences { |config| config.address_requires_state = true }
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should show state text" do
|
83
|
+
visit spree.order_path(order)
|
84
|
+
|
85
|
+
within '#order' do
|
86
|
+
expect(page).to have_content(order.bill_address.state_text)
|
87
|
+
expect(page).to have_content(order.ship_address.state_text)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
context "when set to false" do
|
93
|
+
before do
|
94
|
+
configure_spree_preferences { |config| config.address_requires_state = false }
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should not show state text" do
|
98
|
+
visit spree.order_path(order)
|
99
|
+
|
100
|
+
within '#order' do
|
101
|
+
expect(page).not_to have_content(order.bill_address.state_text)
|
102
|
+
expect(page).not_to have_content(order.ship_address.state_text)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'page promotions', type: :feature do
|
4
|
+
let!(:product) { create(:product, name: "RoR Mug", price: 20) }
|
5
|
+
before do
|
6
|
+
promotion = Spree::Promotion.create!(name: "$10 off",
|
7
|
+
path: 'test',
|
8
|
+
starts_at: 1.day.ago,
|
9
|
+
expires_at: 1.day.from_now)
|
10
|
+
|
11
|
+
calculator = Spree::Calculator::FlatRate.new
|
12
|
+
calculator.preferred_amount = 10
|
13
|
+
|
14
|
+
action = Spree::Promotion::Actions::CreateItemAdjustments.create(calculator: calculator)
|
15
|
+
promotion.actions << action
|
16
|
+
|
17
|
+
visit spree.root_path
|
18
|
+
click_link "RoR Mug"
|
19
|
+
click_button "add-to-cart-button"
|
20
|
+
end
|
21
|
+
|
22
|
+
it "automatically applies a page promotion upon visiting" do
|
23
|
+
expect(page).not_to have_content("Promotion ($10 off) -$10.00")
|
24
|
+
visit '/content/test'
|
25
|
+
visit '/cart'
|
26
|
+
expect(page).to have_content("Promotion ($10 off) -$10.00")
|
27
|
+
expect(page).to have_content("Subtotal (1 item) $20.00")
|
28
|
+
end
|
29
|
+
|
30
|
+
it "does not activate an adjustment for a path that doesn't have a promotion" do
|
31
|
+
expect(page).not_to have_content("Promotion ($10 off) -$10.00")
|
32
|
+
visit '/content/cvv'
|
33
|
+
visit '/cart'
|
34
|
+
expect(page).not_to have_content("Promotion ($10 off) -$10.00")
|
35
|
+
end
|
36
|
+
end
|