solidus_frontend 1.2.3 → 1.3.0.beta1
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.
Potentially problematic release.
This version of solidus_frontend might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile +3 -3
- data/Rakefile +1 -1
- data/app/assets/javascripts/spree/frontend/checkout/address.js.coffee +0 -2
- data/app/assets/stylesheets/spree/frontend.css +1 -2
- data/app/assets/stylesheets/spree/frontend/_skeleton.scss +242 -0
- data/app/assets/stylesheets/spree/frontend/screen.css.scss +1 -0
- data/app/controllers/spree/checkout_controller.rb +93 -93
- data/app/controllers/spree/content_controller.rb +1 -1
- data/app/controllers/spree/orders_controller.rb +15 -16
- data/app/controllers/spree/products_controller.rb +19 -18
- data/app/controllers/spree/store_controller.rb +27 -27
- data/app/controllers/spree/taxons_controller.rb +1 -2
- data/app/models/spree/frontend_configuration.rb +1 -1
- data/app/views/spree/address/_form.html.erb +18 -12
- data/app/views/spree/orders/show.html.erb +2 -2
- data/app/views/spree/products/_cart_form.html.erb +5 -5
- data/app/views/spree/products/show.html.erb +1 -1
- data/app/views/spree/shared/_google_analytics.html.erb +1 -1
- data/app/views/spree/shared/_order_details.html.erb +12 -11
- data/app/views/spree/shared/_products.html.erb +2 -2
- data/config/initializers/assets.rb +8 -1
- data/config/initializers/canonical_rails.rb +1 -2
- data/config/routes.rb +17 -18
- data/lib/spree/frontend.rb +1 -0
- data/lib/spree/frontend/engine.rb +1 -9
- data/lib/spree/frontend/middleware/seo_assist.rb +3 -4
- data/lib/tasks/rake_util.rb +3 -6
- data/lib/tasks/taxon.rake +3 -3
- data/script/rails +0 -1
- data/solidus_frontend.gemspec +1 -0
- data/spec/controllers/controller_extension_spec.rb +15 -15
- data/spec/controllers/controller_helpers_spec.rb +1 -2
- data/spec/controllers/spree/checkout_controller_spec.rb +67 -115
- data/spec/controllers/spree/content_controller_spec.rb +1 -1
- data/spec/controllers/spree/current_order_tracking_spec.rb +7 -6
- data/spec/controllers/spree/home_controller_spec.rb +3 -3
- data/spec/controllers/spree/orders_controller_ability_spec.rb +17 -16
- data/spec/controllers/spree/orders_controller_spec.rb +9 -8
- data/spec/controllers/spree/orders_controller_transitions_spec.rb +5 -5
- data/spec/controllers/spree/products_controller_spec.rb +10 -11
- data/spec/controllers/spree/taxons_controller_spec.rb +5 -5
- data/spec/features/address_spec.rb +15 -15
- data/spec/features/automatic_promotion_adjustments_spec.rb +18 -18
- data/spec/features/caching/products_spec.rb +2 -2
- data/spec/features/caching/taxons_spec.rb +2 -2
- data/spec/features/cart_spec.rb +8 -6
- data/spec/features/checkout_spec.rb +49 -51
- data/spec/features/checkout_unshippable_spec.rb +4 -5
- data/spec/features/coupon_code_spec.rb +28 -30
- data/spec/features/currency_spec.rb +3 -3
- data/spec/features/free_shipping_promotions_spec.rb +17 -17
- data/spec/features/locale_spec.rb +33 -24
- data/spec/features/order_spec.rb +4 -4
- data/spec/features/products_spec.rb +12 -12
- data/spec/features/promotion_code_invalidation_spec.rb +1 -0
- data/spec/features/quantity_promotions_spec.rb +1 -1
- data/spec/features/taxons_spec.rb +16 -16
- data/spec/features/template_rendering_spec.rb +1 -2
- data/spec/helpers/base_helper_spec.rb +2 -2
- data/spec/spec_helper.rb +5 -5
- data/spec/support/shared_contexts/checkout_setup.rb +1 -0
- data/spec/support/shared_contexts/custom_products.rb +18 -17
- data/spec/support/shared_contexts/product_prototypes.rb +3 -5
- data/spec/views/spree/checkout/_summary_spec.rb +2 -2
- metadata +24 -9
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe 'products', :
|
3
|
+
describe 'products', type: :feature, caching: true do
|
4
4
|
let!(:product) { create(:product) }
|
5
5
|
let!(:product2) { create(:product) }
|
6
6
|
let!(:taxonomy) { create(:taxonomy) }
|
7
|
-
let!(:taxon) { create(:taxon, :
|
7
|
+
let!(:taxon) { create(:taxon, taxonomy: taxonomy) }
|
8
8
|
|
9
9
|
before do
|
10
10
|
product2.update_column(:updated_at, 1.day.ago)
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe 'taxons', :
|
3
|
+
describe 'taxons', type: :feature, caching: true do
|
4
4
|
let!(:taxonomy) { create(:taxonomy) }
|
5
|
-
let!(:taxon) { create(:taxon, :
|
5
|
+
let!(:taxon) { create(:taxon, taxonomy: taxonomy) }
|
6
6
|
|
7
7
|
before do
|
8
8
|
# warm up the cache
|
data/spec/features/cart_spec.rb
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe "Cart", type: :feature, inaccessible: true do
|
4
|
+
before { create(:store) }
|
5
|
+
|
4
6
|
it "shows cart icon on non-cart pages" do
|
5
7
|
visit spree.root_path
|
6
|
-
expect(page).to have_selector("li#link-to-cart a", :
|
8
|
+
expect(page).to have_selector("li#link-to-cart a", visible: true)
|
7
9
|
end
|
8
10
|
|
9
|
-
it "prevents double clicking the remove button on cart", :
|
10
|
-
@product = create(:product, :
|
11
|
+
it "prevents double clicking the remove button on cart", js: true do
|
12
|
+
@product = create(:product, name: "RoR Mug")
|
11
13
|
|
12
14
|
visit spree.root_path
|
13
15
|
click_link "RoR Mug"
|
@@ -29,8 +31,8 @@ describe "Cart", type: :feature, inaccessible: true do
|
|
29
31
|
end
|
30
32
|
end
|
31
33
|
|
32
|
-
it 'allows you to remove an item from the cart', :
|
33
|
-
create(:product, :
|
34
|
+
it 'allows you to remove an item from the cart', js: true do
|
35
|
+
create(:product, name: "RoR Mug")
|
34
36
|
visit spree.root_path
|
35
37
|
click_link "RoR Mug"
|
36
38
|
click_button "add-to-cart-button"
|
@@ -45,7 +47,7 @@ describe "Cart", type: :feature, inaccessible: true do
|
|
45
47
|
end
|
46
48
|
|
47
49
|
it 'allows you to empty the cart', js: true do
|
48
|
-
create(:product, :
|
50
|
+
create(:product, name: "RoR Mug")
|
49
51
|
visit spree.root_path
|
50
52
|
click_link "RoR Mug"
|
51
53
|
click_button "add-to-cart-button"
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe "Checkout", type: :feature, inaccessible: true do
|
4
|
-
|
5
4
|
include_context 'checkout setup'
|
6
5
|
|
7
6
|
context "visitor makes checkout as guest without registration" do
|
@@ -20,7 +19,7 @@ describe "Checkout", type: :feature, inaccessible: true do
|
|
20
19
|
expect(find('input#order_use_billing')).to be_checked
|
21
20
|
end
|
22
21
|
|
23
|
-
it "should remain checked when used and visitor steps back to address step", :
|
22
|
+
it "should remain checked when used and visitor steps back to address step", js: true do
|
24
23
|
fill_in_address
|
25
24
|
expect(find('input#order_use_billing')).to be_checked
|
26
25
|
end
|
@@ -47,11 +46,11 @@ describe "Checkout", type: :feature, inaccessible: true do
|
|
47
46
|
mug.save!
|
48
47
|
end
|
49
48
|
|
50
|
-
it "does not break the per-item shipping method calculator", :
|
49
|
+
it "does not break the per-item shipping method calculator", js: true do
|
51
50
|
add_mug_to_cart
|
52
51
|
click_button "Checkout"
|
53
52
|
|
54
|
-
fill_in "order_email", :
|
53
|
+
fill_in "order_email", with: "test@example.com"
|
55
54
|
fill_in_address
|
56
55
|
|
57
56
|
click_button "Save and Continue"
|
@@ -78,25 +77,25 @@ describe "Checkout", type: :feature, inaccessible: true do
|
|
78
77
|
|
79
78
|
# Regression test for https://github.com/spree/spree/issues/2694 and https://github.com/spree/spree/issues/4117
|
80
79
|
context "doesn't allow bad credit card numbers" do
|
81
|
-
let!(:payment_method) { create(:credit_card_payment_method) }
|
82
80
|
before(:each) do
|
83
81
|
order = OrderWalkthrough.up_to(:delivery)
|
82
|
+
allow(order).to receive_messages(available_payment_methods: [create(:credit_card_payment_method)])
|
84
83
|
|
85
84
|
user = create(:user)
|
86
85
|
order.user = user
|
87
86
|
order.update!
|
88
87
|
|
89
|
-
allow_any_instance_of(Spree::CheckoutController).to receive_messages(:
|
90
|
-
allow_any_instance_of(Spree::CheckoutController).to receive_messages(:
|
88
|
+
allow_any_instance_of(Spree::CheckoutController).to receive_messages(current_order: order)
|
89
|
+
allow_any_instance_of(Spree::CheckoutController).to receive_messages(try_spree_current_user: user)
|
91
90
|
end
|
92
91
|
|
93
92
|
it "redirects to payment page", inaccessible: true do
|
94
93
|
visit spree.checkout_state_path(:delivery)
|
95
94
|
click_button "Save and Continue"
|
96
95
|
choose "Credit Card"
|
97
|
-
fill_in "Card Number", :
|
98
|
-
fill_in "card_expiry", :
|
99
|
-
fill_in "Card Code", :
|
96
|
+
fill_in "Card Number", with: '123'
|
97
|
+
fill_in "card_expiry", with: '04 / 20'
|
98
|
+
fill_in "Card Code", with: '123'
|
100
99
|
click_button "Save and Continue"
|
101
100
|
click_button "Place Order"
|
102
101
|
expect(page).to have_content("Bogus Gateway: Forced failure")
|
@@ -117,12 +116,12 @@ describe "Checkout", type: :feature, inaccessible: true do
|
|
117
116
|
end
|
118
117
|
|
119
118
|
before(:each) do
|
120
|
-
allow_any_instance_of(Spree::CheckoutController).to receive_messages(:
|
121
|
-
allow_any_instance_of(Spree::CheckoutController).to receive_messages(:
|
122
|
-
allow_any_instance_of(Spree::CheckoutController).to receive_messages(
|
119
|
+
allow_any_instance_of(Spree::CheckoutController).to receive_messages(current_order: order)
|
120
|
+
allow_any_instance_of(Spree::CheckoutController).to receive_messages(try_spree_current_user: user)
|
121
|
+
allow_any_instance_of(Spree::CheckoutController).to receive_messages(skip_state_validation?: true)
|
123
122
|
end
|
124
123
|
|
125
|
-
it "prevents double clicking the payment button on checkout", :
|
124
|
+
it "prevents double clicking the payment button on checkout", js: true do
|
126
125
|
visit spree.checkout_state_path(:payment)
|
127
126
|
|
128
127
|
# prevent form submit to verify button is disabled
|
@@ -133,7 +132,7 @@ describe "Checkout", type: :feature, inaccessible: true do
|
|
133
132
|
expect(page).to have_selector('input.button[disabled]')
|
134
133
|
end
|
135
134
|
|
136
|
-
it "prevents double clicking the confirm button on checkout", :
|
135
|
+
it "prevents double clicking the confirm button on checkout", js: true do
|
137
136
|
order.payments << create(:payment)
|
138
137
|
visit spree.checkout_state_path(:confirm)
|
139
138
|
|
@@ -147,8 +146,8 @@ describe "Checkout", type: :feature, inaccessible: true do
|
|
147
146
|
end
|
148
147
|
|
149
148
|
context "when several payment methods are available" do
|
150
|
-
let(:credit_cart_payment) {create(:credit_card_payment_method) }
|
151
|
-
let(:check_payment) {create(:check_payment_method) }
|
149
|
+
let(:credit_cart_payment) { create(:credit_card_payment_method) }
|
150
|
+
let(:check_payment) { create(:check_payment_method) }
|
152
151
|
|
153
152
|
after do
|
154
153
|
Capybara.ignore_hidden_elements = true
|
@@ -157,7 +156,7 @@ describe "Checkout", type: :feature, inaccessible: true do
|
|
157
156
|
before do
|
158
157
|
Capybara.ignore_hidden_elements = false
|
159
158
|
order = OrderWalkthrough.up_to(:delivery)
|
160
|
-
allow(order).to receive_messages(:
|
159
|
+
allow(order).to receive_messages(available_payment_methods: [check_payment, credit_cart_payment])
|
161
160
|
order.user = create(:user)
|
162
161
|
order.update!
|
163
162
|
|
@@ -167,13 +166,13 @@ describe "Checkout", type: :feature, inaccessible: true do
|
|
167
166
|
visit spree.checkout_state_path(:payment)
|
168
167
|
end
|
169
168
|
|
170
|
-
it "the first payment method should be selected", :
|
169
|
+
it "the first payment method should be selected", js: true do
|
171
170
|
payment_method_css = "#order_payments_attributes__payment_method_id_"
|
172
171
|
expect(find("#{payment_method_css}#{check_payment.id}")).to be_checked
|
173
172
|
expect(find("#{payment_method_css}#{credit_cart_payment.id}")).not_to be_checked
|
174
173
|
end
|
175
174
|
|
176
|
-
it "the fields for the other payment methods should be hidden", :
|
175
|
+
it "the fields for the other payment methods should be hidden", js: true do
|
177
176
|
payment_method_css = "#payment_method_"
|
178
177
|
expect(find("#{payment_method_css}#{check_payment.id}")).to be_visible
|
179
178
|
expect(find("#{payment_method_css}#{credit_cart_payment.id}")).not_to be_visible
|
@@ -181,8 +180,7 @@ describe "Checkout", type: :feature, inaccessible: true do
|
|
181
180
|
end
|
182
181
|
|
183
182
|
context "user has payment sources", js: true do
|
184
|
-
|
185
|
-
let!(:bogus) { create(:credit_card_payment_method) }
|
183
|
+
let(:bogus) { create(:credit_card_payment_method) }
|
186
184
|
let(:user) { create(:user) }
|
187
185
|
|
188
186
|
let!(:credit_card) do
|
@@ -191,6 +189,7 @@ describe "Checkout", type: :feature, inaccessible: true do
|
|
191
189
|
|
192
190
|
before do
|
193
191
|
order = OrderWalkthrough.up_to(:delivery)
|
192
|
+
allow(order).to receive_messages(available_payment_methods: [bogus])
|
194
193
|
|
195
194
|
allow_any_instance_of(Spree::CheckoutController).to receive_messages(current_order: order)
|
196
195
|
allow_any_instance_of(Spree::CheckoutController).to receive_messages(try_spree_current_user: user)
|
@@ -200,23 +199,23 @@ describe "Checkout", type: :feature, inaccessible: true do
|
|
200
199
|
end
|
201
200
|
|
202
201
|
it "selects first source available and customer moves on" do
|
203
|
-
expect(find
|
202
|
+
expect(find("#use_existing_card_yes")).to be_checked
|
204
203
|
|
205
204
|
expect {
|
206
205
|
click_on "Save and Continue"
|
207
206
|
}.not_to change { Spree::CreditCard.count }
|
208
207
|
|
209
208
|
click_on "Place Order"
|
210
|
-
expect(
|
209
|
+
expect(page).to have_current_path(spree.order_path(Spree::Order.last))
|
211
210
|
end
|
212
211
|
|
213
212
|
it "allows user to enter a new source" do
|
214
213
|
choose "use_existing_card_no"
|
215
214
|
|
216
|
-
fill_in "Name on card", :
|
217
|
-
fill_in "Card Number", :
|
218
|
-
fill_in "card_expiry", :
|
219
|
-
fill_in "Card Code", :
|
215
|
+
fill_in "Name on card", with: 'Spree Commerce'
|
216
|
+
fill_in "Card Number", with: '4111111111111111'
|
217
|
+
fill_in "card_expiry", with: '04 / 20'
|
218
|
+
fill_in "Card Code", with: '123'
|
220
219
|
|
221
220
|
expect {
|
222
221
|
click_on "Save and Continue"
|
@@ -225,23 +224,23 @@ describe "Checkout", type: :feature, inaccessible: true do
|
|
225
224
|
expect(Spree::CreditCard.last.address).to be_present
|
226
225
|
|
227
226
|
click_on "Place Order"
|
228
|
-
expect(
|
227
|
+
expect(page).to have_current_path(spree.order_path(Spree::Order.last))
|
229
228
|
end
|
230
229
|
end
|
231
230
|
|
232
231
|
# regression for https://github.com/spree/spree/issues/2921
|
233
232
|
context "goes back from payment to add another item", js: true do
|
234
233
|
let!(:store) { FactoryGirl.create(:store) }
|
235
|
-
let!(:bag) { create(:product, :
|
234
|
+
let!(:bag) { create(:product, name: "RoR Bag") }
|
236
235
|
|
237
236
|
it "transit nicely through checkout steps again" do
|
238
237
|
add_mug_to_cart
|
239
238
|
click_on "Checkout"
|
240
|
-
fill_in "order_email", :
|
239
|
+
fill_in "order_email", with: "test@example.com"
|
241
240
|
fill_in_address
|
242
241
|
click_on "Save and Continue"
|
243
242
|
click_on "Save and Continue"
|
244
|
-
expect(
|
243
|
+
expect(page).to have_current_path(spree.checkout_state_path("payment"))
|
245
244
|
|
246
245
|
visit spree.root_path
|
247
246
|
click_link bag.name
|
@@ -249,13 +248,13 @@ describe "Checkout", type: :feature, inaccessible: true do
|
|
249
248
|
|
250
249
|
click_on "Checkout"
|
251
250
|
# edit an address field
|
252
|
-
fill_in "order_bill_address_attributes_firstname", :
|
251
|
+
fill_in "order_bill_address_attributes_firstname", with: "Ryann"
|
253
252
|
click_on "Save and Continue"
|
254
253
|
click_on "Save and Continue"
|
255
254
|
click_on "Save and Continue"
|
256
255
|
click_on "Place Order"
|
257
256
|
|
258
|
-
expect(
|
257
|
+
expect(page).to have_current_path(spree.order_path(Spree::Order.last))
|
259
258
|
end
|
260
259
|
end
|
261
260
|
|
@@ -263,11 +262,11 @@ describe "Checkout", type: :feature, inaccessible: true do
|
|
263
262
|
before do
|
264
263
|
add_mug_to_cart
|
265
264
|
click_on "Checkout"
|
266
|
-
fill_in "order_email", :
|
265
|
+
fill_in "order_email", with: "test@example.com"
|
267
266
|
fill_in_address
|
268
267
|
click_on "Save and Continue"
|
269
268
|
click_on "Save and Continue"
|
270
|
-
expect(
|
269
|
+
expect(page).to have_current_path(spree.checkout_state_path("payment"))
|
271
270
|
end
|
272
271
|
|
273
272
|
context "and updates line item quantity and try to reach payment page" do
|
@@ -282,7 +281,7 @@ describe "Checkout", type: :feature, inaccessible: true do
|
|
282
281
|
|
283
282
|
it "redirects user back to address step" do
|
284
283
|
visit spree.checkout_state_path("payment")
|
285
|
-
expect(
|
284
|
+
expect(page).to have_current_path(spree.checkout_state_path("address"))
|
286
285
|
end
|
287
286
|
|
288
287
|
it "updates shipments properly through step address -> delivery transitions" do
|
@@ -295,7 +294,7 @@ describe "Checkout", type: :feature, inaccessible: true do
|
|
295
294
|
end
|
296
295
|
|
297
296
|
context "and adds new product to cart and try to reach payment page" do
|
298
|
-
let!(:bag) { create(:product, :
|
297
|
+
let!(:bag) { create(:product, name: "RoR Bag") }
|
299
298
|
|
300
299
|
before do
|
301
300
|
visit spree.root_path
|
@@ -305,7 +304,7 @@ describe "Checkout", type: :feature, inaccessible: true do
|
|
305
304
|
|
306
305
|
it "redirects user back to address step" do
|
307
306
|
visit spree.checkout_state_path("payment")
|
308
|
-
expect(
|
307
|
+
expect(page).to have_current_path(spree.checkout_state_path("address"))
|
309
308
|
end
|
310
309
|
|
311
310
|
it "updates shipments properly through step address -> delivery transitions" do
|
@@ -329,12 +328,12 @@ describe "Checkout", type: :feature, inaccessible: true do
|
|
329
328
|
add_mug_to_cart
|
330
329
|
click_on "Checkout"
|
331
330
|
|
332
|
-
fill_in "order_email", :
|
331
|
+
fill_in "order_email", with: "test@example.com"
|
333
332
|
fill_in_address
|
334
333
|
click_on "Save and Continue"
|
335
334
|
|
336
335
|
click_on "Save and Continue"
|
337
|
-
expect(
|
336
|
+
expect(page).to have_current_path(spree.checkout_state_path("payment"))
|
338
337
|
end
|
339
338
|
|
340
339
|
it "makes sure payment reflects order total with discounts" do
|
@@ -358,7 +357,7 @@ describe "Checkout", type: :feature, inaccessible: true do
|
|
358
357
|
context "doesn't fill in coupon code input" do
|
359
358
|
it "advances just fine" do
|
360
359
|
click_on "Save and Continue"
|
361
|
-
expect(
|
360
|
+
expect(page).to have_current_path(spree.checkout_state_path("confirm"))
|
362
361
|
end
|
363
362
|
end
|
364
363
|
end
|
@@ -385,13 +384,13 @@ describe "Checkout", type: :feature, inaccessible: true do
|
|
385
384
|
end
|
386
385
|
|
387
386
|
it "goes right payment step and place order just fine" do
|
388
|
-
expect(
|
387
|
+
expect(page).to have_current_path(spree.checkout_state_path('payment'))
|
389
388
|
|
390
389
|
choose "Credit Card"
|
391
|
-
fill_in "Name on card", :
|
392
|
-
fill_in "Card Number", :
|
393
|
-
fill_in "card_expiry", :
|
394
|
-
fill_in "Card Code", :
|
390
|
+
fill_in "Name on card", with: 'Spree Commerce'
|
391
|
+
fill_in "Card Number", with: '4111111111111111'
|
392
|
+
fill_in "card_expiry", with: '04 / 20'
|
393
|
+
fill_in "Card Code", with: '123'
|
395
394
|
click_button "Save and Continue"
|
396
395
|
|
397
396
|
expect(current_path).to eq spree.checkout_state_path('confirm')
|
@@ -399,7 +398,6 @@ describe "Checkout", type: :feature, inaccessible: true do
|
|
399
398
|
end
|
400
399
|
end
|
401
400
|
|
402
|
-
|
403
401
|
context "save my address" do
|
404
402
|
before do
|
405
403
|
stock_location.stock_items.update_all(count_on_hand: 1)
|
@@ -437,9 +435,9 @@ describe "Checkout", type: :feature, inaccessible: true do
|
|
437
435
|
let!(:order) { OrderWalkthrough.up_to(:delivery) }
|
438
436
|
|
439
437
|
before(:each) do
|
440
|
-
allow_any_instance_of(Spree::CheckoutController).to receive_messages(:
|
441
|
-
allow_any_instance_of(Spree::CheckoutController).to receive_messages(:
|
442
|
-
allow_any_instance_of(Spree::OrdersController).to receive_messages(:
|
438
|
+
allow_any_instance_of(Spree::CheckoutController).to receive_messages(current_order: order)
|
439
|
+
allow_any_instance_of(Spree::CheckoutController).to receive_messages(try_spree_current_user: user)
|
440
|
+
allow_any_instance_of(Spree::OrdersController).to receive_messages(try_spree_current_user: user)
|
443
441
|
|
444
442
|
visit spree.checkout_state_path(:delivery)
|
445
443
|
click_button "Save and Continue"
|
@@ -17,10 +17,10 @@ describe "checkout with unshippable items", type: :feature, inaccessible: true d
|
|
17
17
|
order.user = user
|
18
18
|
order.update!
|
19
19
|
|
20
|
-
allow_any_instance_of(Spree::CheckoutController).to receive_messages(:
|
21
|
-
allow_any_instance_of(Spree::CheckoutController).to receive_messages(:
|
22
|
-
allow_any_instance_of(Spree::CheckoutController).to receive_messages(
|
23
|
-
allow_any_instance_of(Spree::CheckoutController).to receive_messages(:
|
20
|
+
allow_any_instance_of(Spree::CheckoutController).to receive_messages(current_order: order)
|
21
|
+
allow_any_instance_of(Spree::CheckoutController).to receive_messages(try_spree_current_user: user)
|
22
|
+
allow_any_instance_of(Spree::CheckoutController).to receive_messages(skip_state_validation?: true)
|
23
|
+
allow_any_instance_of(Spree::CheckoutController).to receive_messages(ensure_sufficient_stock_lines: true)
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'displays and removes' do
|
@@ -33,4 +33,3 @@ describe "checkout with unshippable items", type: :feature, inaccessible: true d
|
|
33
33
|
expect(order.line_items.count).to eq 1
|
34
34
|
end
|
35
35
|
end
|
36
|
-
|
@@ -1,12 +1,13 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe "Coupon code promotions", type: :feature, js: true do
|
4
|
-
let!(:
|
5
|
-
let!(:
|
4
|
+
let!(:store) { create(:store) }
|
5
|
+
let!(:country) { create(:country, name: "United States of America", states_required: true) }
|
6
|
+
let!(:state) { create(:state, name: "Alabama", country: country) }
|
6
7
|
let!(:zone) { create(:zone) }
|
7
8
|
let!(:shipping_method) { create(:shipping_method) }
|
8
9
|
let!(:payment_method) { create(:check_payment_method) }
|
9
|
-
let!(:product) { create(:product, :
|
10
|
+
let!(:product) { create(:product, name: "RoR Mug", price: 20) }
|
10
11
|
|
11
12
|
context "visitor makes checkout as guest without registration" do
|
12
13
|
def create_basic_coupon_promotion(code)
|
@@ -15,7 +16,7 @@ describe "Coupon code promotions", type: :feature, js: true do
|
|
15
16
|
name: code.titleize,
|
16
17
|
code: code,
|
17
18
|
starts_at: 1.day.ago,
|
18
|
-
expires_at: 1.day.from_now
|
19
|
+
expires_at: 1.day.from_now
|
19
20
|
)
|
20
21
|
|
21
22
|
calculator = Spree::Calculator::FlatRate.new
|
@@ -34,20 +35,19 @@ describe "Coupon code promotions", type: :feature, js: true do
|
|
34
35
|
# OrdersController
|
35
36
|
context "on the payment page" do
|
36
37
|
before do
|
37
|
-
|
38
38
|
visit spree.root_path
|
39
39
|
click_link "RoR Mug"
|
40
40
|
click_button "add-to-cart-button"
|
41
41
|
click_button "Checkout"
|
42
|
-
fill_in "order_email", :
|
43
|
-
fill_in "First Name", :
|
44
|
-
fill_in "Last Name", :
|
45
|
-
fill_in "Street Address", :
|
46
|
-
fill_in "City", :
|
47
|
-
fill_in "Zip", :
|
48
|
-
select country.name, :
|
49
|
-
select state.name, :
|
50
|
-
fill_in "Phone", :
|
42
|
+
fill_in "order_email", with: "spree@example.com"
|
43
|
+
fill_in "First Name", with: "John"
|
44
|
+
fill_in "Last Name", with: "Smith"
|
45
|
+
fill_in "Street Address", with: "1 John Street"
|
46
|
+
fill_in "City", with: "City of John"
|
47
|
+
fill_in "Zip", with: "01337"
|
48
|
+
select country.name, from: "Country"
|
49
|
+
select state.name, from: "order[bill_address_attributes][state_id]"
|
50
|
+
fill_in "Phone", with: "555-555-5555"
|
51
51
|
|
52
52
|
# To shipping method screen
|
53
53
|
click_button "Save and Continue"
|
@@ -56,23 +56,23 @@ describe "Coupon code promotions", type: :feature, js: true do
|
|
56
56
|
end
|
57
57
|
|
58
58
|
it "informs about an invalid coupon code" do
|
59
|
-
fill_in "order_coupon_code", :
|
59
|
+
fill_in "order_coupon_code", with: "coupon_codes_rule_man"
|
60
60
|
click_button "Save and Continue"
|
61
61
|
expect(page).to have_content(Spree.t(:coupon_code_not_found))
|
62
62
|
end
|
63
63
|
|
64
64
|
it "can enter an invalid coupon code, then a real one" do
|
65
|
-
fill_in "order_coupon_code", :
|
65
|
+
fill_in "order_coupon_code", with: "coupon_codes_rule_man"
|
66
66
|
click_button "Save and Continue"
|
67
67
|
expect(page).to have_content(Spree.t(:coupon_code_not_found))
|
68
|
-
fill_in "order_coupon_code", :
|
68
|
+
fill_in "order_coupon_code", with: "onetwo"
|
69
69
|
click_button "Save and Continue"
|
70
70
|
expect(page).to have_content("Promotion (Onetwo) -$10.00")
|
71
71
|
end
|
72
72
|
|
73
73
|
context "with a promotion" do
|
74
74
|
it "applies a promotion to an order" do
|
75
|
-
fill_in "order_coupon_code", :
|
75
|
+
fill_in "order_coupon_code", with: "onetwo"
|
76
76
|
click_button "Save and Continue"
|
77
77
|
expect(page).to have_content("Promotion (Onetwo) -$10.00")
|
78
78
|
end
|
@@ -81,7 +81,6 @@ describe "Coupon code promotions", type: :feature, js: true do
|
|
81
81
|
|
82
82
|
# CheckoutController
|
83
83
|
context "on the cart page" do
|
84
|
-
|
85
84
|
before do
|
86
85
|
visit spree.root_path
|
87
86
|
click_link "RoR Mug"
|
@@ -89,13 +88,13 @@ describe "Coupon code promotions", type: :feature, js: true do
|
|
89
88
|
end
|
90
89
|
|
91
90
|
it "can enter a coupon code and receives success notification" do
|
92
|
-
fill_in "order_coupon_code", :
|
91
|
+
fill_in "order_coupon_code", with: "onetwo"
|
93
92
|
click_button "Update"
|
94
93
|
expect(page).to have_content(Spree.t(:coupon_code_applied))
|
95
94
|
end
|
96
95
|
|
97
96
|
it "can enter a promotion code with both upper and lower case letters" do
|
98
|
-
fill_in "order_coupon_code", :
|
97
|
+
fill_in "order_coupon_code", with: "ONETwO"
|
99
98
|
click_button "Update"
|
100
99
|
expect(page).to have_content(Spree.t(:coupon_code_applied))
|
101
100
|
end
|
@@ -103,7 +102,7 @@ describe "Coupon code promotions", type: :feature, js: true do
|
|
103
102
|
it "informs the user about a coupon code which has exceeded its usage" do
|
104
103
|
expect_any_instance_of(Spree::Promotion).to receive(:usage_limit_exceeded?).and_return(true)
|
105
104
|
|
106
|
-
fill_in "order_coupon_code", :
|
105
|
+
fill_in "order_coupon_code", with: "onetwo"
|
107
106
|
click_button "Update"
|
108
107
|
expect(page).to have_content(Spree.t(:coupon_code_max_usage))
|
109
108
|
end
|
@@ -119,7 +118,7 @@ describe "Coupon code promotions", type: :feature, js: true do
|
|
119
118
|
specify do
|
120
119
|
visit spree.cart_path
|
121
120
|
|
122
|
-
fill_in "order_coupon_code", :
|
121
|
+
fill_in "order_coupon_code", with: "onetwo"
|
123
122
|
click_button "Update"
|
124
123
|
expect(page).to have_content(Spree.t(:item_total_less_than_or_equal, scope: [:eligibility_errors, :messages], amount: "$100.00"))
|
125
124
|
end
|
@@ -127,9 +126,9 @@ describe "Coupon code promotions", type: :feature, js: true do
|
|
127
126
|
|
128
127
|
it "informs the user if the coupon is expired" do
|
129
128
|
promotion.expires_at = Date.today.beginning_of_week
|
130
|
-
promotion.starts_at = Date.today.beginning_of_week.advance(:
|
129
|
+
promotion.starts_at = Date.today.beginning_of_week.advance(day: 3)
|
131
130
|
promotion.save!
|
132
|
-
fill_in "order_coupon_code", :
|
131
|
+
fill_in "order_coupon_code", with: "onetwo"
|
133
132
|
click_button "Update"
|
134
133
|
expect(page).to have_content(Spree.t(:coupon_code_expired))
|
135
134
|
end
|
@@ -141,7 +140,7 @@ describe "Coupon code promotions", type: :feature, js: true do
|
|
141
140
|
promotion.actions.first.calculator = calculator
|
142
141
|
promotion.save
|
143
142
|
|
144
|
-
create(:product, :
|
143
|
+
create(:product, name: "Spree Mug", price: 10)
|
145
144
|
end
|
146
145
|
|
147
146
|
specify do
|
@@ -150,14 +149,13 @@ describe "Coupon code promotions", type: :feature, js: true do
|
|
150
149
|
click_button "add-to-cart-button"
|
151
150
|
|
152
151
|
visit spree.cart_path
|
153
|
-
fill_in "order_coupon_code", :
|
152
|
+
fill_in "order_coupon_code", with: "onetwo"
|
154
153
|
click_button "Update"
|
155
154
|
|
156
|
-
fill_in "order_line_items_attributes_0_quantity", :
|
157
|
-
fill_in "order_line_items_attributes_1_quantity", :
|
155
|
+
fill_in "order_line_items_attributes_0_quantity", with: 2
|
156
|
+
fill_in "order_line_items_attributes_1_quantity", with: 2
|
158
157
|
click_button "Update"
|
159
158
|
|
160
|
-
|
161
159
|
within '#cart_adjustments' do
|
162
160
|
# 20% of $40 = 8
|
163
161
|
# 20% of $20 = 4
|