solidus_frontend 2.10.3 → 2.11.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of solidus_frontend might be problematic. Click here for more details.

Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/spree/frontend/checkout/address.js +1 -1
  3. data/app/assets/javascripts/spree/frontend/checkout/coupon-code.js +1 -1
  4. data/app/controllers/spree/checkout_controller.rb +9 -5
  5. data/app/controllers/spree/orders_controller.rb +9 -9
  6. data/app/controllers/spree/products_controller.rb +1 -1
  7. data/app/views/spree/address/_form.html.erb +15 -8
  8. data/app/views/spree/address/_form_hidden.html.erb +6 -2
  9. data/app/views/spree/checkout/payment/_gateway.html.erb +1 -1
  10. data/app/views/spree/orders/_form.html.erb +1 -1
  11. data/app/views/spree/shared/_address.html.erb +1 -1
  12. data/app/views/spree/shared/_image.html.erb +3 -2
  13. data/solidus_frontend.gemspec +5 -5
  14. metadata +10 -53
  15. data/script/rails +0 -10
  16. data/spec/controllers/controller_helpers_spec.rb +0 -29
  17. data/spec/controllers/locale_controller_spec.rb +0 -57
  18. data/spec/controllers/spree/checkout_controller_spec.rb +0 -610
  19. data/spec/controllers/spree/checkout_controller_with_views_spec.rb +0 -37
  20. data/spec/controllers/spree/content_controller_spec.rb +0 -9
  21. data/spec/controllers/spree/current_order_tracking_spec.rb +0 -47
  22. data/spec/controllers/spree/home_controller_spec.rb +0 -29
  23. data/spec/controllers/spree/orders_controller_ability_spec.rb +0 -90
  24. data/spec/controllers/spree/orders_controller_spec.rb +0 -254
  25. data/spec/controllers/spree/orders_controller_transitions_spec.rb +0 -33
  26. data/spec/controllers/spree/products_controller_spec.rb +0 -38
  27. data/spec/controllers/spree/taxons_controller_spec.rb +0 -14
  28. data/spec/features/address_spec.rb +0 -78
  29. data/spec/features/automatic_promotion_adjustments_spec.rb +0 -49
  30. data/spec/features/caching/products_spec.rb +0 -48
  31. data/spec/features/caching/taxons_spec.rb +0 -21
  32. data/spec/features/cart_spec.rb +0 -85
  33. data/spec/features/checkout_confirm_insufficient_stock_spec.rb +0 -71
  34. data/spec/features/checkout_spec.rb +0 -758
  35. data/spec/features/checkout_unshippable_spec.rb +0 -37
  36. data/spec/features/coupon_code_spec.rb +0 -266
  37. data/spec/features/currency_spec.rb +0 -20
  38. data/spec/features/first_order_promotion_spec.rb +0 -59
  39. data/spec/features/free_shipping_promotions_spec.rb +0 -60
  40. data/spec/features/locale_spec.rb +0 -26
  41. data/spec/features/order_spec.rb +0 -73
  42. data/spec/features/products_spec.rb +0 -291
  43. data/spec/features/promotion_code_invalidation_spec.rb +0 -54
  44. data/spec/features/quantity_promotions_spec.rb +0 -130
  45. data/spec/features/taxons_spec.rb +0 -158
  46. data/spec/features/template_rendering_spec.rb +0 -20
  47. data/spec/fixtures/thinking-cat.jpg +0 -0
  48. data/spec/generators/solidus/views/override_generator_spec.rb +0 -50
  49. data/spec/helpers/base_helper_spec.rb +0 -13
  50. data/spec/helpers/order_helper_spec.rb +0 -14
  51. data/spec/helpers/taxon_filters_helper_spec.rb +0 -12
  52. data/spec/spec_helper.rb +0 -106
  53. data/spec/support/shared_contexts/checkout_setup.rb +0 -12
  54. data/spec/support/shared_contexts/custom_products.rb +0 -28
  55. data/spec/support/shared_contexts/locales.rb +0 -16
  56. data/spec/views/spree/checkout/_summary_spec.rb +0 -11
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe "checkout with unshippable items", type: :feature, inaccessible: true do
6
- let!(:stock_location) { create(:stock_location) }
7
- let(:order) { Spree::TestingSupport::OrderWalkthrough.up_to(:address) }
8
-
9
- before do
10
- create(:line_item, order: order)
11
- order.reload
12
- line_item = order.line_items.last
13
- stock_item = stock_location.stock_item(line_item.variant)
14
- stock_item.adjust_count_on_hand(0)
15
- stock_item.backorderable = false
16
- stock_item.save!
17
-
18
- user = create(:user)
19
- order.user = user
20
- order.recalculate
21
-
22
- allow_any_instance_of(Spree::CheckoutController).to receive_messages(current_order: order)
23
- allow_any_instance_of(Spree::CheckoutController).to receive_messages(try_spree_current_user: user)
24
- allow_any_instance_of(Spree::CheckoutController).to receive_messages(skip_state_validation?: true)
25
- allow_any_instance_of(Spree::CheckoutController).to receive_messages(ensure_sufficient_stock_lines: true)
26
- end
27
-
28
- it 'displays and removes' do
29
- visit spree.checkout_state_path(:delivery)
30
- expect(page).to have_content('Unshippable Items')
31
-
32
- click_button "Save and Continue"
33
-
34
- order.reload
35
- expect(order.line_items.count).to eq 1
36
- end
37
- end
@@ -1,266 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe "Coupon code promotions", type: :feature, js: true do
6
- let!(:store) { create(:store) }
7
- let!(:country) { create(:country, name: "United States of America", states_required: true) }
8
- let!(:state) { create(:state, name: "Alabama", country: country) }
9
- let!(:zone) { create(:zone) }
10
- let!(:shipping_method) { create(:shipping_method) }
11
- let!(:payment_method) { create(:check_payment_method) }
12
- let!(:product) { create(:product, name: "RoR Mug", price: 20) }
13
-
14
- context "visitor makes checkout" do
15
- def create_basic_coupon_promotion(code)
16
- promotion = create(
17
- :promotion,
18
- name: code.titleize,
19
- code: code,
20
- starts_at: 1.day.ago,
21
- expires_at: 1.day.from_now
22
- )
23
-
24
- calculator = Spree::Calculator::FlatRate.new
25
- calculator.preferred_amount = 10
26
-
27
- action = Spree::Promotion::Actions::CreateItemAdjustments.new
28
- action.calculator = calculator
29
- action.promotion = promotion
30
- action.save
31
-
32
- promotion.reload # so that promotion.actions is available
33
- end
34
-
35
- let!(:promotion) { create_basic_coupon_promotion("onetwo") }
36
-
37
- context "on the payment page" do
38
- context "as guest without registration" do
39
- before do
40
- visit spree.root_path
41
- click_link "RoR Mug"
42
- click_button "add-to-cart-button"
43
- click_button "Checkout"
44
- fill_in "order_email", with: "spree@example.com"
45
- fill_in "First Name", with: "John"
46
- fill_in "Last Name", with: "Smith"
47
- fill_in "Street Address", with: "1 John Street"
48
- fill_in "City", with: "City of John"
49
- fill_in "Zip", with: "01337"
50
- select country.name, from: "Country"
51
- select state.name, from: "order[bill_address_attributes][state_id]"
52
- fill_in "Phone", with: "555-555-5555"
53
-
54
- # To shipping method screen
55
- click_button "Save and Continue"
56
- # To payment screen
57
- click_button "Save and Continue"
58
- end
59
-
60
- it "informs about an invalid coupon code" do
61
- fill_in "order_coupon_code", with: "coupon_codes_rule_man"
62
- click_button "Apply Code"
63
- expect(page).to have_content(I18n.t('spree.coupon_code_not_found'))
64
- end
65
-
66
- it "can enter an invalid coupon code, then a real one" do
67
- fill_in "order_coupon_code", with: "coupon_codes_rule_man"
68
- click_button "Apply Code"
69
- expect(page).to have_content(I18n.t('spree.coupon_code_not_found'))
70
- fill_in "order_coupon_code", with: "onetwo"
71
- click_button "Apply Code"
72
- expect(page).to have_content("Promotion (Onetwo) -$10.00", normalize_ws: true)
73
- end
74
-
75
- context "with a promotion" do
76
- it "applies a promotion to an order" do
77
- fill_in "order_coupon_code", with: "onetwo"
78
- click_button "Apply Code"
79
- expect(page).to have_content("Promotion (Onetwo) -$10.00", normalize_ws: true)
80
- end
81
- end
82
- end
83
-
84
- context 'as logged user' do
85
- let!(:user) { create(:user, bill_address: create(:address), ship_address: create(:address)) }
86
-
87
- before do
88
- allow_any_instance_of(Spree::CheckoutController).to receive_messages(try_spree_current_user: user)
89
- allow_any_instance_of(Spree::OrdersController).to receive_messages(try_spree_current_user: user)
90
- end
91
-
92
- context 'with saved credit card' do
93
- let(:bogus) { create(:credit_card_payment_method) }
94
- let!(:credit_card) do
95
- create(:credit_card, user_id: user.id, payment_method: bogus, gateway_customer_profile_id: "BGS-WEFWF")
96
- end
97
-
98
- before do
99
- user.wallet.add(credit_card)
100
-
101
- visit spree.root_path
102
- click_link "RoR Mug"
103
- click_button "add-to-cart-button"
104
- # To Cart
105
- click_button "Checkout"
106
- # To shipping method screen, address is auto-populated
107
- # with user's saved addresses
108
- click_button "Save and Continue"
109
- # To payment screen
110
- click_button "Save and Continue"
111
- end
112
-
113
- it "shows wallet payments on coupon code errors" do
114
- fill_in "order_coupon_code", with: "coupon_codes_rule_man"
115
- click_button "Apply Code"
116
-
117
- expect(page).to have_content("The coupon code you entered doesn't exist. Please try again.")
118
- expect(page).to have_content("Use an existing card")
119
- end
120
- end
121
- end
122
- end
123
-
124
- # CheckoutController
125
- context "on the cart page" do
126
- before do
127
- visit spree.root_path
128
- click_link "RoR Mug"
129
- click_button "add-to-cart-button"
130
- end
131
-
132
- it "can enter a coupon code and receives success notification" do
133
- fill_in "coupon_code", with: "onetwo"
134
- click_button "Apply Code"
135
- expect(page).to have_content(I18n.t('spree.coupon_code_applied'))
136
- end
137
-
138
- it "can enter a promotion code with both upper and lower case letters" do
139
- fill_in "coupon_code", with: "ONETwO"
140
- click_button "Apply Code"
141
- expect(page).to have_content(I18n.t('spree.coupon_code_applied'))
142
- end
143
-
144
- it "informs the user about a coupon code which has exceeded its usage" do
145
- expect_any_instance_of(Spree::Promotion).to receive(:usage_limit_exceeded?).and_return(true)
146
-
147
- fill_in "coupon_code", with: "onetwo"
148
- click_button "Apply Code"
149
- expect(page).to have_content(I18n.t('spree.coupon_code_max_usage'))
150
- end
151
-
152
- context "informs the user if the coupon code is not eligible" do
153
- before do
154
- rule = Spree::Promotion::Rules::ItemTotal.new
155
- rule.promotion = promotion
156
- rule.preferred_amount = 100
157
- rule.save
158
- end
159
-
160
- specify do
161
- visit spree.cart_path
162
-
163
- fill_in "coupon_code", with: "onetwo"
164
- click_button "Apply Code"
165
- expect(page).to have_content(I18n.t(:item_total_less_than_or_equal, scope: [:spree, :eligibility_errors, :messages], amount: "$100.00"))
166
- end
167
- end
168
-
169
- it "informs the user if the coupon is expired" do
170
- promotion.expires_at = Date.today.beginning_of_week
171
- promotion.starts_at = Date.today.beginning_of_week.advance(day: 3)
172
- promotion.save!
173
- fill_in "coupon_code", with: "onetwo"
174
- click_button "Apply Code"
175
- expect(page).to have_content(I18n.t('spree.coupon_code_expired'))
176
- end
177
-
178
- context "calculates the correct amount of money saved with flat percent promotions" do
179
- before do
180
- calculator = Spree::Calculator::FlatPercentItemTotal.new
181
- calculator.preferred_flat_percent = 20
182
- promotion.actions.first.calculator = calculator
183
- promotion.save
184
-
185
- create(:product, name: "Spree Mug", price: 10)
186
- end
187
-
188
- specify do
189
- visit spree.root_path
190
- click_link "Spree Mug"
191
- click_button "add-to-cart-button"
192
-
193
- visit spree.cart_path
194
- fill_in "coupon_code", with: "onetwo"
195
- click_button "Apply Code"
196
-
197
- fill_in "order_line_items_attributes_0_quantity", with: 2
198
- fill_in "order_line_items_attributes_1_quantity", with: 2
199
- click_button "Update"
200
-
201
- within '#cart_adjustments' do
202
- # 20% of $40 = 8
203
- # 20% of $20 = 4
204
- # Therefore: promotion discount amount is $12.
205
- expect(page).to have_content("Promotion (Onetwo) -$12.00", normalize_ws: true)
206
- end
207
-
208
- within '.cart-total' do
209
- expect(page).to have_content("$48.00")
210
- end
211
- end
212
- end
213
-
214
- context "calculates the correct amount of money saved with flat 100% promotions on the whole order" do
215
- before do
216
- calculator = Spree::Calculator::FlatPercentItemTotal.new
217
- calculator.preferred_flat_percent = 100
218
-
219
- promotion.promotion_actions.first.discard
220
-
221
- Spree::Promotion::Actions::CreateAdjustment.create!(
222
- calculator: calculator,
223
- promotion: promotion
224
- )
225
-
226
- create(:product, name: "Spree Mug", price: 10)
227
- end
228
-
229
- specify do
230
- visit spree.root_path
231
- click_link "Spree Mug"
232
- click_button "add-to-cart-button"
233
-
234
- visit spree.cart_path
235
-
236
- within '.cart-total' do
237
- expect(page).to have_content("$30.00")
238
- end
239
-
240
- fill_in "coupon_code", with: "onetwo"
241
- click_button "Apply Code"
242
-
243
- within '#cart_adjustments' do
244
- expect(page).to have_content("Promotion (Onetwo) -$30.00", normalize_ws: true)
245
- end
246
-
247
- within '.cart-total' do
248
- expect(page).to have_content("$0.00")
249
- end
250
-
251
- fill_in "order_line_items_attributes_0_quantity", with: 2
252
- fill_in "order_line_items_attributes_1_quantity", with: 2
253
- click_button "Update"
254
-
255
- within '#cart_adjustments' do
256
- expect(page).to have_content("Promotion (Onetwo) -$60.00", normalize_ws: true)
257
- end
258
-
259
- within '.cart-total' do
260
- expect(page).to have_content("$0.00")
261
- end
262
- end
263
- end
264
- end
265
- end
266
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe "Switching currencies in backend", type: :feature do
6
- before do
7
- create(:store)
8
- create(:base_product, name: "RoR Mug")
9
- end
10
-
11
- # Regression test for https://github.com/spree/spree/issues/2340
12
- it "does not cause current_order to become nil", inaccessible: true do
13
- visit spree.root_path
14
- click_link "RoR Mug"
15
- click_button "Add To Cart"
16
- # Now that we have an order...
17
- stub_spree_preferences(currency: "AUD")
18
- visit spree.root_path
19
- end
20
- end
@@ -1,59 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.feature "First Order promotion" do
6
- given!(:promotion) do
7
- FactoryBot.create(
8
- :promotion_with_first_order_rule,
9
- :with_order_adjustment,
10
- code: "FIRSTONEFREE",
11
- per_code_usage_limit: 10
12
- )
13
- end
14
-
15
- background do
16
- create(:store)
17
- product = FactoryBot.create(:product)
18
- visit spree.root_path
19
- click_link product.name
20
- click_button "Add To Cart"
21
- end
22
-
23
- scenario "Adding first order promotion to cart and checking out as guest" do
24
- fill_in "Coupon code", with: "FIRSTONEFREE"
25
- click_button "Apply Code"
26
- expect(page).to have_content("The coupon code was successfully applied to your order")
27
-
28
- within("#cart_adjustments") do
29
- expect(page).to have_content("-$10.00")
30
- end
31
- end
32
-
33
- scenario "Trying to reuse first order promotion" do
34
- previous_user = FactoryBot.create(
35
- :user,
36
- email: "sam@tom.com"
37
- )
38
- _previous_order = create(:completed_order_with_totals, user: previous_user)
39
- fill_in "Coupon code", with: "FIRSTONEFREE"
40
- click_button "Apply Code"
41
- expect(page).to have_content("The coupon code was successfully applied to your order")
42
- click_on "Checkout"
43
- fill_in "Customer E-Mail", with: "sam@tom.com"
44
- fill_in_address
45
- click_on "Save and Continue"
46
- expect(page).to_not have_content("#summary-order-charges")
47
- end
48
-
49
- def fill_in_address
50
- address = "order_bill_address_attributes"
51
- fill_in "#{address}_firstname", with: "Ryan"
52
- fill_in "#{address}_lastname", with: "Bigg"
53
- fill_in "#{address}_address1", with: "143 Swan Street"
54
- fill_in "#{address}_city", with: "Richmond"
55
- select "United States of America", from: "#{address}_country_id"
56
- fill_in "#{address}_zipcode", with: "12345"
57
- fill_in "#{address}_phone", with: "(555) 555-5555"
58
- end
59
- end
@@ -1,60 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe "Free shipping promotions", type: :feature, js: true do
6
- let!(:store) { create(:store) }
7
- let!(:country) { create(:country, name: "United States of America", states_required: true) }
8
- let!(:state) { create(:state, name: "Alabama", country: country) }
9
- let!(:zone) { create(:zone) }
10
- let!(:shipping_method) do
11
- sm = create(:shipping_method)
12
- sm.calculator.preferred_amount = 10
13
- sm.calculator.save
14
- sm
15
- end
16
-
17
- let!(:payment_method) { create(:check_payment_method) }
18
- let!(:product) { create(:product, name: "RoR Mug", price: 20) }
19
- let!(:promotion) do
20
- create(
21
- :promotion,
22
- apply_automatically: true,
23
- promotion_actions: [Spree::Promotion::Actions::FreeShipping.new],
24
- name: "Free Shipping",
25
- starts_at: 1.day.ago,
26
- expires_at: 1.day.from_now,
27
- )
28
- end
29
-
30
- context "free shipping promotion automatically applied" do
31
- before do
32
- visit spree.root_path
33
- click_link "RoR Mug"
34
- click_button "add-to-cart-button"
35
- click_button "Checkout"
36
- fill_in "order_email", with: "spree@example.com"
37
- fill_in "First Name", with: "John"
38
- fill_in "Last Name", with: "Smith"
39
- fill_in "Street Address", with: "1 John Street"
40
- fill_in "City", with: "City of John"
41
- fill_in "Zip", with: "01337"
42
- select country.name, from: "Country"
43
- select state.name, from: "order[bill_address_attributes][state_id]"
44
- fill_in "Phone", with: "555-555-5555"
45
-
46
- # To shipping method screen
47
- click_button "Save and Continue"
48
- # To payment screen
49
- click_button "Save and Continue"
50
- end
51
-
52
- # Regression test for https://github.com/spree/spree/issues/4428
53
- it "applies the free shipping promotion" do
54
- within("#checkout-summary") do
55
- expect(page).to have_content("Shipping total: $10.00", normalize_ws: true)
56
- expect(page).to have_content("Promotion (Free Shipping): -$10.00", normalize_ws: true)
57
- end
58
- end
59
- end
60
- end
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe 'setting locale', type: :feature do
6
- let!(:store) { create(:store) }
7
- def with_locale(locale)
8
- I18n.locale = locale
9
- stub_spree_preferences(Spree::Frontend::Config, locale: locale)
10
- yield
11
- ensure
12
- I18n.locale = I18n.default_locale
13
- end
14
-
15
- context 'shopping cart link and page' do
16
- include_context "fr locale"
17
-
18
- it 'should be in french' do
19
- with_locale('fr') do
20
- visit spree.root_path
21
- click_link 'Panier'
22
- expect(page).to have_content('Panier')
23
- end
24
- end
25
- end
26
- end