solidus_frontend 2.10.2 → 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.
- checksums.yaml +4 -4
- data/app/assets/javascripts/spree/frontend/checkout/address.js +1 -1
- data/app/assets/javascripts/spree/frontend/checkout/coupon-code.js +1 -1
- data/app/controllers/spree/checkout_controller.rb +9 -5
- data/app/controllers/spree/orders_controller.rb +9 -9
- data/app/controllers/spree/products_controller.rb +1 -1
- data/app/views/spree/address/_form.html.erb +15 -8
- data/app/views/spree/address/_form_hidden.html.erb +6 -2
- data/app/views/spree/checkout/payment/_gateway.html.erb +1 -1
- data/app/views/spree/orders/_form.html.erb +1 -1
- data/app/views/spree/shared/_address.html.erb +1 -1
- data/app/views/spree/shared/_image.html.erb +3 -2
- data/solidus_frontend.gemspec +5 -5
- metadata +12 -55
- data/script/rails +0 -10
- data/spec/controllers/controller_helpers_spec.rb +0 -29
- data/spec/controllers/locale_controller_spec.rb +0 -57
- data/spec/controllers/spree/checkout_controller_spec.rb +0 -610
- data/spec/controllers/spree/checkout_controller_with_views_spec.rb +0 -37
- data/spec/controllers/spree/content_controller_spec.rb +0 -9
- data/spec/controllers/spree/current_order_tracking_spec.rb +0 -47
- data/spec/controllers/spree/home_controller_spec.rb +0 -29
- data/spec/controllers/spree/orders_controller_ability_spec.rb +0 -90
- data/spec/controllers/spree/orders_controller_spec.rb +0 -254
- data/spec/controllers/spree/orders_controller_transitions_spec.rb +0 -33
- data/spec/controllers/spree/products_controller_spec.rb +0 -38
- data/spec/controllers/spree/taxons_controller_spec.rb +0 -14
- data/spec/features/address_spec.rb +0 -78
- data/spec/features/automatic_promotion_adjustments_spec.rb +0 -49
- data/spec/features/caching/products_spec.rb +0 -48
- data/spec/features/caching/taxons_spec.rb +0 -21
- data/spec/features/cart_spec.rb +0 -85
- data/spec/features/checkout_confirm_insufficient_stock_spec.rb +0 -71
- data/spec/features/checkout_spec.rb +0 -758
- data/spec/features/checkout_unshippable_spec.rb +0 -37
- data/spec/features/coupon_code_spec.rb +0 -266
- data/spec/features/currency_spec.rb +0 -20
- data/spec/features/first_order_promotion_spec.rb +0 -59
- data/spec/features/free_shipping_promotions_spec.rb +0 -60
- data/spec/features/locale_spec.rb +0 -26
- data/spec/features/order_spec.rb +0 -73
- data/spec/features/products_spec.rb +0 -291
- data/spec/features/promotion_code_invalidation_spec.rb +0 -54
- data/spec/features/quantity_promotions_spec.rb +0 -130
- data/spec/features/taxons_spec.rb +0 -158
- data/spec/features/template_rendering_spec.rb +0 -20
- data/spec/fixtures/thinking-cat.jpg +0 -0
- data/spec/generators/solidus/views/override_generator_spec.rb +0 -50
- data/spec/helpers/base_helper_spec.rb +0 -13
- data/spec/helpers/order_helper_spec.rb +0 -14
- data/spec/helpers/taxon_filters_helper_spec.rb +0 -12
- data/spec/spec_helper.rb +0 -106
- data/spec/support/shared_contexts/checkout_setup.rb +0 -12
- data/spec/support/shared_contexts/custom_products.rb +0 -28
- data/spec/support/shared_contexts/locales.rb +0 -16
- data/spec/views/spree/checkout/_summary_spec.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8276f0fe5ca9fe4d4a2d8d327f7d9b5a747564c69a101bf95168f3462e8ce6b3
|
4
|
+
data.tar.gz: c51e8b73de741bc504e151d55a79e3715a37f4bc88a574d4a9c96b6ceae889c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dcc274c38109e0f2bae29bc3820f13d679705b5132657950983e2347bc3d4d5e8c23c7e74a92e0961f21d6a38323b0b367e561a92ee2a06642eebaf1f33ebfaa
|
7
|
+
data.tar.gz: 01366c21ebae0cebdb9e7fbfdd2f1778ea54159ff5f0c627e093c0fcd70cbd49d18d1e4a781c41212cee42e560f0684e74b74efc949a3860e12d21a8e96cf247
|
@@ -15,7 +15,7 @@ Spree.onCouponCodeApply = function(e) {
|
|
15
15
|
};
|
16
16
|
var req = Spree.ajax({
|
17
17
|
method: 'POST',
|
18
|
-
url: Spree.
|
18
|
+
url: Spree.pathFor('api/orders/' + Spree.current_order_id + '/coupon_codes'),
|
19
19
|
data: JSON.stringify(data),
|
20
20
|
contentType: "application/json"
|
21
21
|
});
|
@@ -8,8 +8,8 @@ module Spree
|
|
8
8
|
class CheckoutController < Spree::StoreController
|
9
9
|
before_action :load_order
|
10
10
|
around_action :lock_order
|
11
|
-
before_action :set_state_if_present
|
12
11
|
|
12
|
+
before_action :ensure_order_is_not_skipping_states
|
13
13
|
before_action :ensure_order_not_completed
|
14
14
|
before_action :ensure_checkout_allowed
|
15
15
|
before_action :ensure_sufficient_stock_lines
|
@@ -153,13 +153,18 @@ module Spree
|
|
153
153
|
# when trying to change it via params[:state]. It's not allowed to
|
154
154
|
# jump forward and skip states (unless #skip_state_validation? is
|
155
155
|
# truthy).
|
156
|
-
def
|
156
|
+
def ensure_order_is_not_skipping_states
|
157
157
|
if params[:state]
|
158
158
|
redirect_to checkout_state_path(@order.state) if @order.can_go_to_state?(params[:state]) && !skip_state_validation?
|
159
159
|
@order.state = params[:state]
|
160
160
|
end
|
161
161
|
end
|
162
162
|
|
163
|
+
def set_state_if_present
|
164
|
+
ensure_order_is_not_skipping_states
|
165
|
+
end
|
166
|
+
deprecate set_state_if_present: :prevent_order_from_skipping_states, deprecator: Spree::Deprecation
|
167
|
+
|
163
168
|
def ensure_checkout_allowed
|
164
169
|
unless @order.checkout_allowed?
|
165
170
|
redirect_to spree.cart_path
|
@@ -210,9 +215,8 @@ module Spree
|
|
210
215
|
@order.assign_default_user_addresses
|
211
216
|
# If the user has a default address, the previous method call takes care
|
212
217
|
# of setting that; but if he doesn't, we need to build an empty one here
|
213
|
-
|
214
|
-
@order.
|
215
|
-
@order.build_ship_address(default) if @order.checkout_steps.include?('delivery') && !@order.ship_address
|
218
|
+
@order.bill_address ||= Spree::Address.build_default
|
219
|
+
@order.ship_address ||= Spree::Address.build_default if @order.checkout_steps.include?('delivery')
|
216
220
|
end
|
217
221
|
|
218
222
|
def before_delivery
|
@@ -15,7 +15,7 @@ module Spree
|
|
15
15
|
|
16
16
|
def show
|
17
17
|
@order = Spree::Order.find_by!(number: params[:id])
|
18
|
-
authorize! :
|
18
|
+
authorize! :show, @order, cookies.signed[:guest_token]
|
19
19
|
end
|
20
20
|
|
21
21
|
def update
|
@@ -39,8 +39,8 @@ module Spree
|
|
39
39
|
|
40
40
|
# Shows the current incomplete order from the session
|
41
41
|
def edit
|
42
|
-
@order = current_order
|
43
|
-
authorize! :
|
42
|
+
@order = current_order(build_order_if_necessary: true)
|
43
|
+
authorize! :edit, @order, cookies.signed[:guest_token]
|
44
44
|
associate_user
|
45
45
|
if params[:id] && @order.number != params[:id]
|
46
46
|
flash[:error] = t('spree.cannot_edit_orders')
|
@@ -59,12 +59,12 @@ module Spree
|
|
59
59
|
# 2,147,483,647 is crazy. See issue https://github.com/spree/spree/issues/2695.
|
60
60
|
if !quantity.between?(1, 2_147_483_647)
|
61
61
|
@order.errors.add(:base, t('spree.please_enter_reasonable_quantity'))
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
62
|
+
else
|
63
|
+
begin
|
64
|
+
@line_item = @order.contents.add(variant, quantity)
|
65
|
+
rescue ActiveRecord::RecordInvalid => error
|
66
|
+
@order.errors.add(:base, error.record.errors.full_messages.join(", "))
|
67
|
+
end
|
68
68
|
end
|
69
69
|
|
70
70
|
respond_with(@order) do |format|
|
@@ -1,14 +1,21 @@
|
|
1
1
|
<% address_id = address_type.chars.first %>
|
2
2
|
<div class="inner" data-hook=<%="#{address_type}_inner" %>>
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
<% if Spree::Config.use_combined_first_and_last_name_in_address %>
|
4
|
+
<div class="field field-required" id="<%= "#{address_id}name" %>">
|
5
|
+
<%= form.label :name, t('spree.name') %>
|
6
|
+
<%= form.text_field :name, class: 'required', autocomplete: address_type + ' name', required: true, autofocus: true %>
|
7
|
+
</div>
|
8
|
+
<% else %>
|
9
|
+
<div class="field field-required" id="<%= "#{address_id}firstname" %>">
|
10
|
+
<%= form.label :firstname, t('spree.first_name') %>
|
11
|
+
<%= form.text_field :firstname, class: 'required', autocomplete: address_type + ' given-name', required: true, autofocus: true %>
|
12
|
+
</div>
|
7
13
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
14
|
+
<div class="field" id="<%= "#{address_id}lastname" %>">
|
15
|
+
<%= form.label :lastname, t('spree.last_name') %>
|
16
|
+
<%= form.text_field :lastname, autocomplete: address_type + ' family-name' %>
|
17
|
+
</div>
|
18
|
+
<% end %>
|
12
19
|
|
13
20
|
<% if Spree::Config[:company] %>
|
14
21
|
<div class="field" id=<%="#{address_id}company" %>>
|
@@ -1,5 +1,9 @@
|
|
1
|
-
|
2
|
-
<%= form.hidden_field :
|
1
|
+
<% if Spree::Config.use_combined_first_and_last_name_in_address %>
|
2
|
+
<%= form.hidden_field :name %>
|
3
|
+
<% else %>
|
4
|
+
<%= form.hidden_field :firstname %>
|
5
|
+
<%= form.hidden_field :lastname %>
|
6
|
+
<% end %>
|
3
7
|
<%= form.hidden_field :company %>
|
4
8
|
<%= form.hidden_field :address1 %>
|
5
9
|
<%= form.hidden_field :address2 %>
|
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
<div class="field field-required card_name" data-hook="card_name">
|
5
5
|
<%= label_tag "name_on_card_#{payment_method.id}", t('spree.name_on_card') %>
|
6
|
-
<%= text_field_tag "#{param_prefix}[name]",
|
6
|
+
<%= text_field_tag "#{param_prefix}[name]", @order.billing_name, { id: "name_on_card_#{payment_method.id}", autocomplete: "cc-name", class: 'cardName' } %>
|
7
7
|
</div>
|
8
8
|
|
9
9
|
<div class="field field-required card_number" data-hook="card_number">
|
@@ -13,7 +13,7 @@
|
|
13
13
|
<tbody id="line_items" data-hook>
|
14
14
|
<%= render partial: 'spree/orders/line_item', collection: order.line_items, locals: { order_form: order_form } %>
|
15
15
|
</tbody>
|
16
|
-
<% if order.
|
16
|
+
<% if order.all_adjustments.nonzero.any? || order.shipments.any? %>
|
17
17
|
<tr class="cart-subtotal">
|
18
18
|
<td colspan="4" align='right'><h5><%= t('spree.cart_subtotal', count: order.line_items.sum(:quantity)) %></h5></td>
|
19
19
|
<td colspan><h5><%= order.display_item_total %></h5></td>
|
@@ -1,11 +1,12 @@
|
|
1
1
|
<% size ||= :mini %>
|
2
2
|
<% itemprop ||= nil %>
|
3
|
+
<% options ||= {} %>
|
3
4
|
|
4
5
|
<% if image_url = image.try(:url, size) %>
|
5
6
|
<% if image_alt = image.try(:alt) %>
|
6
|
-
<%= image_tag image_url, alt: image_alt, itemprop: itemprop %>
|
7
|
+
<%= image_tag image_url, { alt: image_alt, itemprop: itemprop }.merge(options) %>
|
7
8
|
<% else %>
|
8
|
-
<%= image_tag image_url, itemprop: itemprop %>
|
9
|
+
<%= image_tag image_url, { itemprop: itemprop }.merge(options) %>
|
9
10
|
<% end %>
|
10
11
|
<% else %>
|
11
12
|
<span class="image-placeholder <%= size %>"></span>
|
data/solidus_frontend.gemspec
CHANGED
@@ -11,14 +11,14 @@ Gem::Specification.new do |s|
|
|
11
11
|
|
12
12
|
s.author = 'Solidus Team'
|
13
13
|
s.email = 'contact@solidus.io'
|
14
|
-
s.homepage = 'http://solidus.io
|
14
|
+
s.homepage = 'http://solidus.io'
|
15
15
|
s.license = 'BSD-3-Clause'
|
16
16
|
|
17
|
-
s.files
|
18
|
-
|
19
|
-
|
17
|
+
s.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(spec|script)/})
|
19
|
+
end
|
20
20
|
|
21
|
-
s.required_ruby_version = '>= 2.
|
21
|
+
s.required_ruby_version = '>= 2.5.0'
|
22
22
|
s.required_rubygems_version = '>= 1.8.23'
|
23
23
|
|
24
24
|
s.add_dependency 'solidus_api', s.version
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solidus_frontend
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Solidus Team
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: solidus_api
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.
|
19
|
+
version: 2.11.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.
|
26
|
+
version: 2.11.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: solidus_core
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 2.
|
33
|
+
version: 2.11.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 2.
|
40
|
+
version: 2.11.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: canonical-rails
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -284,54 +284,12 @@ files:
|
|
284
284
|
- lib/spree_frontend.rb
|
285
285
|
- lib/tasks/rake_util.rb
|
286
286
|
- lib/tasks/taxon.rake
|
287
|
-
- script/rails
|
288
287
|
- solidus_frontend.gemspec
|
289
|
-
|
290
|
-
- spec/controllers/locale_controller_spec.rb
|
291
|
-
- spec/controllers/spree/checkout_controller_spec.rb
|
292
|
-
- spec/controllers/spree/checkout_controller_with_views_spec.rb
|
293
|
-
- spec/controllers/spree/content_controller_spec.rb
|
294
|
-
- spec/controllers/spree/current_order_tracking_spec.rb
|
295
|
-
- spec/controllers/spree/home_controller_spec.rb
|
296
|
-
- spec/controllers/spree/orders_controller_ability_spec.rb
|
297
|
-
- spec/controllers/spree/orders_controller_spec.rb
|
298
|
-
- spec/controllers/spree/orders_controller_transitions_spec.rb
|
299
|
-
- spec/controllers/spree/products_controller_spec.rb
|
300
|
-
- spec/controllers/spree/taxons_controller_spec.rb
|
301
|
-
- spec/features/address_spec.rb
|
302
|
-
- spec/features/automatic_promotion_adjustments_spec.rb
|
303
|
-
- spec/features/caching/products_spec.rb
|
304
|
-
- spec/features/caching/taxons_spec.rb
|
305
|
-
- spec/features/cart_spec.rb
|
306
|
-
- spec/features/checkout_confirm_insufficient_stock_spec.rb
|
307
|
-
- spec/features/checkout_spec.rb
|
308
|
-
- spec/features/checkout_unshippable_spec.rb
|
309
|
-
- spec/features/coupon_code_spec.rb
|
310
|
-
- spec/features/currency_spec.rb
|
311
|
-
- spec/features/first_order_promotion_spec.rb
|
312
|
-
- spec/features/free_shipping_promotions_spec.rb
|
313
|
-
- spec/features/locale_spec.rb
|
314
|
-
- spec/features/order_spec.rb
|
315
|
-
- spec/features/products_spec.rb
|
316
|
-
- spec/features/promotion_code_invalidation_spec.rb
|
317
|
-
- spec/features/quantity_promotions_spec.rb
|
318
|
-
- spec/features/taxons_spec.rb
|
319
|
-
- spec/features/template_rendering_spec.rb
|
320
|
-
- spec/fixtures/thinking-cat.jpg
|
321
|
-
- spec/generators/solidus/views/override_generator_spec.rb
|
322
|
-
- spec/helpers/base_helper_spec.rb
|
323
|
-
- spec/helpers/order_helper_spec.rb
|
324
|
-
- spec/helpers/taxon_filters_helper_spec.rb
|
325
|
-
- spec/spec_helper.rb
|
326
|
-
- spec/support/shared_contexts/checkout_setup.rb
|
327
|
-
- spec/support/shared_contexts/custom_products.rb
|
328
|
-
- spec/support/shared_contexts/locales.rb
|
329
|
-
- spec/views/spree/checkout/_summary_spec.rb
|
330
|
-
homepage: http://solidus.io/
|
288
|
+
homepage: http://solidus.io
|
331
289
|
licenses:
|
332
290
|
- BSD-3-Clause
|
333
291
|
metadata: {}
|
334
|
-
post_install_message:
|
292
|
+
post_install_message:
|
335
293
|
rdoc_options: []
|
336
294
|
require_paths:
|
337
295
|
- lib
|
@@ -339,16 +297,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
339
297
|
requirements:
|
340
298
|
- - ">="
|
341
299
|
- !ruby/object:Gem::Version
|
342
|
-
version: 2.
|
300
|
+
version: 2.5.0
|
343
301
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
344
302
|
requirements:
|
345
303
|
- - ">="
|
346
304
|
- !ruby/object:Gem::Version
|
347
305
|
version: 1.8.23
|
348
|
-
requirements:
|
349
|
-
- none
|
306
|
+
requirements: []
|
350
307
|
rubygems_version: 3.0.3
|
351
|
-
signing_key:
|
308
|
+
signing_key:
|
352
309
|
specification_version: 4
|
353
310
|
summary: Cart and storefront for the Solidus e-commerce project.
|
354
311
|
test_files: []
|
data/script/rails
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
5
|
-
|
6
|
-
ENGINE_ROOT = File.expand_path('..', __dir__)
|
7
|
-
ENGINE_PATH = File.expand_path('../lib/spree/frontend/engine', __dir__)
|
8
|
-
|
9
|
-
require 'rails/all'
|
10
|
-
require 'rails/engine/commands'
|
@@ -1,29 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
# In this file, we want to test that the controller helpers function correctly
|
6
|
-
# So we need to use one of the controllers inside Spree.
|
7
|
-
# ProductsController is good.
|
8
|
-
describe Spree::ProductsController, type: :controller do
|
9
|
-
before do
|
10
|
-
I18n.enforce_available_locales = false
|
11
|
-
stub_spree_preferences(Spree::Frontend::Config, locale: :de)
|
12
|
-
I18n.backend.store_translations(:de, spree: {
|
13
|
-
i18n: { this_file_language: "Deutsch (DE)" }
|
14
|
-
})
|
15
|
-
end
|
16
|
-
|
17
|
-
after do
|
18
|
-
I18n.reload!
|
19
|
-
I18n.locale = :en
|
20
|
-
I18n.enforce_available_locales = true
|
21
|
-
end
|
22
|
-
|
23
|
-
# Regression test for https://github.com/spree/spree/issues/1184
|
24
|
-
it "sets the default locale based off Spree::Frontend::Config[:locale]" do
|
25
|
-
expect(I18n.locale).to eq(:en)
|
26
|
-
get :index
|
27
|
-
expect(I18n.locale).to eq(:de)
|
28
|
-
end
|
29
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
RSpec.describe Spree::LocaleController, type: :controller do
|
6
|
-
include_context "fr locale"
|
7
|
-
|
8
|
-
context 'switch_to_locale specified' do
|
9
|
-
context "available locale" do
|
10
|
-
it 'sets locale and redirects' do
|
11
|
-
get :set, params: { switch_to_locale: 'fr' }
|
12
|
-
expect(I18n.locale).to eq :fr
|
13
|
-
expect(response).to redirect_to('/')
|
14
|
-
expect(session[:locale]).to eq('fr')
|
15
|
-
expect(flash[:notice]).to eq(I18n.t("spree.locale_changed"))
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
context "unavailable locale" do
|
20
|
-
it 'does not change locale and redirects' do
|
21
|
-
get :set, params: { switch_to_locale: 'klingon' }
|
22
|
-
expect(I18n.locale).to eq :en
|
23
|
-
expect(response).to redirect_to('/')
|
24
|
-
expect(flash[:error]).to eq(I18n.t("spree.locale_not_changed"))
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
context 'locale specified' do
|
30
|
-
context "available locale" do
|
31
|
-
it 'sets locale and redirects' do
|
32
|
-
get :set, params: { locale: 'fr' }
|
33
|
-
expect(I18n.locale).to eq :fr
|
34
|
-
expect(response).to redirect_to('/')
|
35
|
-
expect(flash[:notice]).to eq(I18n.t("spree.locale_changed"))
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
context "unavailable locale" do
|
40
|
-
it 'does not change locale and redirects' do
|
41
|
-
get :set, params: { locale: 'klingon' }
|
42
|
-
expect(I18n.locale).to eq :en
|
43
|
-
expect(response).to redirect_to('/')
|
44
|
-
expect(flash[:error]).to eq(I18n.t("spree.locale_not_changed"))
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
context 'both locale and switch_to_locale specified' do
|
50
|
-
it 'uses switch_to_locale value' do
|
51
|
-
get :set, params: { locale: 'en', switch_to_locale: 'fr' }
|
52
|
-
expect(I18n.locale).to eq :fr
|
53
|
-
expect(response).to redirect_to('/')
|
54
|
-
expect(flash[:notice]).to eq(I18n.t("spree.locale_changed"))
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|