spree_frontend 3.0.1 → 3.0.2
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 +4 -4
- data/app/controllers/spree/checkout_controller.rb +9 -2
- data/app/controllers/spree/products_controller.rb +11 -0
- data/app/views/spree/products/show.html.erb +1 -1
- data/app/views/spree/shared/_google_analytics.js.erb +6 -1
- data/app/views/spree/shared/_order_details.html.erb +2 -2
- data/app/views/spree/shared/_taxonomies.html.erb +1 -1
- data/spec/controllers/spree/checkout_controller_spec.rb +5 -5
- data/spec/controllers/spree/checkout_controller_with_views_spec.rb +1 -1
- data/spec/controllers/spree/orders_controller_spec.rb +4 -4
- data/spec/controllers/spree/products_controller_spec.rb +31 -0
- data/spec/features/cart_spec.rb +3 -1
- data/spec/features/checkout_spec.rb +7 -8
- data/spec/features/checkout_unshippable_spec.rb +1 -1
- data/spec/spec_helper.rb +7 -0
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56c38cf8ac7763562f329b9adc3fc02a6447bfc7
|
4
|
+
data.tar.gz: bb96d44f57de9e6aa5f5332a8890eb7c1c9c19cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75d2017697863f14073f5f1a355caa6045eb96658191470e166772c9fb759eaf58606d9eb5c3280ec44bd5cb6be07dc81794a03170bc4955154dc7f84bea159e
|
7
|
+
data.tar.gz: 9fdea3dfa42e6715cbb26ad22c3260f0651470ca3eeaeac8a9c2f5625a46188c0df5d4e1d48064a8c11b9ed88da9978a015b5df187cf28a918fd12043af761de
|
@@ -5,8 +5,8 @@ module Spree
|
|
5
5
|
# is waranted.
|
6
6
|
class CheckoutController < Spree::StoreController
|
7
7
|
before_action :load_order_with_lock
|
8
|
-
|
9
|
-
|
8
|
+
before_action :ensure_valid_state_lock_version, only: [:update]
|
9
|
+
before_action :set_state_if_present
|
10
10
|
|
11
11
|
before_action :ensure_order_not_completed
|
12
12
|
before_action :ensure_checkout_allowed
|
@@ -154,6 +154,13 @@ module Spree
|
|
154
154
|
@differentiator.missing.each do |variant, quantity|
|
155
155
|
@order.contents.remove(variant, quantity)
|
156
156
|
end
|
157
|
+
|
158
|
+
# @order.contents.remove did transitively call reload in the past.
|
159
|
+
# Hiding the fact that the machine advanced already to "payment" state.
|
160
|
+
#
|
161
|
+
# As an intermediary step to optimize reloads out of high volume code path
|
162
|
+
# the reload was lifted here and will be removed by later passes.
|
163
|
+
@order.reload
|
157
164
|
end
|
158
165
|
|
159
166
|
if try_spree_current_user && try_spree_current_user.respond_to?(:payment_sources)
|
@@ -18,9 +18,11 @@ module Spree
|
|
18
18
|
@variants = @product.variants_including_master.active(current_currency).includes([:option_values, :images])
|
19
19
|
@product_properties = @product.product_properties.includes(:property)
|
20
20
|
@taxon = Spree::Taxon.find(params[:taxon_id]) if params[:taxon_id]
|
21
|
+
redirect_if_legacy_path
|
21
22
|
end
|
22
23
|
|
23
24
|
private
|
25
|
+
|
24
26
|
def accurate_title
|
25
27
|
if @product
|
26
28
|
@product.meta_title.blank? ? @product.name : @product.meta_title
|
@@ -41,5 +43,14 @@ module Spree
|
|
41
43
|
def load_taxon
|
42
44
|
@taxon = Spree::Taxon.find(params[:taxon]) if params[:taxon].present?
|
43
45
|
end
|
46
|
+
|
47
|
+
def redirect_if_legacy_path
|
48
|
+
# If an old id or a numeric id was used to find the record,
|
49
|
+
# we should do a 301 redirect that uses the current friendly id.
|
50
|
+
if params[:id] != @product.friendly_id
|
51
|
+
params.merge!(id: @product.friendly_id)
|
52
|
+
return redirect_to url_for(params), status: :moved_permanently
|
53
|
+
end
|
54
|
+
end
|
44
55
|
end
|
45
56
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<% @body_id = 'product-details' %>
|
2
2
|
|
3
|
-
<% cache [I18n.locale, current_currency, @product] do %>
|
3
|
+
<% cache [I18n.locale, current_currency, @product, @product.possible_promotions] do %>
|
4
4
|
<div data-hook="product_show" itemscope itemtype="https://schema.org/Product">
|
5
5
|
<div class="col-md-4" data-hook="product_left_part">
|
6
6
|
<div data-hook="product_left_part_wrap">
|
@@ -5,7 +5,12 @@
|
|
5
5
|
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
6
6
|
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
7
7
|
|
8
|
-
|
8
|
+
<% if user_analytics_id = try_spree_current_user.try(:analytics_id) %>
|
9
|
+
ga('create', { 'trackingId': '<%= tracker.analytics_id %>', 'cookieDomain': 'auto', 'userId': '<%= user_analytics_id %>' });
|
10
|
+
<% else %>
|
11
|
+
ga('create', '<%= tracker.analytics_id %>', 'auto');
|
12
|
+
<% end %>
|
13
|
+
|
9
14
|
ga('require', 'displayfeatures');
|
10
15
|
<%= yield :google_analytics %>
|
11
16
|
ga('send', 'pageview');
|
@@ -92,9 +92,9 @@
|
|
92
92
|
</tfoot>
|
93
93
|
|
94
94
|
<% if order.line_item_adjustments.exists? %>
|
95
|
-
<% if order.
|
95
|
+
<% if order.line_item_adjustments.promotion.eligible.exists? %>
|
96
96
|
<tfoot id="price-adjustments" data-hook="order_details_price_adjustments">
|
97
|
-
<% order.
|
97
|
+
<% order.line_item_adjustments.promotion.eligible.group_by(&:label).each do |label, adjustments| %>
|
98
98
|
<tr class="total">
|
99
99
|
<td colspan="4"><%= Spree.t(:promotion) %>: <strong><%= label %></strong></td>
|
100
100
|
<td class="total"><span><%= Spree::Money.new(adjustments.sum(&:amount), currency: order.currency) %></span></td>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
<nav id="taxonomies" class="sidebar-item" data-hook>
|
4
4
|
<% @taxonomies.each do |taxonomy| %>
|
5
|
-
<% cache [I18n.locale, taxonomy, max_level] do %>
|
5
|
+
<% cache [I18n.locale, taxonomy, max_level, @taxon] do %>
|
6
6
|
<h4 class='taxonomy-root'><%= Spree.t(:shop_by_taxonomy, :taxonomy => taxonomy.name) %></h4>
|
7
7
|
<%= taxons_tree(taxonomy.root, @taxon, max_level) %>
|
8
8
|
<% end %>
|
@@ -327,14 +327,14 @@ describe Spree::CheckoutController, :type => :controller do
|
|
327
327
|
|
328
328
|
context "when the order is invalid" do
|
329
329
|
before do
|
330
|
-
allow(order).to receive_messages
|
331
|
-
order.errors.add
|
332
|
-
order.errors.add
|
330
|
+
allow(order).to receive_messages(update_from_params: true, next: nil)
|
331
|
+
order.errors.add(:base, 'Base error')
|
332
|
+
order.errors.add(:adjustments, 'error')
|
333
333
|
end
|
334
334
|
|
335
335
|
it "due to the order having errors" do
|
336
336
|
spree_put :update, state: order.state, :order => {}
|
337
|
-
expect(flash[:error]).to
|
337
|
+
expect(flash[:error]).to eql("Base error\nAdjustments error")
|
338
338
|
expect(response).to redirect_to(spree.checkout_state_path('address'))
|
339
339
|
end
|
340
340
|
end
|
@@ -420,6 +420,6 @@ describe Spree::CheckoutController, :type => :controller do
|
|
420
420
|
|
421
421
|
expect {
|
422
422
|
spree_post :update, { :state => "payment" }
|
423
|
-
}.to change { order.line_items }
|
423
|
+
}.to change { order.reload.line_items.length }
|
424
424
|
end
|
425
425
|
end
|
@@ -22,7 +22,7 @@ describe Spree::CheckoutController, type: :controller do
|
|
22
22
|
before do
|
23
23
|
# Using a let block won't acknowledge the currency setting
|
24
24
|
# Therefore we just do it like this...
|
25
|
-
order = OrderWalkthrough.up_to(:
|
25
|
+
order = OrderWalkthrough.up_to(:delivery)
|
26
26
|
allow(controller).to receive_messages current_order: order
|
27
27
|
end
|
28
28
|
|
@@ -34,7 +34,7 @@ describe Spree::OrdersController, :type => :controller do
|
|
34
34
|
end
|
35
35
|
|
36
36
|
it "shows an error when population fails" do
|
37
|
-
request.env["HTTP_REFERER"] =
|
37
|
+
request.env["HTTP_REFERER"] = '/dummy_redirect'
|
38
38
|
allow_any_instance_of(Spree::LineItem).to(
|
39
39
|
receive(:valid?).and_return(false)
|
40
40
|
)
|
@@ -45,19 +45,19 @@ describe Spree::OrdersController, :type => :controller do
|
|
45
45
|
|
46
46
|
spree_post :populate, variant_id: variant.id, quantity: 5
|
47
47
|
|
48
|
-
expect(response).to redirect_to(
|
48
|
+
expect(response).to redirect_to('/dummy_redirect')
|
49
49
|
expect(flash[:error]).to eq("Order population failed")
|
50
50
|
end
|
51
51
|
|
52
52
|
it "shows an error when quantity is invalid" do
|
53
|
-
request.env["HTTP_REFERER"] =
|
53
|
+
request.env["HTTP_REFERER"] = '/dummy_redirect'
|
54
54
|
|
55
55
|
spree_post(
|
56
56
|
:populate,
|
57
57
|
variant_id: variant.id, quantity: -1
|
58
58
|
)
|
59
59
|
|
60
|
-
expect(response).to redirect_to(
|
60
|
+
expect(response).to redirect_to('/dummy_redirect')
|
61
61
|
expect(flash[:error]).to eq(
|
62
62
|
Spree.t(:please_enter_reasonable_quantity)
|
63
63
|
)
|
@@ -2,6 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Spree::ProductsController, :type => :controller do
|
4
4
|
let!(:product) { create(:product, :available_on => 1.year.from_now) }
|
5
|
+
let(:taxon) { create(:taxon) }
|
5
6
|
|
6
7
|
# Regression test for #1390
|
7
8
|
it "allows admins to view non-active products" do
|
@@ -33,4 +34,34 @@ describe Spree::ProductsController, :type => :controller do
|
|
33
34
|
expect { spree_get :show, :id => product.to_param }.not_to raise_error
|
34
35
|
end
|
35
36
|
|
37
|
+
context 'with history slugs present' do
|
38
|
+
let!(:product) { create(:product, available_on: 1.day.ago) }
|
39
|
+
|
40
|
+
it 'will redirect with a 301 with legacy url used' do
|
41
|
+
legacy_params = product.to_param
|
42
|
+
product.name = product.name + " Brand New"
|
43
|
+
product.slug = nil
|
44
|
+
product.save!
|
45
|
+
spree_get :show, id: legacy_params
|
46
|
+
expect(response.status).to eq(301)
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'will redirect with a 301 with id used' do
|
50
|
+
product.name = product.name + " Brand New"
|
51
|
+
product.slug = nil
|
52
|
+
product.save!
|
53
|
+
spree_get :show, id: product.id
|
54
|
+
expect(response.status).to eq(301)
|
55
|
+
end
|
56
|
+
|
57
|
+
it "will keep url params on legacy url redirect" do
|
58
|
+
legacy_params = product.to_param
|
59
|
+
product.name = product.name + " Brand New"
|
60
|
+
product.slug = nil
|
61
|
+
product.save!
|
62
|
+
spree_get :show, id: legacy_params, taxon_id: taxon.id
|
63
|
+
expect(response.status).to eq(301)
|
64
|
+
expect(response.header["Location"]).to include("taxon_id=#{taxon.id}")
|
65
|
+
end
|
66
|
+
end
|
36
67
|
end
|
data/spec/features/cart_spec.rb
CHANGED
@@ -34,8 +34,9 @@ describe "Cart", type: :feature, inaccessible: true do
|
|
34
34
|
visit spree.root_path
|
35
35
|
click_link "RoR Mug"
|
36
36
|
click_button "add-to-cart-button"
|
37
|
+
line_item = Spree::LineItem.first!
|
37
38
|
within("#line_items") do
|
38
|
-
click_link "
|
39
|
+
click_link "delete_line_item_#{line_item.id}"
|
39
40
|
end
|
40
41
|
|
41
42
|
expect(page).to_not have_content("Line items quantity must be an integer")
|
@@ -77,6 +78,7 @@ describe "Cart", type: :feature, inaccessible: true do
|
|
77
78
|
expect(page).to have_content(product.name)
|
78
79
|
end
|
79
80
|
end
|
81
|
+
|
80
82
|
it "should have a surrounding element with data-hook='cart_container'" do
|
81
83
|
visit spree.cart_path
|
82
84
|
expect(page).to have_selector("div[data-hook='cart_container']")
|
@@ -96,7 +96,7 @@ describe "Checkout", type: :feature, inaccessible: true, js: true do
|
|
96
96
|
# Regression test for #2694 and #4117
|
97
97
|
context "doesn't allow bad credit card numbers" do
|
98
98
|
before(:each) do
|
99
|
-
order = OrderWalkthrough.up_to(:
|
99
|
+
order = OrderWalkthrough.up_to(:payment)
|
100
100
|
allow(order).to receive_messages confirmation_required?: true
|
101
101
|
allow(order).to receive_messages(:available_payment_methods => [ create(:credit_card_payment_method) ])
|
102
102
|
|
@@ -109,7 +109,7 @@ describe "Checkout", type: :feature, inaccessible: true, js: true do
|
|
109
109
|
end
|
110
110
|
|
111
111
|
it "redirects to payment page", inaccessible: true, js: true do
|
112
|
-
visit spree.checkout_state_path(:
|
112
|
+
visit spree.checkout_state_path(:payment)
|
113
113
|
click_button "Save and Continue"
|
114
114
|
choose "Credit Card"
|
115
115
|
fill_in "Card Number", with: '123'
|
@@ -149,7 +149,7 @@ describe "Checkout", type: :feature, inaccessible: true, js: true do
|
|
149
149
|
let!(:user) { create(:user) }
|
150
150
|
|
151
151
|
let!(:order) do
|
152
|
-
order = OrderWalkthrough.up_to(:
|
152
|
+
order = OrderWalkthrough.up_to(:payment)
|
153
153
|
allow(order).to receive_messages confirmation_required?: true
|
154
154
|
|
155
155
|
order.reload
|
@@ -198,7 +198,7 @@ describe "Checkout", type: :feature, inaccessible: true, js: true do
|
|
198
198
|
|
199
199
|
before do
|
200
200
|
Capybara.ignore_hidden_elements = false
|
201
|
-
order = OrderWalkthrough.up_to(:
|
201
|
+
order = OrderWalkthrough.up_to(:payment)
|
202
202
|
allow(order).to receive_messages(available_payment_methods: [check_payment,credit_cart_payment])
|
203
203
|
order.user = create(:user)
|
204
204
|
order.update!
|
@@ -231,7 +231,7 @@ describe "Checkout", type: :feature, inaccessible: true, js: true do
|
|
231
231
|
end
|
232
232
|
|
233
233
|
before do
|
234
|
-
order = OrderWalkthrough.up_to(:
|
234
|
+
order = OrderWalkthrough.up_to(:payment)
|
235
235
|
allow(order).to receive_messages(available_payment_methods: [bogus])
|
236
236
|
|
237
237
|
allow_any_instance_of(Spree::CheckoutController).to receive_messages(current_order: order)
|
@@ -473,15 +473,14 @@ describe "Checkout", type: :feature, inaccessible: true, js: true do
|
|
473
473
|
|
474
474
|
context "when order is completed" do
|
475
475
|
let!(:user) { create(:user) }
|
476
|
-
let!(:order) { OrderWalkthrough.up_to(:
|
476
|
+
let!(:order) { OrderWalkthrough.up_to(:payment) }
|
477
477
|
|
478
478
|
before(:each) do
|
479
479
|
allow_any_instance_of(Spree::CheckoutController).to receive_messages(current_order: order)
|
480
480
|
allow_any_instance_of(Spree::CheckoutController).to receive_messages(try_spree_current_user: user)
|
481
481
|
allow_any_instance_of(Spree::OrdersController).to receive_messages(try_spree_current_user: user)
|
482
482
|
|
483
|
-
visit spree.checkout_state_path(:
|
484
|
-
click_button "Save and Continue"
|
483
|
+
visit spree.checkout_state_path(:payment)
|
485
484
|
click_button "Save and Continue"
|
486
485
|
end
|
487
486
|
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe "checkout with unshippable items", type: :feature, inaccessible: true do
|
4
4
|
let!(:stock_location) { create(:stock_location) }
|
5
|
-
let(:order) { OrderWalkthrough.up_to(:
|
5
|
+
let(:order) { OrderWalkthrough.up_to(:delivery) }
|
6
6
|
|
7
7
|
before do
|
8
8
|
OrderWalkthrough.add_line_item!(order)
|
data/spec/spec_helper.rb
CHANGED
@@ -74,6 +74,13 @@ RSpec.configure do |config|
|
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
|
+
# Ensure DB is clean, so that transaction isolated specs see
|
78
|
+
# pristine state.
|
79
|
+
config.before(:suite) do
|
80
|
+
DatabaseCleaner.strategy = :truncation
|
81
|
+
DatabaseCleaner.clean
|
82
|
+
end
|
83
|
+
|
77
84
|
config.before(:each) do
|
78
85
|
WebMock.disable!
|
79
86
|
if RSpec.current_example.metadata[:js]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_frontend
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Schofield
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: spree_api
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 3.0.
|
19
|
+
version: 3.0.2
|
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: 3.0.
|
26
|
+
version: 3.0.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: spree_core
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 3.0.
|
33
|
+
version: 3.0.2
|
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: 3.0.
|
40
|
+
version: 3.0.2
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bootstrap-sass
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|