spree_frontend 3.2.9 → 3.3.0.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/spree/checkout_controller.rb +8 -2
  3. data/app/controllers/spree/orders_controller.rb +7 -3
  4. data/app/controllers/spree/products_controller.rb +3 -1
  5. data/app/helpers/spree/frontend_helper.rb +1 -1
  6. data/app/helpers/spree/taxons_helper.rb +2 -3
  7. data/app/views/spree/checkout/_confirm.html.erb +3 -0
  8. data/app/views/spree/checkout/_summary.html.erb +1 -1
  9. data/app/views/spree/checkout/payment/_storecredit.html.erb +1 -0
  10. data/app/views/spree/products/_cart_form.html.erb +3 -3
  11. data/app/views/spree/shared/_main_nav_bar.html.erb +1 -1
  12. data/app/views/spree/shared/_order_details.html.erb +0 -1
  13. data/app/views/spree/shared/_products.html.erb +4 -1
  14. data/spec/controllers/controller_extension_spec.rb +126 -0
  15. data/spec/controllers/controller_helpers_spec.rb +122 -0
  16. data/spec/controllers/spree/checkout_controller_spec.rb +547 -0
  17. data/spec/controllers/spree/checkout_controller_with_views_spec.rb +36 -0
  18. data/spec/controllers/spree/content_controller_spec.rb +12 -0
  19. data/spec/controllers/spree/current_order_tracking_spec.rb +44 -0
  20. data/spec/controllers/spree/home_controller_spec.rb +47 -0
  21. data/spec/controllers/spree/orders_controller_ability_spec.rb +96 -0
  22. data/spec/controllers/spree/orders_controller_spec.rb +134 -0
  23. data/spec/controllers/spree/orders_controller_transitions_spec.rb +31 -0
  24. data/spec/controllers/spree/products_controller_spec.rb +87 -0
  25. data/spec/controllers/spree/taxons_controller_spec.rb +12 -0
  26. data/spec/features/address_spec.rb +93 -0
  27. data/spec/features/automatic_promotion_adjustments_spec.rb +47 -0
  28. data/spec/features/caching/products_spec.rb +59 -0
  29. data/spec/features/caching/taxons_spec.rb +22 -0
  30. data/spec/features/cart_spec.rb +132 -0
  31. data/spec/features/checkout_spec.rb +723 -0
  32. data/spec/features/checkout_unshippable_spec.rb +34 -0
  33. data/spec/features/coupon_code_spec.rb +88 -0
  34. data/spec/features/currency_spec.rb +18 -0
  35. data/spec/features/delivery_spec.rb +64 -0
  36. data/spec/features/free_shipping_promotions_spec.rb +59 -0
  37. data/spec/features/locale_spec.rb +60 -0
  38. data/spec/features/microdata_spec.rb +0 -0
  39. data/spec/features/order_spec.rb +107 -0
  40. data/spec/features/page_promotions_spec.rb +36 -0
  41. data/spec/features/products_spec.rb +345 -0
  42. data/spec/features/taxons_spec.rb +147 -0
  43. data/spec/features/template_rendering_spec.rb +19 -0
  44. data/spec/helpers/frontend_helper_spec.rb +57 -0
  45. data/spec/helpers/taxons_helper_spec.rb +17 -0
  46. data/spec/spec_helper.rb +128 -0
  47. data/spec/support/shared_contexts/checkout_setup.rb +10 -0
  48. data/spec/support/shared_contexts/custom_products.rb +25 -0
  49. data/spec/support/shared_contexts/product_prototypes.rb +30 -0
  50. data/spec/views/spree/checkout/_summary_spec.rb +11 -0
  51. data/spree_frontend.gemspec +5 -4
  52. metadata +90 -15
