solidus_frontend 2.1.1 → 2.2.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 +1 -0
- data/README.md +30 -0
- data/app/assets/config/solidus_frontend_manifest.js +6 -0
- data/app/assets/javascripts/spree/frontend/checkout/coupon-code.js.coffee +2 -2
- data/app/assets/javascripts/spree/frontend/checkout.js.coffee +8 -0
- data/app/assets/stylesheets/spree/frontend/screen.css.scss +18 -7
- data/app/controllers/spree/checkout_controller.rb +63 -21
- data/app/controllers/spree/orders_controller.rb +2 -2
- data/app/controllers/spree/products_controller.rb +2 -2
- data/app/controllers/spree/store_controller.rb +1 -1
- data/app/controllers/spree/taxons_controller.rb +1 -1
- data/app/models/spree/frontend_configuration.rb +3 -0
- data/app/views/spree/address/_form.html.erb +2 -2
- data/app/views/spree/checkout/_address.html.erb +4 -4
- data/app/views/spree/checkout/_confirm.html.erb +15 -2
- data/app/views/spree/checkout/_delivery.html.erb +2 -2
- data/app/views/spree/checkout/_payment.html.erb +14 -14
- data/app/views/spree/checkout/_terms_and_conditions.en.html.erb +1 -0
- data/app/views/spree/checkout/edit.html.erb +4 -4
- data/app/views/spree/checkout/existing_payment/_gateway.html.erb +9 -0
- data/app/views/spree/checkout/payment/_gateway.html.erb +8 -8
- data/app/views/spree/home/index.html.erb +2 -2
- data/app/views/spree/layouts/spree_application.html.erb +4 -4
- data/app/views/spree/orders/_adjustment_row.html.erb +1 -1
- data/app/views/spree/orders/_adjustments.html.erb +3 -3
- data/app/views/spree/orders/_form.html.erb +7 -6
- data/app/views/spree/orders/_line_item.html.erb +2 -2
- data/app/views/spree/orders/edit.html.erb +9 -9
- data/app/views/spree/orders/show.html.erb +4 -4
- data/app/views/spree/products/_cart_form.html.erb +3 -3
- data/app/views/spree/products/_properties.html.erb +1 -1
- data/app/views/spree/products/index.html.erb +4 -4
- data/app/views/spree/products/show.html.erb +6 -6
- data/app/views/spree/shared/_filters.html.erb +2 -2
- data/app/views/spree/shared/_head.html.erb +1 -1
- data/app/views/spree/shared/_header.html.erb +2 -2
- data/app/views/spree/shared/_main_nav_bar.html.erb +2 -2
- data/app/views/spree/shared/_nav_bar.html.erb +1 -1
- data/app/views/spree/shared/_order_details.html.erb +7 -7
- data/app/views/spree/shared/_search.html.erb +4 -4
- data/app/views/spree/shared/_taxonomies.html.erb +1 -1
- data/config/initializers/assets.rb +1 -8
- data/config/routes.rb +1 -1
- data/lib/generators/solidus/views/override_generator.rb +46 -0
- data/spec/controllers/spree/checkout_controller_spec.rb +5 -52
- data/spec/controllers/spree/orders_controller_spec.rb +3 -3
- data/spec/controllers/spree/orders_controller_transitions_spec.rb +1 -1
- data/spec/features/caching/products_spec.rb +0 -1
- data/spec/features/caching/taxons_spec.rb +0 -1
- data/spec/features/checkout_spec.rb +4 -3
- data/spec/generators/solidus/views/override_generator_spec.rb +47 -0
- metadata +12 -7
@@ -1,12 +1,12 @@
|
|
1
1
|
<tbody id="cart_adjustments" data-hook>
|
2
2
|
<% if @order.line_item_adjustments.exists? %>
|
3
3
|
<% @order.line_item_adjustments.promotion.eligible.group_by(&:label).each do |label, adjustments| %>
|
4
|
-
<%= render "spree/orders/adjustment_row", :
|
4
|
+
<%= render "spree/orders/adjustment_row", label: label, adjustments: adjustments, type: Spree.t(:promotion) %>
|
5
5
|
<% end %>
|
6
6
|
<% end %>
|
7
7
|
|
8
8
|
<% @order.all_adjustments.tax.eligible.group_by(&:label).each do |label, adjustments| %>
|
9
|
-
<%= render "spree/orders/adjustment_row", :
|
9
|
+
<%= render "spree/orders/adjustment_row", label: label, adjustments: adjustments, type: Spree.t(:tax) %>
|
10
10
|
<% end %>
|
11
11
|
|
12
12
|
<% @order.shipments.each do |shipment| %>
|
@@ -19,6 +19,6 @@
|
|
19
19
|
<% end %>
|
20
20
|
|
21
21
|
<% @order.adjustments.eligible.group_by(&:label).each do |label, adjustments| %>
|
22
|
-
<%= render "spree/orders/adjustment_row", :
|
22
|
+
<%= render "spree/orders/adjustment_row", label: label, adjustments: adjustments, type: Spree.t(:adjustment) %>
|
23
23
|
<% end %>
|
24
24
|
</tbody>
|
@@ -1,4 +1,5 @@
|
|
1
|
-
|
1
|
+
<% order = order_form.object %>
|
2
|
+
<%= render 'spree/shared/error_messages', target: order %>
|
2
3
|
<table id="cart-detail" data-hook>
|
3
4
|
<thead>
|
4
5
|
<tr data-hook="cart_items_headers">
|
@@ -10,19 +11,19 @@
|
|
10
11
|
</tr>
|
11
12
|
</thead>
|
12
13
|
<tbody id="line_items" data-hook>
|
13
|
-
<%= render partial: 'spree/orders/line_item', collection:
|
14
|
+
<%= render partial: 'spree/orders/line_item', collection: order.line_items, locals: { order_form: order_form } %>
|
14
15
|
</tbody>
|
15
|
-
<% if
|
16
|
+
<% if order.adjustments.nonzero.exists? || order.line_item_adjustments.nonzero.exists? || order.shipment_adjustments.nonzero.exists? || order.shipments.any? %>
|
16
17
|
<tr class="cart-subtotal">
|
17
|
-
<td colspan="4" align='right'><h5><%= Spree.t(:cart_subtotal, :
|
18
|
-
<td colspan><h5><%=
|
18
|
+
<td colspan="4" align='right'><h5><%= Spree.t(:cart_subtotal, count: order.line_items.sum(:quantity)) %></h5></th>
|
19
|
+
<td colspan><h5><%= order.display_item_total %></h5></td>
|
19
20
|
<td></td>
|
20
21
|
</tr>
|
21
22
|
<%= render "spree/orders/adjustments" %>
|
22
23
|
<% end %>
|
23
24
|
<tr class="cart-total">
|
24
25
|
<td colspan="4" align='right'><h5><%= Spree.t(:total) %></h5></th>
|
25
|
-
<td colspan><h5><%=
|
26
|
+
<td colspan><h5><%= order.display_total %></h5></td>
|
26
27
|
<td></td>
|
27
28
|
</tr>
|
28
29
|
</table>
|
@@ -24,13 +24,13 @@
|
|
24
24
|
<%= line_item.single_money.to_html %>
|
25
25
|
</td>
|
26
26
|
<td class="cart-item-quantity" data-hook="cart_item_quantity">
|
27
|
-
<%= item_form.number_field :quantity, :
|
27
|
+
<%= item_form.number_field :quantity, min: 0, class: "line_item_quantity", size: 5 %>
|
28
28
|
</td>
|
29
29
|
<td class="cart-item-total" data-hook="cart_item_total">
|
30
30
|
<%= line_item.display_amount.to_html unless line_item.quantity.nil? %>
|
31
31
|
</td>
|
32
32
|
<td class="cart-item-delete" data-hook="cart_item_delete">
|
33
|
-
<%= link_to image_tag('icons/delete.png'), '#', :
|
33
|
+
<%= link_to image_tag('icons/delete.png'), '#', class: 'delete', id: "delete_#{dom_id(line_item)}" %>
|
34
34
|
</td>
|
35
35
|
</tr>
|
36
36
|
<% end -%>
|
@@ -6,25 +6,25 @@
|
|
6
6
|
|
7
7
|
<div data-hook="empty_cart">
|
8
8
|
<p><%= Spree.t(:your_cart_is_empty) %></p>
|
9
|
-
<p><%= link_to Spree.t(:continue_shopping), products_path, :
|
9
|
+
<p><%= link_to Spree.t(:continue_shopping), products_path, class: 'button continue' %></p>
|
10
10
|
</div>
|
11
11
|
|
12
12
|
<% else %>
|
13
13
|
|
14
14
|
<div data-hook="outside_cart_form">
|
15
|
-
<%= form_for @order, :
|
15
|
+
<%= form_for @order, url: update_cart_path, html: {id: 'update-cart'} do |order_form| %>
|
16
16
|
<div data-hook="inside_cart_form">
|
17
17
|
|
18
18
|
<div data-hook="cart_items">
|
19
|
-
<%= render
|
19
|
+
<%= render 'form', order_form: order_form %>
|
20
20
|
</div>
|
21
21
|
|
22
22
|
<div class="links columns sixteen alpha omega" data-hook="cart_buttons">
|
23
|
-
<%= order_form.text_field :coupon_code, :
|
24
|
-
<%= button_tag :
|
23
|
+
<%= order_form.text_field :coupon_code, size: 10, placeholder: Spree.t(:coupon_code) %>
|
24
|
+
<%= button_tag class: 'primary', id: 'update-button' do %>
|
25
25
|
<%= Spree.t(:update) %>
|
26
26
|
<% end %>
|
27
|
-
<%= button_tag :
|
27
|
+
<%= button_tag class: 'button checkout primary', id: 'checkout-link', name: 'checkout' do %>
|
28
28
|
<%= Spree.t(:checkout) %>
|
29
29
|
<% end %>
|
30
30
|
</div>
|
@@ -34,11 +34,11 @@
|
|
34
34
|
</div>
|
35
35
|
|
36
36
|
<div id="empty-cart" data-hook>
|
37
|
-
<%= form_tag empty_cart_path, :
|
37
|
+
<%= form_tag empty_cart_path, method: :put do %>
|
38
38
|
<p id="clear_cart_link" data-hook>
|
39
|
-
<%= submit_tag Spree.t(:empty_cart), :
|
39
|
+
<%= submit_tag Spree.t(:empty_cart), class: 'button gray' %>
|
40
40
|
<%= Spree.t(:or) %>
|
41
|
-
<%= link_to Spree.t(:continue_shopping), products_path, :
|
41
|
+
<%= link_to Spree.t(:continue_shopping), products_path, class: 'continue button gray' %>
|
42
42
|
</p>
|
43
43
|
<% end %>
|
44
44
|
</div>
|
@@ -1,20 +1,20 @@
|
|
1
1
|
<fieldset id="order_summary" data-hook>
|
2
|
-
<legend><%= Spree.t(:order_number, :
|
2
|
+
<legend><%= Spree.t(:order_number, number: @order.number) %></legend>
|
3
3
|
<h1><%= accurate_title %></h1>
|
4
4
|
<% if order_just_completed?(@order) %>
|
5
5
|
<strong><%= Spree.t(:thank_you_for_your_order) %></strong>
|
6
6
|
<% end %>
|
7
7
|
|
8
8
|
<div id="order" data-hook>
|
9
|
-
<%= render :
|
9
|
+
<%= render partial: 'spree/shared/order_details', locals: { order: @order } %>
|
10
10
|
|
11
11
|
<br class="clear" />
|
12
12
|
|
13
13
|
<p data-hook="links">
|
14
|
-
<%= link_to Spree.t(:back_to_store), spree.root_path, :
|
14
|
+
<%= link_to Spree.t(:back_to_store), spree.root_path, class: "button" %>
|
15
15
|
<% unless order_just_completed?(@order) %>
|
16
16
|
<% if try_spree_current_user && respond_to?(:account_path) %>
|
17
|
-
<%= link_to Spree.t(:my_account), spree.account_path, :
|
17
|
+
<%= link_to Spree.t(:my_account), spree.account_path, class: "button" %>
|
18
18
|
<% end %>
|
19
19
|
<% end %>
|
20
20
|
</p>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%= form_for :order, :
|
1
|
+
<%= form_for :order, url: populate_orders_path do |f| %>
|
2
2
|
<div id="inside-product-cart-form" data-hook="inside_product_cart_form" itemprop="offers" itemscope itemtype="http://schema.org/Offer">
|
3
3
|
|
4
4
|
<% if @product.variants_and_option_values_for(current_pricing_options).any? %>
|
@@ -49,8 +49,8 @@
|
|
49
49
|
</div>
|
50
50
|
|
51
51
|
<div class="add-to-cart">
|
52
|
-
<%= number_field_tag :quantity, 1, :
|
53
|
-
<%= button_tag :
|
52
|
+
<%= number_field_tag :quantity, 1, class: 'title', min: 1 %>
|
53
|
+
<%= button_tag class: 'large primary', id: 'add-to-cart-button', type: :submit do %>
|
54
54
|
<%= Spree.t(:add_to_cart) %>
|
55
55
|
<% end %>
|
56
56
|
</div>
|
@@ -3,7 +3,7 @@
|
|
3
3
|
<table id="product-properties" class="table-display" data-hook>
|
4
4
|
<tbody>
|
5
5
|
<% @product_properties.each do |product_property| %>
|
6
|
-
<% css_class = cycle('even', 'odd', :
|
6
|
+
<% css_class = cycle('even', 'odd', name: "properties") %>
|
7
7
|
<tr class="<%= css_class %>">
|
8
8
|
<td><strong><%= product_property.property.presentation %></strong></td>
|
9
9
|
<td><%= product_property.value %></td>
|
@@ -1,9 +1,9 @@
|
|
1
1
|
<% content_for :sidebar do %>
|
2
2
|
<div data-hook="homepage_sidebar_navigation">
|
3
3
|
<% if "spree/products" == params[:controller] && @taxon %>
|
4
|
-
<%= render :
|
4
|
+
<%= render partial: 'spree/shared/filters' %>
|
5
5
|
<% else %>
|
6
|
-
<%= render :
|
6
|
+
<%= render partial: 'spree/shared/taxonomies' %>
|
7
7
|
<% end %>
|
8
8
|
</div>
|
9
9
|
<% end %>
|
@@ -15,13 +15,13 @@
|
|
15
15
|
<% if @products.empty? %>
|
16
16
|
<h6 class="search-results-title"><%= Spree.t(:no_products_found) %></h6>
|
17
17
|
<% else %>
|
18
|
-
<%= render :
|
18
|
+
<%= render partial: 'spree/shared/products', locals: { products: @products, taxon: @taxon } %>
|
19
19
|
<% end %>
|
20
20
|
</div>
|
21
21
|
|
22
22
|
<% else %>
|
23
23
|
|
24
24
|
<div data-hook="homepage_products">
|
25
|
-
<%= render :
|
25
|
+
<%= render partial: 'spree/shared/products', locals: { products: @products, taxon: @taxon } %>
|
26
26
|
</div>
|
27
27
|
<% end %>
|
@@ -7,19 +7,19 @@
|
|
7
7
|
|
8
8
|
<div id="product-images" data-hook="product_images">
|
9
9
|
<div id="main-image" data-hook>
|
10
|
-
<%= render :
|
10
|
+
<%= render partial: 'image' %>
|
11
11
|
</div>
|
12
12
|
<div id="thumbnails" data-hook>
|
13
|
-
<%= render :
|
13
|
+
<%= render partial: 'thumbnails' %>
|
14
14
|
</div>
|
15
15
|
</div>
|
16
16
|
|
17
17
|
<div data-hook="product_properties">
|
18
|
-
<%= render :
|
18
|
+
<%= render partial: 'properties' %>
|
19
19
|
</div>
|
20
20
|
|
21
21
|
<div data-hook="promotions">
|
22
|
-
<%= render :
|
22
|
+
<%= render partial: 'promotions' %>
|
23
23
|
</div>
|
24
24
|
|
25
25
|
</div>
|
@@ -37,12 +37,12 @@
|
|
37
37
|
</div>
|
38
38
|
|
39
39
|
<div id="cart-form" data-hook="cart_form">
|
40
|
-
<%= render :
|
40
|
+
<%= render partial: 'cart_form' %>
|
41
41
|
</div>
|
42
42
|
|
43
43
|
</div>
|
44
44
|
|
45
|
-
<%= render :
|
45
|
+
<%= render partial: 'taxons' %>
|
46
46
|
|
47
47
|
</div>
|
48
48
|
</div>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<% filters = @taxon ? @taxon.applicable_filters : [Spree::Core::ProductFilters.all_taxons] %>
|
2
2
|
<% unless filters.empty? %>
|
3
|
-
<%= form_tag '', :
|
3
|
+
<%= form_tag '', method: :get, id: 'sidebar_products_search' do %>
|
4
4
|
<%= hidden_field_tag 'per_page', params[:per_page] %>
|
5
5
|
<% filters.each do |filter| %>
|
6
6
|
<% labels = filter[:labels] || filter[:conds].map {|m,c| [m,m]} %>
|
@@ -22,6 +22,6 @@
|
|
22
22
|
</ul>
|
23
23
|
</div>
|
24
24
|
<% end %>
|
25
|
-
<%= submit_tag Spree.t(:search), :
|
25
|
+
<%= submit_tag Spree.t(:search), name: nil %>
|
26
26
|
<% end %>
|
27
27
|
<% end %>
|
@@ -5,7 +5,7 @@
|
|
5
5
|
<%== meta_data_tags %>
|
6
6
|
<%= canonical_tag(current_store.url) %>
|
7
7
|
<%= favicon_link_tag 'favicon.ico' %>
|
8
|
-
<%= stylesheet_link_tag 'spree/frontend/all', :
|
8
|
+
<%= stylesheet_link_tag 'spree/frontend/all', media: 'screen' %>
|
9
9
|
<%= csrf_meta_tags %>
|
10
10
|
<%= javascript_include_tag 'spree/frontend/all' %>
|
11
11
|
<!--[if lt IE 9]>
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<header id="header" class="row" data-hook>
|
2
2
|
<figure id="logo" class="columns six" data-hook><%= logo %></figure>
|
3
|
-
<%= render :
|
4
|
-
<%= render :
|
3
|
+
<%= render partial: 'spree/shared/nav_bar' %>
|
4
|
+
<%= render partial: 'spree/shared/main_nav_bar' if store_menu? %>
|
5
5
|
</header>
|
@@ -3,10 +3,10 @@
|
|
3
3
|
<li id="home-link" data-hook><%= link_to Spree.t(:home), spree.root_path %></li>
|
4
4
|
<li id="link-to-cart" data-hook>
|
5
5
|
<noscript>
|
6
|
-
<%= link_to Spree.t(:cart),
|
6
|
+
<%= link_to Spree.t(:cart), spree.cart_path %>
|
7
7
|
</noscript>
|
8
8
|
|
9
9
|
</li>
|
10
|
-
<script>Spree.fetch_cart('<%= j spree.cart_link_url %>')</script>
|
11
10
|
</ul>
|
11
|
+
<script>Spree.fetch_cart('<%= j spree.cart_link_path %>')</script>
|
12
12
|
</nav>
|
@@ -1,16 +1,16 @@
|
|
1
1
|
<div class="row steps-data">
|
2
2
|
|
3
|
-
<% if order.
|
3
|
+
<% if order.has_checkout_step?("address") %>
|
4
4
|
|
5
5
|
<div class="columns alpha four" data-hook="order-bill-address">
|
6
6
|
<h6><%= Spree.t(:billing_address) %> <%= link_to "(#{Spree.t('actions.edit')})", checkout_state_path(:address) unless order.completed? %></h6>
|
7
|
-
<%= render :
|
7
|
+
<%= render partial: 'spree/shared/address', locals: { address: order.bill_address } %>
|
8
8
|
</div>
|
9
9
|
|
10
|
-
<% if order.
|
10
|
+
<% if order.has_checkout_step?("delivery") %>
|
11
11
|
<div class="columns alpha four" data-hook="order-ship-address">
|
12
12
|
<h6><%= Spree.t(:shipping_address) %> <%= link_to "(#{Spree.t('actions.edit')})", checkout_state_path(:address) unless order.completed? %></h6>
|
13
|
-
<%= render :
|
13
|
+
<%= render partial: 'spree/shared/address', locals: { address: order.ship_address } %>
|
14
14
|
</div>
|
15
15
|
|
16
16
|
<div class="columns alpha four" data-hook="order-shipment">
|
@@ -19,16 +19,16 @@
|
|
19
19
|
<% order.shipments.each do |shipment| %>
|
20
20
|
<div>
|
21
21
|
<i class='fa fa-truck'></i>
|
22
|
-
<%= Spree.t(:shipment_details, :
|
22
|
+
<%= Spree.t(:shipment_details, stock_location: shipment.stock_location.name, shipping_method: shipment.selected_shipping_rate.name) %>
|
23
23
|
</div>
|
24
24
|
<% end %>
|
25
25
|
</div>
|
26
|
-
<%= render(:
|
26
|
+
<%= render(partial: 'spree/shared/shipment_tracking', locals: {order: order}) if order.shipped? %>
|
27
27
|
</div>
|
28
28
|
<% end %>
|
29
29
|
<% end %>
|
30
30
|
|
31
|
-
<% if order.
|
31
|
+
<% if order.has_checkout_step?("payment") %>
|
32
32
|
<div class="columns omega four">
|
33
33
|
<h6><%= Spree.t(:payment_information) %> <%= link_to "(#{Spree.t('actions.edit')})", checkout_state_path(:payment) unless order.completed? %></h6>
|
34
34
|
<div class="payment-info">
|
@@ -1,11 +1,11 @@
|
|
1
1
|
<% @taxons = @taxon && @taxon.parent ? @taxon.parent.children : Spree::Taxon.roots %>
|
2
|
-
<%= form_tag spree.products_path, :
|
3
|
-
<% cache
|
2
|
+
<%= form_tag spree.products_path, method: :get do %>
|
3
|
+
<% cache [I18n.locale, @taxons] do %>
|
4
4
|
<%= select_tag :taxon,
|
5
5
|
options_for_select([[Spree.t(: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], :
|
10
|
-
<%= submit_tag Spree.t(:search), :
|
9
|
+
<%= search_field_tag :keywords, params[:keywords], placeholder: Spree.t(:search) %>
|
10
|
+
<%= submit_tag Spree.t(:search), name: nil %>
|
11
11
|
<% end %>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<nav id="taxonomies" class="sidebar-item" data-hook>
|
3
3
|
<% @taxonomies.each do |taxonomy| %>
|
4
4
|
<% cache [I18n.locale, taxonomy, max_level] do %>
|
5
|
-
<h6 class='taxonomy-root'><%= Spree.t(:shop_by_taxonomy, :
|
5
|
+
<h6 class='taxonomy-root'><%= Spree.t(:shop_by_taxonomy, taxonomy: taxonomy.name) %></h6>
|
6
6
|
<%= taxons_tree(taxonomy.root, @taxon, max_level) %>
|
7
7
|
<% end %>
|
8
8
|
<% end %>
|
@@ -1,8 +1 @@
|
|
1
|
-
Rails.application.config.assets.precompile
|
2
|
-
spree/frontend/all*
|
3
|
-
jquery.validate/localization/messages_*
|
4
|
-
favicon.ico
|
5
|
-
spree/frontend/cart.png
|
6
|
-
credit_cards/*
|
7
|
-
icons/delete.png
|
8
|
-
]
|
1
|
+
Rails.application.config.assets.precompile << 'solidus_frontend_manifest.js'
|
data/config/routes.rb
CHANGED
@@ -11,7 +11,7 @@ Spree::Core::Engine.routes.draw do
|
|
11
11
|
get '/checkout', to: 'checkout#edit', as: :checkout
|
12
12
|
|
13
13
|
get '/orders/populate', to: 'orders#populate_redirect'
|
14
|
-
get '/orders/:id/token/:token' => 'orders#show', :
|
14
|
+
get '/orders/:id/token/:token' => 'orders#show', as: :token_order
|
15
15
|
|
16
16
|
resources :orders, except: [:index, :new, :create, :destroy] do
|
17
17
|
post :populate, on: :collection
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'rails'
|
2
|
+
|
3
|
+
module Solidus
|
4
|
+
module Views
|
5
|
+
class OverrideGenerator < ::Rails::Generators::Base
|
6
|
+
def self.views_folder
|
7
|
+
Spree::Frontend::Engine.root.join('app', 'views', 'spree')
|
8
|
+
end
|
9
|
+
|
10
|
+
VIEWS = Dir.glob(views_folder.join('**', '*'))
|
11
|
+
|
12
|
+
desc "Override solidus frontend views in your app. You can either provide single files or complete folders."
|
13
|
+
|
14
|
+
class_option :only,
|
15
|
+
type: :string,
|
16
|
+
default: nil,
|
17
|
+
desc: "Name of file or folder to copy exclusively. Can be a substring."
|
18
|
+
|
19
|
+
source_root views_folder
|
20
|
+
|
21
|
+
def copy_views
|
22
|
+
views_to_copy.each do |file|
|
23
|
+
next if File.directory?(file)
|
24
|
+
dest_file = Pathname.new(file).relative_path_from(source_dir)
|
25
|
+
copy_file file, Rails.root.join('app', 'views', 'spree', dest_file)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def views_to_copy
|
32
|
+
if @options['only']
|
33
|
+
VIEWS.select do |v|
|
34
|
+
Pathname.new(v).relative_path_from(source_dir).to_s.include?(@options['only'])
|
35
|
+
end
|
36
|
+
else
|
37
|
+
VIEWS
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def source_dir
|
42
|
+
self.class.views_folder
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Spree::CheckoutController, type: :controller do
|
4
4
|
let(:token) { 'some_token' }
|
5
|
-
let(:user) {
|
5
|
+
let(:user) { create(:user) }
|
6
6
|
let(:order) { FactoryGirl.create(:order_with_totals) }
|
7
7
|
|
8
8
|
let(:address_params) do
|
@@ -58,7 +58,7 @@ describe Spree::CheckoutController, type: :controller do
|
|
58
58
|
it "should associate the order with a user" do
|
59
59
|
order.update_column :user_id, nil
|
60
60
|
expect(order).to receive(:associate_user!).with(user)
|
61
|
-
get :edit
|
61
|
+
get :edit
|
62
62
|
end
|
63
63
|
end
|
64
64
|
end
|
@@ -81,9 +81,9 @@ describe Spree::CheckoutController, type: :controller do
|
|
81
81
|
}
|
82
82
|
end
|
83
83
|
|
84
|
-
let!(:payment_method) { create(:payment_method) }
|
85
84
|
before do
|
86
85
|
# Must have *a* shipping method and a payment method so updating from address works
|
86
|
+
allow(order).to receive_messages available_payment_methods: [stub_model(Spree::PaymentMethod)]
|
87
87
|
allow(order).to receive_messages ensure_available_shipping_rates: true
|
88
88
|
order.line_items << FactoryGirl.create(:line_item)
|
89
89
|
end
|
@@ -218,53 +218,6 @@ describe Spree::CheckoutController, type: :controller do
|
|
218
218
|
end
|
219
219
|
end
|
220
220
|
|
221
|
-
context "when in the payment state" do
|
222
|
-
let(:order) { create(:order_with_line_items) }
|
223
|
-
let(:payment_method) { create(:credit_card_payment_method) }
|
224
|
-
|
225
|
-
let(:params) do
|
226
|
-
{
|
227
|
-
state: 'payment',
|
228
|
-
order: {
|
229
|
-
payments_attributes: [
|
230
|
-
{
|
231
|
-
payment_method_id: payment_method.id.to_s,
|
232
|
-
source_attributes: attributes_for(:credit_card)
|
233
|
-
}
|
234
|
-
]
|
235
|
-
}
|
236
|
-
}
|
237
|
-
end
|
238
|
-
|
239
|
-
before do
|
240
|
-
order.update_attributes! user: user
|
241
|
-
3.times { order.next! } # should put us in the payment state
|
242
|
-
end
|
243
|
-
|
244
|
-
context 'with a permitted payment method' do
|
245
|
-
it 'sets the payment amount' do
|
246
|
-
post :update, params: params
|
247
|
-
order.reload
|
248
|
-
expect(order.state).to eq('confirm')
|
249
|
-
expect(order.payments.size).to eq(1)
|
250
|
-
expect(order.payments.first.amount).to eq(order.total)
|
251
|
-
end
|
252
|
-
end
|
253
|
-
|
254
|
-
context 'with an unpermitted payment method' do
|
255
|
-
before { payment_method.update!(available_to_users: false) }
|
256
|
-
|
257
|
-
it 'sets the payment amount' do
|
258
|
-
expect {
|
259
|
-
post :update, params: params
|
260
|
-
}.to raise_error(ActiveRecord::RecordNotFound)
|
261
|
-
|
262
|
-
expect(order.state).to eq('payment')
|
263
|
-
expect(order.payments).to be_empty
|
264
|
-
end
|
265
|
-
end
|
266
|
-
end
|
267
|
-
|
268
221
|
context "when in the confirm state" do
|
269
222
|
before do
|
270
223
|
order.update_attributes! user: user
|
@@ -288,7 +241,7 @@ describe Spree::CheckoutController, type: :controller do
|
|
288
241
|
end
|
289
242
|
|
290
243
|
it "should remove completed order from current_order" do
|
291
|
-
post :update, params: { state: "confirm" }
|
244
|
+
post :update, params: { state: "confirm" }
|
292
245
|
expect(assigns(:current_order)).to be_nil
|
293
246
|
expect(assigns(:order)).to eql controller.current_order
|
294
247
|
end
|
@@ -437,7 +390,7 @@ describe Spree::CheckoutController, type: :controller do
|
|
437
390
|
context "When last inventory item has been purchased" do
|
438
391
|
let(:product) { mock_model(Spree::Product, name: "Amazing Object") }
|
439
392
|
let(:variant) { mock_model(Spree::Variant) }
|
440
|
-
let(:line_item) { mock_model Spree::LineItem, insufficient_stock?: true, amount: 0 }
|
393
|
+
let(:line_item) { mock_model Spree::LineItem, insufficient_stock?: true, amount: 0, name: "Amazing Item" }
|
441
394
|
let(:order) { create(:order) }
|
442
395
|
|
443
396
|
before do
|
@@ -81,20 +81,20 @@ describe Spree::OrdersController, type: :controller do
|
|
81
81
|
it "should render the edit view (on failure)" do
|
82
82
|
# email validation is only after address state
|
83
83
|
order.update_column(:state, "delivery")
|
84
|
-
put :update, params: { order: { email: "" } }
|
84
|
+
put :update, params: { order: { email: "" } }
|
85
85
|
expect(response).to render_template :edit
|
86
86
|
end
|
87
87
|
|
88
88
|
it "should redirect to cart path (on success)" do
|
89
89
|
allow(order).to receive(:update_attributes).and_return true
|
90
|
-
put :update
|
90
|
+
put :update
|
91
91
|
expect(response).to redirect_to(spree.cart_path)
|
92
92
|
end
|
93
93
|
|
94
94
|
it "should advance the order if :checkout button is pressed" do
|
95
95
|
allow(order).to receive(:update_attributes).and_return true
|
96
96
|
expect(order).to receive(:next)
|
97
|
-
put :update, { checkout: true }
|
97
|
+
put :update, params: { checkout: true }
|
98
98
|
expect(response).to redirect_to checkout_state_path('address')
|
99
99
|
end
|
100
100
|
end
|
@@ -23,7 +23,7 @@ module Spree
|
|
23
23
|
it "correctly calls the transition callback" do
|
24
24
|
expect(order.did_transition).to be_nil
|
25
25
|
order.line_items << FactoryGirl.create(:line_item)
|
26
|
-
put :update, params: { checkout: "checkout" }
|
26
|
+
put :update, params: { checkout: "checkout" }
|
27
27
|
expect(order.did_transition).to be true
|
28
28
|
end
|
29
29
|
end
|
@@ -13,7 +13,6 @@ describe 'products', type: :feature, caching: true do
|
|
13
13
|
assert_written_to_cache("views/en/USD/spree/products/all--#{product.updated_at.utc.to_s(:number)}")
|
14
14
|
assert_written_to_cache("views/en/USD/spree/products/#{product.id}-#{product.updated_at.utc.to_s(:number)}")
|
15
15
|
assert_written_to_cache("views/en/spree/taxonomies/#{taxonomy.id}")
|
16
|
-
assert_written_to_cache("views/en/taxons/#{taxon.updated_at.utc.to_i}")
|
17
16
|
|
18
17
|
clear_cache_events
|
19
18
|
end
|
@@ -8,7 +8,6 @@ describe 'taxons', type: :feature, caching: true do
|
|
8
8
|
# warm up the cache
|
9
9
|
visit spree.root_path
|
10
10
|
assert_written_to_cache("views/en/spree/taxonomies/#{taxonomy.id}")
|
11
|
-
assert_written_to_cache("views/en/taxons/#{taxon.updated_at.utc.to_i}")
|
12
11
|
|
13
12
|
clear_cache_events
|
14
13
|
end
|
@@ -77,9 +77,9 @@ describe "Checkout", type: :feature, inaccessible: true do
|
|
77
77
|
|
78
78
|
# Regression test for https://github.com/spree/spree/issues/2694 and https://github.com/spree/spree/issues/4117
|
79
79
|
context "doesn't allow bad credit card numbers" do
|
80
|
-
let!(:payment_method) { create(:credit_card_payment_method) }
|
81
80
|
before(:each) do
|
82
81
|
order = OrderWalkthrough.up_to(:delivery)
|
82
|
+
allow(order).to receive_messages(available_payment_methods: [create(:credit_card_payment_method)])
|
83
83
|
|
84
84
|
user = create(:user)
|
85
85
|
order.user = user
|
@@ -180,8 +180,7 @@ describe "Checkout", type: :feature, inaccessible: true do
|
|
180
180
|
end
|
181
181
|
|
182
182
|
context "user has payment sources", js: true do
|
183
|
-
|
184
|
-
let!(:bogus) { create(:credit_card_payment_method) }
|
183
|
+
let(:bogus) { create(:credit_card_payment_method) }
|
185
184
|
let(:user) { create(:user) }
|
186
185
|
|
187
186
|
let!(:credit_card) do
|
@@ -189,7 +188,9 @@ describe "Checkout", type: :feature, inaccessible: true do
|
|
189
188
|
end
|
190
189
|
|
191
190
|
before do
|
191
|
+
user.wallet.add(credit_card)
|
192
192
|
order = OrderWalkthrough.up_to(:delivery)
|
193
|
+
allow(order).to receive_messages(available_payment_methods: [bogus])
|
193
194
|
|
194
195
|
allow_any_instance_of(Spree::CheckoutController).to receive_messages(current_order: order)
|
195
196
|
allow_any_instance_of(Spree::CheckoutController).to receive_messages(try_spree_current_user: user)
|