solidus_frontend 2.4.2 → 2.5.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.
- checksums.yaml +5 -5
- data/README.md +1 -5
- data/Rakefile +7 -7
- data/app/assets/config/solidus_frontend_manifest.js +0 -2
- data/app/assets/javascripts/spree/frontend.js +0 -1
- data/app/assets/javascripts/spree/frontend/cart.js +30 -0
- data/app/assets/javascripts/spree/frontend/checkout.js +24 -0
- data/app/assets/javascripts/spree/frontend/checkout/address.js +128 -0
- data/app/assets/javascripts/spree/frontend/checkout/coupon-code.js +40 -0
- data/app/assets/javascripts/spree/frontend/checkout/payment.js +55 -0
- data/app/assets/javascripts/spree/frontend/product.js +81 -0
- data/app/assets/stylesheets/spree/frontend/_variables.scss +3 -0
- data/app/assets/stylesheets/spree/frontend/screen.css.scss +2 -2
- data/app/controllers/spree/checkout_controller.rb +3 -3
- data/app/controllers/spree/locale_controller.rb +2 -2
- data/app/controllers/spree/orders_controller.rb +5 -6
- data/app/controllers/spree/products_controller.rb +0 -1
- data/app/controllers/spree/store_controller.rb +1 -1
- data/app/controllers/spree/taxons_controller.rb +0 -1
- data/app/views/spree/address/_form.html.erb +23 -21
- data/app/views/spree/checkout/_address.html.erb +5 -5
- data/app/views/spree/checkout/_confirm.html.erb +3 -3
- data/app/views/spree/checkout/_delivery.html.erb +18 -14
- data/app/views/spree/checkout/_payment.html.erb +6 -6
- data/app/views/spree/checkout/_summary.html.erb +5 -5
- data/app/views/spree/checkout/edit.html.erb +2 -6
- data/app/views/spree/checkout/payment/_gateway.html.erb +9 -9
- data/app/views/spree/content/cvv.html.erb +1 -1
- data/app/views/spree/orders/_adjustments.html.erb +4 -4
- data/app/views/spree/orders/_form.html.erb +6 -6
- data/app/views/spree/orders/_line_item.html.erb +4 -4
- data/app/views/spree/orders/edit.html.erb +9 -9
- data/app/views/spree/orders/show.html.erb +4 -4
- data/app/views/spree/payments/_payment.html.erb +1 -1
- data/app/views/spree/products/_cart_form.html.erb +7 -7
- data/app/views/spree/products/_image.html.erb +2 -2
- data/app/views/spree/products/_promotions.html.erb +1 -1
- data/app/views/spree/products/_properties.html.erb +1 -1
- data/app/views/spree/products/_taxons.html.erb +1 -1
- data/app/views/spree/products/index.html.erb +1 -1
- data/app/views/spree/products/show.html.erb +1 -1
- data/app/views/spree/shared/_address.html.erb +2 -2
- data/app/views/spree/shared/_filters.html.erb +2 -2
- data/app/views/spree/shared/_footer.html.erb +1 -1
- data/app/views/spree/shared/_image.html.erb +12 -0
- data/app/views/spree/shared/_login_bar_items.html.erb +1 -0
- data/app/views/spree/shared/_main_nav_bar.html.erb +2 -2
- data/app/views/spree/shared/_nav_bar.html.erb +1 -0
- data/app/views/spree/shared/_order_details.html.erb +20 -20
- data/app/views/spree/shared/_products.html.erb +3 -3
- data/app/views/spree/shared/_search.html.erb +3 -3
- data/app/views/spree/shared/_shipment_tracking.html.erb +1 -1
- data/app/views/spree/shared/_taxonomies.html.erb +2 -2
- data/lib/generators/solidus/views/override_generator.rb +1 -0
- data/lib/spree/frontend.rb +4 -2
- data/solidus_frontend.gemspec +1 -2
- data/spec/controllers/spree/checkout_controller_spec.rb +12 -12
- data/spec/controllers/spree/current_order_tracking_spec.rb +1 -1
- data/spec/controllers/spree/orders_controller_ability_spec.rb +6 -4
- data/spec/controllers/spree/orders_controller_spec.rb +4 -3
- data/spec/controllers/spree/orders_controller_transitions_spec.rb +1 -1
- data/spec/controllers/spree/products_controller_spec.rb +3 -2
- data/spec/features/caching/products_spec.rb +7 -7
- data/spec/features/cart_spec.rb +1 -1
- data/spec/features/checkout_spec.rb +10 -9
- data/spec/features/coupon_code_spec.rb +12 -13
- data/spec/features/locale_spec.rb +0 -38
- data/spec/features/order_spec.rb +1 -1
- data/spec/features/products_spec.rb +4 -4
- data/spec/features/promotion_code_invalidation_spec.rb +3 -3
- data/spec/features/quantity_promotions_spec.rb +5 -5
- data/spec/generators/solidus/views/override_generator_spec.rb +2 -1
- data/spec/spec_helper.rb +19 -41
- data/spec/support/shared_contexts/custom_products.rb +17 -17
- metadata +19 -88
- data/Gemfile +0 -7
- data/app/assets/javascripts/spree/frontend/cart.js.coffee +0 -15
- data/app/assets/javascripts/spree/frontend/checkout.js.coffee +0 -17
- data/app/assets/javascripts/spree/frontend/checkout/address.js.coffee +0 -91
- data/app/assets/javascripts/spree/frontend/checkout/coupon-code.js.coffee +0 -34
- data/app/assets/javascripts/spree/frontend/checkout/payment.js.coffee +0 -42
- data/app/assets/javascripts/spree/frontend/product.js.coffee +0 -47
- data/vendor/assets/javascripts/jquery.validate/additional-methods.min.js +0 -12
- data/vendor/assets/javascripts/jquery.validate/jquery.validate.min.js +0 -12
- data/vendor/assets/javascripts/jquery.validate/localization/messages_ar.js +0 -25
- data/vendor/assets/javascripts/jquery.validate/localization/messages_bg.js +0 -25
- data/vendor/assets/javascripts/jquery.validate/localization/messages_ca.js +0 -25
- data/vendor/assets/javascripts/jquery.validate/localization/messages_cs.js +0 -25
- data/vendor/assets/javascripts/jquery.validate/localization/messages_da.js +0 -22
- data/vendor/assets/javascripts/jquery.validate/localization/messages_de.js +0 -22
- data/vendor/assets/javascripts/jquery.validate/localization/messages_el.js +0 -25
- data/vendor/assets/javascripts/jquery.validate/localization/messages_es.js +0 -25
- data/vendor/assets/javascripts/jquery.validate/localization/messages_et.js +0 -23
- data/vendor/assets/javascripts/jquery.validate/localization/messages_eu.js +0 -25
- data/vendor/assets/javascripts/jquery.validate/localization/messages_fa.js +0 -25
- data/vendor/assets/javascripts/jquery.validate/localization/messages_fi.js +0 -23
- data/vendor/assets/javascripts/jquery.validate/localization/messages_fr.js +0 -47
- data/vendor/assets/javascripts/jquery.validate/localization/messages_ge.js +0 -23
- data/vendor/assets/javascripts/jquery.validate/localization/messages_he.js +0 -25
- data/vendor/assets/javascripts/jquery.validate/localization/messages_hr.js +0 -25
- data/vendor/assets/javascripts/jquery.validate/localization/messages_hu.js +0 -24
- data/vendor/assets/javascripts/jquery.validate/localization/messages_it.js +0 -25
- data/vendor/assets/javascripts/jquery.validate/localization/messages_ja.js +0 -25
- data/vendor/assets/javascripts/jquery.validate/localization/messages_ka.js +0 -25
- data/vendor/assets/javascripts/jquery.validate/localization/messages_kk.js +0 -25
- data/vendor/assets/javascripts/jquery.validate/localization/messages_ko.js +0 -25
- data/vendor/assets/javascripts/jquery.validate/localization/messages_lt.js +0 -25
- data/vendor/assets/javascripts/jquery.validate/localization/messages_lv.js +0 -25
- data/vendor/assets/javascripts/jquery.validate/localization/messages_ms.js +0 -25
- data/vendor/assets/javascripts/jquery.validate/localization/messages_nl.js +0 -35
- data/vendor/assets/javascripts/jquery.validate/localization/messages_no.js +0 -25
- data/vendor/assets/javascripts/jquery.validate/localization/messages_pl.js +0 -25
- data/vendor/assets/javascripts/jquery.validate/localization/messages_ptbr.js +0 -24
- data/vendor/assets/javascripts/jquery.validate/localization/messages_ptpt.js +0 -24
- data/vendor/assets/javascripts/jquery.validate/localization/messages_ro.js +0 -25
- data/vendor/assets/javascripts/jquery.validate/localization/messages_ru.js +0 -25
- data/vendor/assets/javascripts/jquery.validate/localization/messages_se.js +0 -23
- data/vendor/assets/javascripts/jquery.validate/localization/messages_si.js +0 -25
- data/vendor/assets/javascripts/jquery.validate/localization/messages_sk.js +0 -22
- data/vendor/assets/javascripts/jquery.validate/localization/messages_sl.js +0 -25
- data/vendor/assets/javascripts/jquery.validate/localization/messages_sr.js +0 -25
- data/vendor/assets/javascripts/jquery.validate/localization/messages_sv.js +0 -23
- data/vendor/assets/javascripts/jquery.validate/localization/messages_th.js +0 -25
- data/vendor/assets/javascripts/jquery.validate/localization/messages_tr.js +0 -25
- data/vendor/assets/javascripts/jquery.validate/localization/messages_tw.js +0 -24
- data/vendor/assets/javascripts/jquery.validate/localization/messages_uk.js +0 -25
- data/vendor/assets/javascripts/jquery.validate/localization/messages_vi.js +0 -25
- data/vendor/assets/javascripts/jquery.validate/localization/messages_zh.js +0 -25
- data/vendor/assets/javascripts/jquery.validate/localization/messages_zhtw.js +0 -26
- data/vendor/assets/javascripts/jquery.validate/localization/methods_de.js +0 -12
- data/vendor/assets/javascripts/jquery.validate/localization/methods_nl.js +0 -9
- data/vendor/assets/javascripts/jquery.validate/localization/methods_pt.js +0 -9
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
<div data-hook="products_search_results_heading">
|
|
13
13
|
<% if products.empty? %>
|
|
14
14
|
<div data-hook="products_search_results_heading_no_results_found">
|
|
15
|
-
<%=
|
|
15
|
+
<%= t('spree.no_products_found') %>
|
|
16
16
|
</div>
|
|
17
17
|
<% elsif params.key?(:keywords) %>
|
|
18
18
|
<div data-hook="products_search_results_heading_results_found">
|
|
19
|
-
<h6 class="search-results-title"><%=
|
|
19
|
+
<h6 class="search-results-title"><%= t('spree.search_results', keywords: h(params[:keywords])) %></h6>
|
|
20
20
|
</div>
|
|
21
21
|
<% end %>
|
|
22
22
|
</div>
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
<li id="product_<%= product.id %>" class="columns three <%= cycle("alpha", "secondary", "", "omega secondary", name: "classes") %>" data-hook="products_list_item" itemscope itemtype="http://schema.org/Product">
|
|
29
29
|
<% cache(@taxon.present? ? [I18n.locale, current_pricing_options, @taxon, product] : [I18n.locale, current_pricing_options, product]) do %>
|
|
30
30
|
<div class="product-image">
|
|
31
|
-
<%= link_to
|
|
31
|
+
<%= link_to(render('spree/shared/image', image: product.display_image, size: :small, itemprop: "image"), url, itemprop: 'url') %>
|
|
32
32
|
</div>
|
|
33
33
|
<%= link_to truncate(product.name, length: 50), url, class: 'info', itemprop: "name", title: product.name %>
|
|
34
34
|
<span itemprop="offers" itemscope itemtype="http://schema.org/Offer">
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
<%= form_tag spree.products_path, method: :get do %>
|
|
3
3
|
<% cache [I18n.locale, @taxons] do %>
|
|
4
4
|
<%= select_tag :taxon,
|
|
5
|
-
options_for_select([[
|
|
5
|
+
options_for_select([[t('spree.all_departments'), '']] +
|
|
6
6
|
@taxons.map {|t| [t.name, t.id]},
|
|
7
7
|
@taxon ? @taxon.id : params[:taxon]), 'aria-label' => 'Taxon' %>
|
|
8
8
|
<% end %>
|
|
9
|
-
<%= search_field_tag :keywords, params[:keywords], placeholder:
|
|
10
|
-
<%= submit_tag
|
|
9
|
+
<%= search_field_tag :keywords, params[:keywords], placeholder: t('spree.search') %>
|
|
10
|
+
<%= submit_tag t('spree.search'), name: nil %>
|
|
11
11
|
<% end %>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<% max_level = Spree::Config[:max_level_in_taxons_menu] || 1 %>
|
|
2
2
|
<nav id="taxonomies" class="sidebar-item" data-hook>
|
|
3
3
|
<% @taxonomies.each do |taxonomy| %>
|
|
4
|
-
<% cache [I18n.locale, taxonomy, max_level] do %>
|
|
5
|
-
<h6 class='taxonomy-root'><%=
|
|
4
|
+
<% cache [I18n.locale, taxonomy, @taxon, max_level] do %>
|
|
5
|
+
<h6 class='taxonomy-root'><%= t('spree.shop_by_taxonomy', taxonomy: taxonomy.name) %></h6>
|
|
6
6
|
<%= taxons_tree(taxonomy.root, @taxon, max_level) %>
|
|
7
7
|
<% end %>
|
|
8
8
|
<% end %>
|
data/lib/spree/frontend.rb
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
require 'rails/all'
|
|
2
2
|
require 'jquery-rails'
|
|
3
3
|
require 'canonical-rails'
|
|
4
|
-
require 'coffee-rails'
|
|
5
4
|
require 'sass-rails'
|
|
6
5
|
require 'font-awesome-rails'
|
|
6
|
+
require 'responders'
|
|
7
|
+
require 'kaminari'
|
|
7
8
|
|
|
8
|
-
require '
|
|
9
|
+
require 'solidus_core'
|
|
10
|
+
require 'solidus_api'
|
|
9
11
|
|
|
10
12
|
require 'spree/frontend/middleware/seo_assist'
|
|
11
13
|
require 'spree/frontend/engine'
|
data/solidus_frontend.gemspec
CHANGED
|
@@ -26,10 +26,9 @@ Gem::Specification.new do |s|
|
|
|
26
26
|
s.add_dependency 'canonical-rails', '~> 0.2.0'
|
|
27
27
|
s.add_dependency 'jquery-rails'
|
|
28
28
|
s.add_dependency 'sass-rails'
|
|
29
|
-
s.add_dependency 'coffee-rails'
|
|
30
29
|
s.add_dependency 'font-awesome-rails', '~> 4.0'
|
|
31
30
|
s.add_dependency 'truncate_html', '~> 0.9', '>= 0.9.2'
|
|
32
|
-
s.add_dependency 'kaminari', '
|
|
31
|
+
s.add_dependency 'kaminari', '~> 1.1'
|
|
33
32
|
|
|
34
33
|
s.add_development_dependency 'capybara-accessible'
|
|
35
34
|
end
|
|
@@ -3,10 +3,10 @@ require 'spec_helper'
|
|
|
3
3
|
describe Spree::CheckoutController, type: :controller do
|
|
4
4
|
let(:token) { 'some_token' }
|
|
5
5
|
let(:user) { create(:user) }
|
|
6
|
-
let(:order) {
|
|
6
|
+
let(:order) { FactoryBot.create(:order_with_totals) }
|
|
7
7
|
|
|
8
8
|
let(:address_params) do
|
|
9
|
-
address =
|
|
9
|
+
address = FactoryBot.build(:address)
|
|
10
10
|
address.attributes.except("created_at", "updated_at")
|
|
11
11
|
end
|
|
12
12
|
|
|
@@ -85,7 +85,7 @@ describe Spree::CheckoutController, type: :controller do
|
|
|
85
85
|
before do
|
|
86
86
|
# Must have *a* shipping method and a payment method so updating from address works
|
|
87
87
|
allow(order).to receive_messages ensure_available_shipping_rates: true
|
|
88
|
-
order.line_items <<
|
|
88
|
+
order.line_items << FactoryBot.create(:line_item)
|
|
89
89
|
end
|
|
90
90
|
|
|
91
91
|
context "with the order in the cart state" do
|
|
@@ -291,7 +291,7 @@ describe Spree::CheckoutController, type: :controller do
|
|
|
291
291
|
|
|
292
292
|
it "should populate the flash message" do
|
|
293
293
|
post :update, params: { state: "confirm" }
|
|
294
|
-
expect(flash.notice).to eq(
|
|
294
|
+
expect(flash.notice).to eq(I18n.t('spree.order_processed_successfully'))
|
|
295
295
|
end
|
|
296
296
|
|
|
297
297
|
it "should remove completed order from current_order" do
|
|
@@ -346,14 +346,14 @@ describe Spree::CheckoutController, type: :controller do
|
|
|
346
346
|
|
|
347
347
|
it "should render the edit template and display exception message" do
|
|
348
348
|
expect(response).to render_template :edit
|
|
349
|
-
expect(flash.now[:error]).to eq(
|
|
349
|
+
expect(flash.now[:error]).to eq(I18n.t('spree.spree_gateway_error_flash_for_checkout'))
|
|
350
350
|
expect(assigns(:order).errors[:base]).to include("Invalid something or other.")
|
|
351
351
|
end
|
|
352
352
|
end
|
|
353
353
|
|
|
354
354
|
context "fails to transition from address" do
|
|
355
355
|
let(:order) do
|
|
356
|
-
|
|
356
|
+
FactoryBot.create(:order_with_line_items).tap do |order|
|
|
357
357
|
order.next!
|
|
358
358
|
expect(order.state).to eq('address')
|
|
359
359
|
end
|
|
@@ -387,7 +387,7 @@ describe Spree::CheckoutController, type: :controller do
|
|
|
387
387
|
|
|
388
388
|
it "due to no available shipping rates for any of the shipments" do
|
|
389
389
|
put :update, params: { state: "address", order: {} }
|
|
390
|
-
expect(flash[:error]).to eq(
|
|
390
|
+
expect(flash[:error]).to eq(I18n.t('spree.items_cannot_be_shipped'))
|
|
391
391
|
expect(response).to redirect_to(spree.checkout_state_path('address'))
|
|
392
392
|
end
|
|
393
393
|
end
|
|
@@ -395,13 +395,13 @@ describe Spree::CheckoutController, type: :controller do
|
|
|
395
395
|
|
|
396
396
|
context "when GatewayError is raised" do
|
|
397
397
|
let(:order) do
|
|
398
|
-
|
|
398
|
+
FactoryBot.create(:order_with_line_items).tap do |order|
|
|
399
399
|
until order.state == 'payment'
|
|
400
400
|
order.next!
|
|
401
401
|
end
|
|
402
402
|
# So that the confirmation step is skipped and we get straight to the action.
|
|
403
|
-
payment_method =
|
|
404
|
-
payment =
|
|
403
|
+
payment_method = FactoryBot.create(:simple_credit_card_payment_method)
|
|
404
|
+
payment = FactoryBot.create(:payment, payment_method: payment_method, amount: order.total)
|
|
405
405
|
order.payments << payment
|
|
406
406
|
order.next!
|
|
407
407
|
end
|
|
@@ -413,9 +413,9 @@ describe Spree::CheckoutController, type: :controller do
|
|
|
413
413
|
end
|
|
414
414
|
|
|
415
415
|
it "fails to transition from payment to complete" do
|
|
416
|
-
allow_any_instance_of(Spree::Payment).to receive(:process!).and_raise(Spree::Core::GatewayError.new(
|
|
416
|
+
allow_any_instance_of(Spree::Payment).to receive(:process!).and_raise(Spree::Core::GatewayError.new(I18n.t('spree.payment_processing_failed')))
|
|
417
417
|
put :update, params: { state: order.state, order: {} }
|
|
418
|
-
expect(flash[:error]).to eq(
|
|
418
|
+
expect(flash[:error]).to eq(I18n.t('spree.payment_processing_failed'))
|
|
419
419
|
end
|
|
420
420
|
end
|
|
421
421
|
end
|
|
@@ -10,7 +10,7 @@ describe 'current order tracking', type: :controller do
|
|
|
10
10
|
end
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
let(:order) {
|
|
13
|
+
let(:order) { FactoryBot.create(:order) }
|
|
14
14
|
|
|
15
15
|
it 'automatically tracks who the order was created by & IP address' do
|
|
16
16
|
allow(controller).to receive_messages(try_spree_current_user: user)
|
|
@@ -8,6 +8,7 @@ module Spree
|
|
|
8
8
|
let(:user) { create(:user) }
|
|
9
9
|
let(:guest_user) { create(:user) }
|
|
10
10
|
let(:order) { Spree::Order.create }
|
|
11
|
+
let(:variant) { create(:variant) }
|
|
11
12
|
|
|
12
13
|
it 'should understand order routes with token' do
|
|
13
14
|
expect(spree.token_order_path('R123456', 'ABCDEF')).to eq('/orders/R123456/token/ABCDEF')
|
|
@@ -25,11 +26,11 @@ module Spree
|
|
|
25
26
|
context '#populate' do
|
|
26
27
|
it 'should check if user is authorized for :edit' do
|
|
27
28
|
expect(controller).to receive(:authorize!).with(:edit, order, token)
|
|
28
|
-
post :populate, params: { token: token }
|
|
29
|
+
post :populate, params: { variant_id: variant.id, token: token }
|
|
29
30
|
end
|
|
30
31
|
it "should check against the specified order" do
|
|
31
32
|
expect(controller).to receive(:authorize!).with(:edit, specified_order, token)
|
|
32
|
-
post :populate, params: { id: specified_order.number, token: token }
|
|
33
|
+
post :populate, params: { id: specified_order.number, variant_id: variant.id, token: token }
|
|
33
34
|
end
|
|
34
35
|
end
|
|
35
36
|
|
|
@@ -95,8 +96,9 @@ module Spree
|
|
|
95
96
|
|
|
96
97
|
context 'when no token present' do
|
|
97
98
|
it 'should respond with 404' do
|
|
98
|
-
|
|
99
|
-
|
|
99
|
+
expect {
|
|
100
|
+
get :show, params: { id: 'R123' }
|
|
101
|
+
}.to raise_error(ActiveRecord::RecordNotFound)
|
|
100
102
|
end
|
|
101
103
|
end
|
|
102
104
|
end
|
|
@@ -16,7 +16,8 @@ describe Spree::OrdersController, type: :controller do
|
|
|
16
16
|
|
|
17
17
|
context "#populate" do
|
|
18
18
|
it "should create a new order when none specified" do
|
|
19
|
-
post :populate
|
|
19
|
+
post :populate, params: { variant_id: variant.id }
|
|
20
|
+
expect(response).to be_redirect
|
|
20
21
|
expect(cookies.signed[:guest_token]).not_to be_blank
|
|
21
22
|
|
|
22
23
|
order_by_token = Spree::Order.find_by(guest_token: cookies.signed[:guest_token])
|
|
@@ -65,7 +66,7 @@ describe Spree::OrdersController, type: :controller do
|
|
|
65
66
|
|
|
66
67
|
expect(response).to redirect_to(spree.root_path)
|
|
67
68
|
expect(flash[:error]).to eq(
|
|
68
|
-
|
|
69
|
+
I18n.t('spree.please_enter_reasonable_quantity')
|
|
69
70
|
)
|
|
70
71
|
end
|
|
71
72
|
|
|
@@ -150,7 +151,7 @@ describe Spree::OrdersController, type: :controller do
|
|
|
150
151
|
|
|
151
152
|
it "cannot update a blank order" do
|
|
152
153
|
put :update, params: { order: { email: "foo" } }
|
|
153
|
-
expect(flash[:error]).to eq(
|
|
154
|
+
expect(flash[:error]).to eq(I18n.t('spree.order_not_found'))
|
|
154
155
|
expect(response).to redirect_to(spree.root_path)
|
|
155
156
|
end
|
|
156
157
|
end
|
|
@@ -22,7 +22,7 @@ module Spree
|
|
|
22
22
|
|
|
23
23
|
it "correctly calls the transition callback" do
|
|
24
24
|
expect(order.did_transition).to be_nil
|
|
25
|
-
order.line_items <<
|
|
25
|
+
order.line_items << FactoryBot.create(:line_item)
|
|
26
26
|
put :update, params: { checkout: "checkout" }
|
|
27
27
|
expect(order.did_transition).to be true
|
|
28
28
|
end
|
|
@@ -11,8 +11,9 @@ describe Spree::ProductsController, type: :controller do
|
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
it "cannot view non-active products" do
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
expect {
|
|
15
|
+
get :show, params: { id: product.to_param }
|
|
16
|
+
}.to raise_error(ActiveRecord::RecordNotFound)
|
|
16
17
|
end
|
|
17
18
|
|
|
18
19
|
it "should provide the current user to the searcher class" do
|
|
@@ -30,23 +30,23 @@ describe 'products', type: :feature, caching: true do
|
|
|
30
30
|
expect(cache_writes.count).to eq(2)
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
-
it "busts the cache when all products are deleted" do
|
|
34
|
-
product.
|
|
35
|
-
product2.
|
|
33
|
+
it "busts the cache when all products are soft-deleted" do
|
|
34
|
+
product.discard
|
|
35
|
+
product2.discard
|
|
36
36
|
visit spree.root_path
|
|
37
37
|
assert_written_to_cache("views/en/USD/spree/products/all--#{Date.today.to_s(:number)}-0")
|
|
38
38
|
expect(cache_writes.count).to eq(1)
|
|
39
39
|
end
|
|
40
40
|
|
|
41
|
-
it "busts the cache when the newest product is deleted" do
|
|
42
|
-
product.
|
|
41
|
+
it "busts the cache when the newest product is soft-deleted" do
|
|
42
|
+
product.discard
|
|
43
43
|
visit spree.root_path
|
|
44
44
|
assert_written_to_cache("views/en/USD/spree/products/all--#{product2.updated_at.utc.to_s(:number)}")
|
|
45
45
|
expect(cache_writes.count).to eq(1)
|
|
46
46
|
end
|
|
47
47
|
|
|
48
|
-
it "busts the cache when an older product is deleted" do
|
|
49
|
-
product2.
|
|
48
|
+
it "busts the cache when an older product is soft-deleted" do
|
|
49
|
+
product2.discard
|
|
50
50
|
visit spree.root_path
|
|
51
51
|
assert_written_to_cache("views/en/USD/spree/products/all--#{product.updated_at.utc.to_s(:number)}")
|
|
52
52
|
expect(cache_writes.count).to eq(1)
|
data/spec/features/cart_spec.rb
CHANGED
|
@@ -27,7 +27,7 @@ describe "Cart", type: :feature, inaccessible: true do
|
|
|
27
27
|
it "does not error out with a 404 when GET'ing to /orders/populate" do
|
|
28
28
|
visit '/orders/populate'
|
|
29
29
|
within(".error") do
|
|
30
|
-
expect(page).to have_content(
|
|
30
|
+
expect(page).to have_content(I18n.t('spree.populate_get_error'))
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
33
|
|
|
@@ -88,7 +88,7 @@ describe "Checkout", type: :feature, inaccessible: true do
|
|
|
88
88
|
let!(:order) do
|
|
89
89
|
order = Spree::Order.create!(
|
|
90
90
|
email: "spree@example.com",
|
|
91
|
-
store: Spree::Store.first ||
|
|
91
|
+
store: Spree::Store.first || FactoryBot.create(:store)
|
|
92
92
|
)
|
|
93
93
|
|
|
94
94
|
order.reload
|
|
@@ -348,7 +348,7 @@ describe "Checkout", type: :feature, inaccessible: true do
|
|
|
348
348
|
choose "use_existing_card_no"
|
|
349
349
|
|
|
350
350
|
fill_in "Name on card", with: 'Spree Commerce'
|
|
351
|
-
fill_in "Card Number", with: '
|
|
351
|
+
fill_in "Card Number", with: '4111 1111 1111 1111'
|
|
352
352
|
fill_in "card_expiry", with: '04 / 20'
|
|
353
353
|
fill_in "Card Code", with: '123'
|
|
354
354
|
|
|
@@ -365,7 +365,7 @@ describe "Checkout", type: :feature, inaccessible: true do
|
|
|
365
365
|
|
|
366
366
|
# regression for https://github.com/spree/spree/issues/2921
|
|
367
367
|
context "goes back from payment to add another item", js: true do
|
|
368
|
-
let!(:store) {
|
|
368
|
+
let!(:store) { FactoryBot.create(:store) }
|
|
369
369
|
let!(:bag) { create(:product, name: "RoR Bag") }
|
|
370
370
|
|
|
371
371
|
it "transit nicely through checkout steps again" do
|
|
@@ -484,7 +484,7 @@ describe "Checkout", type: :feature, inaccessible: true do
|
|
|
484
484
|
fill_in "Coupon Code", with: 'invalid'
|
|
485
485
|
click_on "Apply Code"
|
|
486
486
|
|
|
487
|
-
expect(page).to have_content(
|
|
487
|
+
expect(page).to have_content(I18n.t('spree.coupon_code_not_found'))
|
|
488
488
|
end
|
|
489
489
|
end
|
|
490
490
|
|
|
@@ -522,7 +522,7 @@ describe "Checkout", type: :feature, inaccessible: true do
|
|
|
522
522
|
|
|
523
523
|
choose "Credit Card"
|
|
524
524
|
fill_in "Name on card", with: 'Spree Commerce'
|
|
525
|
-
fill_in "Card Number", with: '
|
|
525
|
+
fill_in "Card Number", with: '4111 1111 1111 1111'
|
|
526
526
|
fill_in "card_expiry", with: '04 / 20'
|
|
527
527
|
fill_in "Card Code", with: '123'
|
|
528
528
|
click_button "Save and Continue"
|
|
@@ -580,12 +580,12 @@ describe "Checkout", type: :feature, inaccessible: true do
|
|
|
580
580
|
end
|
|
581
581
|
|
|
582
582
|
it "displays a thank you message" do
|
|
583
|
-
expect(page).to have_content(
|
|
583
|
+
expect(page).to have_content(I18n.t('spree.thank_you_for_your_order'))
|
|
584
584
|
end
|
|
585
585
|
|
|
586
586
|
it "does not display a thank you message on that order future visits" do
|
|
587
587
|
visit spree.order_path(order)
|
|
588
|
-
expect(page).to_not have_content(
|
|
588
|
+
expect(page).to_not have_content(I18n.t('spree.thank_you_for_your_order'))
|
|
589
589
|
end
|
|
590
590
|
end
|
|
591
591
|
|
|
@@ -607,6 +607,7 @@ describe "Checkout", type: :feature, inaccessible: true do
|
|
|
607
607
|
state_name_css = "order_bill_address_attributes_state_name"
|
|
608
608
|
|
|
609
609
|
select "Canada", from: "order_bill_address_attributes_country_id"
|
|
610
|
+
fill_in 'Customer E-Mail', with: 'test@example.com'
|
|
610
611
|
fill_in state_name_css, with: xss_string
|
|
611
612
|
fill_in "Zip", with: "H0H0H0"
|
|
612
613
|
|
|
@@ -654,7 +655,7 @@ describe "Checkout", type: :feature, inaccessible: true do
|
|
|
654
655
|
click_on "Save and Continue"
|
|
655
656
|
click_on "Save and Continue"
|
|
656
657
|
|
|
657
|
-
fill_in_credit_card(number: "
|
|
658
|
+
fill_in_credit_card(number: "4111 1111 1111 1111")
|
|
658
659
|
click_on "Save and Continue"
|
|
659
660
|
|
|
660
661
|
expect(page).to have_current_path("/checkout/confirm")
|
|
@@ -663,7 +664,7 @@ describe "Checkout", type: :feature, inaccessible: true do
|
|
|
663
664
|
|
|
664
665
|
def fill_in_credit_card(number:)
|
|
665
666
|
fill_in "Card Number", with: number
|
|
666
|
-
fill_in "Expiration", with: "
|
|
667
|
+
fill_in "Expiration", with: "12 / 24"
|
|
667
668
|
fill_in "Card Code", with: "123"
|
|
668
669
|
end
|
|
669
670
|
|
|
@@ -58,13 +58,13 @@ describe "Coupon code promotions", type: :feature, js: true do
|
|
|
58
58
|
it "informs about an invalid coupon code" do
|
|
59
59
|
fill_in "order_coupon_code", with: "coupon_codes_rule_man"
|
|
60
60
|
click_button "Save and Continue"
|
|
61
|
-
expect(page).to have_content(
|
|
61
|
+
expect(page).to have_content(I18n.t('spree.coupon_code_not_found'))
|
|
62
62
|
end
|
|
63
63
|
|
|
64
64
|
it "can enter an invalid coupon code, then a real one" do
|
|
65
65
|
fill_in "order_coupon_code", with: "coupon_codes_rule_man"
|
|
66
66
|
click_button "Save and Continue"
|
|
67
|
-
expect(page).to have_content(
|
|
67
|
+
expect(page).to have_content(I18n.t('spree.coupon_code_not_found'))
|
|
68
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")
|
|
@@ -90,13 +90,13 @@ describe "Coupon code promotions", type: :feature, js: true do
|
|
|
90
90
|
it "can enter a coupon code and receives success notification" do
|
|
91
91
|
fill_in "order_coupon_code", with: "onetwo"
|
|
92
92
|
click_button "Update"
|
|
93
|
-
expect(page).to have_content(
|
|
93
|
+
expect(page).to have_content(I18n.t('spree.coupon_code_applied'))
|
|
94
94
|
end
|
|
95
95
|
|
|
96
96
|
it "can enter a promotion code with both upper and lower case letters" do
|
|
97
97
|
fill_in "order_coupon_code", with: "ONETwO"
|
|
98
98
|
click_button "Update"
|
|
99
|
-
expect(page).to have_content(
|
|
99
|
+
expect(page).to have_content(I18n.t('spree.coupon_code_applied'))
|
|
100
100
|
end
|
|
101
101
|
|
|
102
102
|
it "informs the user about a coupon code which has exceeded its usage" do
|
|
@@ -104,7 +104,7 @@ describe "Coupon code promotions", type: :feature, js: true do
|
|
|
104
104
|
|
|
105
105
|
fill_in "order_coupon_code", with: "onetwo"
|
|
106
106
|
click_button "Update"
|
|
107
|
-
expect(page).to have_content(
|
|
107
|
+
expect(page).to have_content(I18n.t('spree.coupon_code_max_usage'))
|
|
108
108
|
end
|
|
109
109
|
|
|
110
110
|
context "informs the user if the coupon code is not eligible" do
|
|
@@ -120,7 +120,7 @@ describe "Coupon code promotions", type: :feature, js: true do
|
|
|
120
120
|
|
|
121
121
|
fill_in "order_coupon_code", with: "onetwo"
|
|
122
122
|
click_button "Update"
|
|
123
|
-
expect(page).to have_content(
|
|
123
|
+
expect(page).to have_content(I18n.t(:item_total_less_than_or_equal, scope: [:spree, :eligibility_errors, :messages], amount: "$100.00"))
|
|
124
124
|
end
|
|
125
125
|
end
|
|
126
126
|
|
|
@@ -130,7 +130,7 @@ describe "Coupon code promotions", type: :feature, js: true do
|
|
|
130
130
|
promotion.save!
|
|
131
131
|
fill_in "order_coupon_code", with: "onetwo"
|
|
132
132
|
click_button "Update"
|
|
133
|
-
expect(page).to have_content(
|
|
133
|
+
expect(page).to have_content(I18n.t('spree.coupon_code_expired'))
|
|
134
134
|
end
|
|
135
135
|
|
|
136
136
|
context "calculates the correct amount of money saved with flat percent promotions" do
|
|
@@ -174,13 +174,12 @@ describe "Coupon code promotions", type: :feature, js: true do
|
|
|
174
174
|
calculator = Spree::Calculator::FlatPercentItemTotal.new
|
|
175
175
|
calculator.preferred_flat_percent = 100
|
|
176
176
|
|
|
177
|
-
|
|
178
|
-
action.calculator = calculator
|
|
179
|
-
action.promotion = promotion
|
|
180
|
-
action.save
|
|
177
|
+
promotion.promotion_actions.first.discard
|
|
181
178
|
|
|
182
|
-
|
|
183
|
-
|
|
179
|
+
Spree::Promotion::Actions::CreateAdjustment.create!(
|
|
180
|
+
calculator: calculator,
|
|
181
|
+
promotion: promotion
|
|
182
|
+
)
|
|
184
183
|
|
|
185
184
|
create(:product, name: "Spree Mug", price: 10)
|
|
186
185
|
end
|