@@ -0,0 +1,132 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Cart", type: :feature, inaccessible: true do
4
+ before { Timecop.scale(100) }
5
+
6
+ after { Timecop.return }
7
+
8
+ let!(:variant) { create(:variant) }
9
+ let!(:product) { variant.product }
10
+
11
+ def add_mug_to_cart
12
+ visit spree.root_path
13
+ click_link product.name
14
+ click_button "add-to-cart-button"
15
+ end
16
+
17
+ it "shows cart icon on non-cart pages" do
18
+ visit spree.root_path
19
+ expect(page).to have_selector("li#link-to-cart a", visible: true)
20
+ end
21
+
22
+ it "prevents double clicking the remove button on cart", js: true do
23
+ add_mug_to_cart
24
+ # prevent form submit to verify button is disabled
25
+ page.execute_script("$('#update-cart').submit(function(){return false;})")
26
+
27
+ expect(page).not_to have_selector('button#update-button[disabled]')
28
+ page.find(:css, '.delete span').click
29
+ expect(page).to have_selector('button#update-button[disabled]')
30
+ end
31
+
32
+ # Regression test for #2006
33
+ it "does not error out with a 404 when GET'ing to /orders/populate" do
34
+ visit '/orders/populate'
35
+ within(".alert-error") do
36
+ expect(page).to have_content(Spree.t(:populate_get_error))
37
+ end
38
+ end
39
+
40
+ it 'allows you to remove an item from the cart', js: true do
41
+ add_mug_to_cart
42
+ line_item = Spree::LineItem.first!
43
+ within("#line_items") do
44
+ click_link "delete_line_item_#{line_item.id}"
45
+ end
46
+
47
+ expect(page).to_not have_content("Line items quantity must be an integer")
48
+ expect(page).to_not have_content(product.name)
49
+ expect(page).to have_content("Your cart is empty")
50
+
51
+ within "#link-to-cart" do
52
+ expect(page).to have_content("Empty")
53
+ end
54
+ end
55
+
56
+ it 'allows you to empty the cart', js: true do
57
+ add_mug_to_cart
58
+ expect(page).to have_content(product.name)
59
+ click_on "Empty Cart"
60
+ expect(page).to have_content("Your cart is empty")
61
+
62
+ within "#link-to-cart" do
63
+ expect(page).to have_content("Empty")
64
+ end
65
+ end
66
+
67
+ # regression for #2276
68
+ context "product contains variants but no option values" do
69
+ before { variant.option_values.destroy_all }
70
+
71
+ it "still adds product to cart", inaccessible: true do
72
+ add_mug_to_cart
73
+ visit spree.cart_path
74
+ expect(page).to have_content(product.name)
75
+ end
76
+ end
77
+
78
+ it "should have a surrounding element with data-hook='cart_container'" do
79
+ visit spree.cart_path
80
+ expect(page).to have_selector("div[data-hook='cart_container']")
81
+ end
82
+
83
+ describe 'add promotion coupon on cart page', js: true do
84
+ let!(:promotion) { Spree::Promotion.create(name: 'Huhuhu', code: 'huhu') }
85
+ let!(:calculator) { Spree::Calculator::FlatPercentItemTotal.create(preferred_flat_percent: '10') }
86
+ let!(:action) { Spree::Promotion::Actions::CreateItemAdjustments.create(calculator: calculator) }
87
+
88
+ before do
89
+ promotion.actions << action
90
+ add_mug_to_cart
91
+ expect(current_path).to eql(spree.cart_path)
92
+ end
93
+
94
+ def apply_coupon(code)
95
+ fill_in 'Coupon Code', with: code
96
+ click_on 'Update'
97
+ end
98
+
99
+ context 'valid coupon' do
100
+ before { apply_coupon(promotion.code) }
101
+
102
+ context 'for the first time' do
103
+ it 'makes sure payment reflects order total with discounts' do
104
+ expect(page).to have_content(promotion.name)
105
+ end
106
+ end
107
+
108
+ context 'same coupon for the second time' do
109
+ before { apply_coupon(promotion.code) }
110
+ it 'should reflect an error that coupon already applied' do
111
+ apply_coupon(promotion.code)
112
+ expect(page).to have_content(Spree.t(:coupon_code_already_applied))
113
+ expect(page).to have_content(promotion.name)
114
+ end
115
+ end
116
+ end
117
+
118
+ context 'invalid coupon' do
119
+ it 'doesnt create a payment record' do
120
+ apply_coupon('invalid')
121
+ expect(page).to have_content(Spree.t(:coupon_code_not_found))
122
+ end
123
+ end
124
+
125
+ context "doesn't fill in coupon code input" do
126
+ it 'advances just fine' do
127
+ click_on 'Update'
128
+ expect(current_path).to match(spree.cart_path)
129
+ end
130
+ end
131
+ end
132
+ end