solidus_backend 2.9.6 → 2.10.0.beta1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of solidus_backend might be problematic. Click here for more details.

Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/spree/backend/models/order.js +9 -0
  3. data/app/assets/javascripts/spree/backend/orders/cart.js +6 -0
  4. data/app/assets/javascripts/spree/backend/shipments.js +0 -62
  5. data/app/assets/javascripts/spree/backend/templates/index.js +0 -1
  6. data/app/assets/javascripts/spree/backend/views/cart/empty_cart_button.js +29 -0
  7. data/app/assets/javascripts/spree/backend/views/cart/line_item_table.js +5 -0
  8. data/app/assets/javascripts/spree/backend/views/index.js +1 -0
  9. data/app/assets/stylesheets/spree/backend/globals/{_mixins.css → _mixins.scss} +0 -0
  10. data/app/controllers/spree/admin/adjustments_controller.rb +1 -1
  11. data/app/controllers/spree/admin/base_controller.rb +1 -1
  12. data/app/controllers/spree/admin/payment_methods_controller.rb +1 -1
  13. data/app/controllers/spree/admin/products_controller.rb +1 -1
  14. data/app/controllers/spree/admin/resource_controller.rb +1 -1
  15. data/app/controllers/spree/admin/style_guide_controller.rb +1 -1
  16. data/app/controllers/spree/admin/users_controller.rb +2 -2
  17. data/app/helpers/spree/admin/navigation_helper.rb +3 -2
  18. data/app/helpers/spree/promotion_rules_helper.rb +1 -1
  19. data/app/views/spree/admin/orders/_line_items_edit_form.html.erb +1 -0
  20. data/app/views/spree/admin/orders/edit.html.erb +3 -4
  21. data/app/views/spree/admin/promotions/index.html.erb +1 -1
  22. data/app/views/spree/admin/shared/_order_submenu.html.erb +2 -2
  23. data/app/views/spree/admin/stock_locations/index.html.erb +1 -1
  24. data/app/views/spree/admin/store_credit_reasons/index.html.erb +1 -1
  25. data/app/views/spree/admin/store_credits/index.html.erb +1 -1
  26. data/app/views/spree/admin/users/_tabs.html.erb +1 -1
  27. data/lib/spree/backend.rb +1 -0
  28. data/lib/spree/backend/config.rb +9 -0
  29. data/lib/spree/backend/engine.rb +5 -3
  30. data/{app/models → lib}/spree/backend_configuration.rb +3 -1
  31. data/solidus_backend.gemspec +1 -0
  32. data/spec/controllers/spree/admin/customer_returns_controller_spec.rb +1 -1
  33. data/spec/controllers/spree/admin/orders/customer_details_controller_spec.rb +2 -2
  34. data/spec/controllers/spree/admin/store_credits_controller_spec.rb +1 -1
  35. data/spec/features/admin/orders/customer_details_spec.rb +1 -2
  36. data/spec/features/admin/orders/new_order_spec.rb +5 -5
  37. data/spec/features/admin/orders/new_refund_spec.rb +1 -1
  38. data/spec/features/admin/orders/order_details_spec.rb +14 -4
  39. data/spec/features/admin/products/edit/taxons_spec.rb +8 -2
  40. data/spec/{models → lib}/spree/backend_configuration/menu_item_spec.rb +0 -0
  41. data/spec/{models → lib}/spree/backend_configuration_spec.rb +0 -0
  42. metadata +27 -13
  43. data/app/assets/javascripts/spree/backend/templates/variants/autocomplete_stock.hbs +0 -56
  44. data/app/views/spree/admin/orders/_add_product.html.erb +0 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8f0c706dab405664795c44607df0bd5c1c34c672d5b127334dc26f96a3c6d512
4
- data.tar.gz: a967573f7531766f5463d62bf6003c199cbe3edc818045dda6c1253e65ea95ff
3
+ metadata.gz: 6900a204c004e5fe7d29af73908bdc9ccc97edd722a4000946a6c15baca90ed6
4
+ data.tar.gz: b52e623d7cf35f72ac8fe09661da2c4e69f7f727636393429f2e638919bc6dcc
5
5
  SHA512:
6
- metadata.gz: 4d1dbb894a0fa1d9680ccb0209e18674f646fb8fdc3a839d5dfbba35c21eb7deb03c9872ee08eb39cc850fd828ce03782038cf5e939b481826c9d1b70c08557e
7
- data.tar.gz: dfc913572b3815ba7558833d08360d06b607d0ce2c6361682c765972528ceeeff3cbcadb6eeae2d3dd6bf84ef9edc363a3a0101f38b3d957f9f6d913dc788a2a
6
+ metadata.gz: 502d7cb40991948f4cd60ee9d602cf94121109fd933c5f7b97aab79f0ae05c92b29b88efb71a803e2f53479a1d0d1b287be8b5fa10184956f977f697134dd93e
7
+ data.tar.gz: 649b8e1085cd38b2ae6ea77065a5eff52efe187facef00c924e1d18ddcee06286cbcb09c716f8fbe1c748625d87271b7f6f5cd8505f1261ebb74f2661f0ab375
@@ -21,6 +21,15 @@ Spree.Models.Order = Backbone.Model.extend({
21
21
  };
22
22
  _.extend(options, opts);
23
23
  return this.fetch(options)
24
+ },
25
+
26
+ empty: function (opts) {
27
+ var options = {
28
+ url: Spree.routes.orders_api + "/" + this.id + "/empty",
29
+ type: 'PUT',
30
+ };
31
+ _.extend(options, opts);
32
+ return this.fetch(options)
24
33
  }
25
34
  });
26
35
 
@@ -19,6 +19,12 @@ Spree.Order.initCartPage = function(order_number) {
19
19
  collection: collection
20
20
  });
21
21
 
22
+ new Spree.Views.Cart.EmptyCartButton({
23
+ el: $('.js-empty-cart'),
24
+ collection: collection,
25
+ model: order
26
+ });
27
+
22
28
  new Spree.Views.Order.DetailsTotal({
23
29
  el: $('#order-total'),
24
30
  model: order
@@ -1,42 +1,6 @@
1
1
  // Shipments AJAX API
2
2
  /* eslint no-extra-semi: "off", no-unused-vars: "off" */
3
3
 
4
- var ShipmentAddVariantView = Backbone.View.extend({
5
- events: {
6
- "change #add_variant_id": "onSelect",
7
- "click .add_variant": "onAdd",
8
- "submit form": "onAdd"
9
- },
10
- onSelect: function(e) {
11
- var variant_id = this.$("#add_variant_id").val();
12
- var template = HandlebarsTemplates["variants/autocomplete_stock"];
13
- var $stock_details = this.$('#stock_details');
14
- Spree.ajax({
15
- url: Spree.routes.variants_api + "/" + variant_id,
16
- success: function(variant){
17
- $stock_details.html(template({variant: variant})).show()
18
- }
19
- });
20
- },
21
- onAdd: function(e){
22
- e.preventDefault();
23
-
24
- this.$('#stock_details').hide();
25
-
26
- var variant_id = this.$('input.variant_autocomplete').val();
27
- var stock_location_id = $(e.target).data('stock-location-id');
28
- var quantity = this.$("input.quantity[data-stock-location-id='" + stock_location_id + "']").val();
29
-
30
- addVariantFromStockLocation(stock_location_id, variant_id, quantity)
31
- }
32
- });
33
-
34
- Spree.ready(function(){
35
- $(".js-shipment-add-variant").each(function(){
36
- new ShipmentAddVariantView({el: this});
37
- });
38
- });
39
-
40
4
  var ShipShipmentView = Backbone.View.extend({
41
5
  initialize: function(options){
42
6
  this.shipment_number = options.shipment_number;
@@ -97,32 +61,6 @@ adjustShipmentItems = function(shipment_number, variant_id, quantity){
97
61
  }
98
62
  };
99
63
 
100
- addVariantFromStockLocation = function(stock_location_id, variant_id, quantity) {
101
- var shipment = _.find(shipments, function(shipment){
102
- return shipment.stock_location_id == stock_location_id && (shipment.state == 'ready' || shipment.state == 'pending');
103
- });
104
-
105
- if(shipment==undefined){
106
- Spree.ajax({
107
- type: "POST",
108
- url: Spree.routes.shipments_api,
109
- data: {
110
- shipment: {
111
- order_id: window.order_number
112
- },
113
- variant_id: variant_id,
114
- quantity: quantity,
115
- stock_location_id: stock_location_id,
116
- }
117
- }).done(function(){
118
- window.location.reload();
119
- });
120
- }else{
121
- //add to existing shipment
122
- adjustShipmentItems(shipment.number, variant_id, quantity);
123
- }
124
- };
125
-
126
64
  var ShipmentSplitItemView = Backbone.View.extend({
127
65
  tagName: 'tr',
128
66
  className: 'stock-item-split',
@@ -13,6 +13,5 @@
13
13
  //= require spree/backend/templates/taxons/_tree
14
14
  //= require spree/backend/templates/taxons/tree
15
15
  //= require spree/backend/templates/variants/autocomplete
16
- //= require spree/backend/templates/variants/autocomplete_stock
17
16
  //= require spree/backend/templates/variants/line_items_autocomplete_stock
18
17
  //= require spree/backend/templates/variants/split
@@ -0,0 +1,29 @@
1
+ Spree.Views.Cart.EmptyCartButton = Backbone.View.extend({
2
+ initialize: function() {
3
+ this.listenTo(this.collection, 'update', this.render);
4
+ this.render();
5
+ },
6
+
7
+ events: {
8
+ "click": "onClick"
9
+ },
10
+
11
+ onClick: function(e) {
12
+ e.preventDefault()
13
+ if (!confirm(Spree.translations.are_you_sure_delete)) {
14
+ return;
15
+ }
16
+
17
+ this.model.empty({
18
+ success: () => {
19
+ this.collection.reset()
20
+ this.collection.push({})
21
+ }
22
+ })
23
+ },
24
+
25
+ render: function() {
26
+ var isNew = function (item) { return item.isNew() };
27
+ this.$el.prop("disabled", !this.collection.length || this.collection.some(isNew));
28
+ }
29
+ });
@@ -1,11 +1,16 @@
1
1
  Spree.Views.Cart.LineItemTable = Backbone.View.extend({
2
2
  initialize: function() {
3
3
  this.listenTo(this.collection, 'add', this.add);
4
+ this.listenTo(this.collection, 'reset', this.reset);
4
5
  },
5
6
 
6
7
  add: function(line_item) {
7
8
  var view = new Spree.Views.Cart.LineItemRow({model: line_item});
8
9
  view.render();
9
10
  this.$el.append(view.el);
11
+ },
12
+
13
+ reset: function() {
14
+ this.$el.empty();
10
15
  }
11
16
  });
@@ -1,5 +1,6 @@
1
1
  //= require 'spree/backend/views/calculators/tiered'
2
2
  //= require 'spree/backend/views/cart/add_line_item_button'
3
+ //= require 'spree/backend/views/cart/empty_cart_button'
3
4
  //= require 'spree/backend/views/cart/line_item_row'
4
5
  //= require 'spree/backend/views/cart/line_item_table'
5
6
  //= require 'spree/backend/views/images/upload_zone'
@@ -40,7 +40,7 @@ module Spree
40
40
  [
41
41
  Spree::AdjustmentReason.active.to_a,
42
42
  @adjustment.adjustment_reason
43
- ].flatten.compact.uniq.sort_by { |r| r.name.downcase }
43
+ ].flatten.compact.uniq.sort_by { |reason| reason.name.downcase }
44
44
  end
45
45
  end
46
46
  end
@@ -4,7 +4,7 @@ module Spree
4
4
  module Admin
5
5
  class BaseController < Spree::BaseController
6
6
  helper 'spree/admin/navigation'
7
- layout '/spree/layouts/admin'
7
+ layout 'spree/layouts/admin'
8
8
 
9
9
  before_action :authorize_admin
10
10
 
@@ -34,7 +34,7 @@ module Spree
34
34
  end
35
35
  end
36
36
 
37
- if @payment_method.update_attributes(attributes)
37
+ if @payment_method.update(attributes)
38
38
  invoke_callbacks(:update, :after)
39
39
  flash[:success] = t('spree.successfully_updated', resource: t('spree.payment_method'))
40
40
  redirect_to edit_admin_payment_method_path(@payment_method)
@@ -26,7 +26,7 @@ module Spree
26
26
  end
27
27
  end
28
28
  invoke_callbacks(:update, :before)
29
- if @object.update_attributes(permitted_resource_params)
29
+ if @object.update(permitted_resource_params)
30
30
  invoke_callbacks(:update, :after)
31
31
  flash[:success] = flash_message_for(@object, :successfully_updated)
32
32
  respond_with(@object) do |format|
@@ -30,7 +30,7 @@ class Spree::Admin::ResourceController < Spree::Admin::BaseController
30
30
 
31
31
  def update
32
32
  invoke_callbacks(:update, :before)
33
- if @object.update_attributes(permitted_resource_params)
33
+ if @object.update(permitted_resource_params)
34
34
  invoke_callbacks(:update, :after)
35
35
  respond_with(@object) do |format|
36
36
  format.html do
@@ -4,7 +4,7 @@ module Spree
4
4
  module Admin
5
5
  class StyleGuideController < Spree::Admin::BaseController
6
6
  respond_to :html
7
- layout '/spree/layouts/admin_style_guide'
7
+ layout 'spree/layouts/admin_style_guide'
8
8
 
9
9
  def index
10
10
  @topics = {
@@ -38,7 +38,7 @@ module Spree
38
38
  end
39
39
 
40
40
  def update
41
- if @user.update_attributes(user_params)
41
+ if @user.update(user_params)
42
42
  set_roles
43
43
  set_stock_locations
44
44
 
@@ -55,7 +55,7 @@ module Spree
55
55
 
56
56
  def addresses
57
57
  if request.put?
58
- if @user.update_attributes(user_params)
58
+ if @user.update(user_params)
59
59
  flash.now[:success] = t('spree.account_updated')
60
60
  end
61
61
 
@@ -33,7 +33,7 @@ module Spree
33
33
  elsif content_for?(:page_title)
34
34
  content_for(:page_title)
35
35
  elsif admin_breadcrumbs.any?
36
- admin_breadcrumbs.map{ |x| strip_tags(x) }.reverse.join(' - ')
36
+ admin_breadcrumbs.map { |breadcrumb| strip_tags(breadcrumb) }.reverse.join(' - ')
37
37
  else
38
38
  t(controller.controller_name, default: controller.controller_name.titleize, scope: 'spree')
39
39
  end
@@ -181,7 +181,8 @@ module Spree
181
181
  url.ends_with?("#{controller.controller_name.singularize}/edit")
182
182
  options[:class] = 'fa'
183
183
  options[:class] += ' active' if is_active
184
- options[:datahook] = "admin_settings_#{link_text.downcase.tr(' ', '_')}"
184
+ options[:data] ||= {}
185
+ options[:data][:hook] = "admin_settings_#{link_text.downcase.tr(' ', '_')}"
185
186
  content_tag(:li, options) do
186
187
  link_to(link_text, url)
187
188
  end
@@ -4,7 +4,7 @@ module Spree
4
4
  module PromotionRulesHelper
5
5
  def options_for_promotion_rule_types(promotion)
6
6
  existing = promotion.rules.map { |rule| rule.class.name }
7
- rules = Rails.application.config.spree.promotions.rules.reject { |r| existing.include? r.name }
7
+ rules = Rails.application.config.spree.promotions.rules.reject { |rule| existing.include? rule.name }
8
8
  options = rules.map { |rule| [rule.model_name.human, rule.name] }
9
9
  options_for_select(options)
10
10
  end
@@ -7,6 +7,7 @@
7
7
 
8
8
  <% if can?(:update, @order) && can?(:create, Spree::LineItem) %>
9
9
  <button class="js-add-line-item btn btn-primary" disabled><%= t('spree.add_line_item') %></button>
10
+ <button class="js-empty-cart btn btn-primary" disabled><%= t('spree.empty_cart') %></button>
10
11
  <% end %>
11
12
 
12
13
  <%= render "spree/admin/orders/order_details", { order: order } %>
@@ -18,13 +18,12 @@
18
18
  <%= render 'spree/admin/orders/risk_analysis', latest_payment: @order.payments.reorder("created_at DESC").first %>
19
19
  <% end %>
20
20
 
21
- <% if can?(:update, Spree::Shipment) && can?(:update, @order) && @order.shipment_state != "shipped" %>
22
- <%= render partial: 'add_product' %>
23
- <% end %>
21
+ <div data-hook="admin_order_edit_sub_header" />
24
22
 
25
23
  <% if @order.line_items.empty? %>
26
24
  <div class="no-objects-found">
27
- <%= t('spree.your_order_is_empty_add_product')%>
25
+ <p><%= t('spree.your_order_is_empty_add_product') %></p>
26
+ <%= link_to t('spree.cart'), spree.cart_admin_order_url(@order), class: 'btn btn-primary' %>
28
27
  </div>
29
28
  <% end %>
30
29
 
@@ -78,7 +78,7 @@
78
78
  <tr id="<%= spree_dom_id promotion %>">
79
79
  <td><%= promotion.name %></td>
80
80
  <td>
81
- <%= (promotion.codes.size == 1) ? promotion.codes.take.try!(:value) : t('spree.number_of_codes', count: promotion.codes.size) %>
81
+ <%= (promotion.codes.size == 1) ? promotion.codes.pluck(:value).first : t('spree.number_of_codes', count: promotion.codes.size) %>
82
82
  </td>
83
83
  <td>
84
84
  <span class="pill pill-<%= promotion.active? ? 'active' : 'inactive' %>">
@@ -55,9 +55,9 @@
55
55
  <% end %>
56
56
 
57
57
  <% if can?(:manage, Spree::OrderCancellations) && @order.inventory_units.cancelable.present? %>
58
- <%= content_tag('li', class: "#{'active' if current == 'Cancel Inventory'}", data: {hook: 'admin_order_tabs_cancel_inventory'}) do %>
58
+ <li class="<%= "active" if current == "Cancel Inventory" %>" data-hook='admin_order_tabs_cancel_inventory'>
59
59
  <%= link_to t('spree.cancel_inventory'), spree.admin_order_cancellations_path(@order) %>
60
- <% end %>
60
+ </li>
61
61
  <% end %>
62
62
  </ul>
63
63
  </nav>
@@ -28,7 +28,7 @@
28
28
  <tr data-hook="stock_locations_header">
29
29
  <th></th>
30
30
  <th><%= Spree::StockLocation.human_attribute_name(:name) %></th>
31
- <th><%= Spree::StockLocation.human_attribute_name(:state_id) %></th>
31
+ <th><%= Spree::StockLocation.human_attribute_name(:state) %></th>
32
32
  <th><%= plural_resource_name(Spree::StockMovement) %></th>
33
33
  <th class="actions"></th>
34
34
  </tr>
@@ -7,7 +7,7 @@
7
7
  <% content_for :page_actions do %>
8
8
  <ul class='actions inline-menu'>
9
9
  <li>
10
- <%= link_to t('spree.new_adjustment_reason'), new_object_url, id: 'admin_new_named_type', class: 'btn btn-primary' %>
10
+ <%= link_to t('spree.new_store_credit_reason'), new_object_url, id: 'admin_new_named_type', class: 'btn btn-primary' %>
11
11
  </li>
12
12
  </ul>
13
13
  <% end %>
@@ -6,7 +6,7 @@
6
6
  <%= render 'spree/admin/users/sidebar' %>
7
7
  <%= render 'spree/admin/users/tabs', current: :store_credits %>
8
8
  <% content_for :page_actions do %>
9
- <% if can?(:create, Spree::StoreCredit) %>
9
+ <% if can?(:create, @user.store_credits.new) %>
10
10
  <li><%= link_to t('spree.admin.store_credits.add'), new_admin_user_store_credit_path(@user), class: 'button btn btn-primary' %></li>
11
11
  <% end %>
12
12
  <% end %>
@@ -19,7 +19,7 @@
19
19
  <%= link_to t("spree.admin.user.items"), spree.items_admin_user_path(@user) %>
20
20
  </li>
21
21
  <% end %>
22
- <% if can?(:display, Spree::StoreCredit) %>
22
+ <% if can?(:display, @user.store_credits.new) %>
23
23
  <li<%== ' class="active"' if current == :store_credits %>>
24
24
  <%= link_to t("spree.admin.user.store_credit"), spree.admin_user_store_credits_path(@user) %>
25
25
  </li>
data/lib/spree/backend.rb CHANGED
@@ -9,6 +9,7 @@ require 'font-awesome-rails'
9
9
  require 'autoprefixer-rails'
10
10
  require 'jbuilder'
11
11
  require 'kaminari'
12
+ require 'responders'
12
13
 
13
14
  require 'spree_core'
14
15
  require 'spree_api'
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spree/backend_configuration'
4
+
5
+ module Spree
6
+ module Backend
7
+ Config = Spree::BackendConfiguration.new
8
+ end
9
+ end
@@ -1,13 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'spree/backend/config'
4
+
3
5
  module Spree
4
6
  module Backend
5
7
  class Engine < ::Rails::Engine
6
8
  config.middleware.use "Spree::Backend::Middleware::SeoAssist"
7
9
 
8
- initializer "spree.backend.environment", before: :load_config_initializers do |_app|
9
- Spree::Backend::Config = Spree::BackendConfiguration.new
10
- end
10
+ # Leave initializer empty for backwards-compatability. Other apps
11
+ # might still rely on this event.
12
+ initializer "spree.backend.environment", before: :load_config_initializers do; end
11
13
  end
12
14
  end
13
15
  end
@@ -1,8 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'spree/preferences/configuration'
4
+
3
5
  module Spree
4
6
  class BackendConfiguration < Preferences::Configuration
5
- preference :locale, :string, default: Rails.application.config.i18n.default_locale
7
+ preference :locale, :string, default: I18n.default_locale
6
8
 
7
9
  ORDER_TABS ||= [:orders, :payments, :creditcard_payments,
8
10
  :shipments, :credit_cards, :return_authorizations,
@@ -29,6 +29,7 @@ Gem::Specification.new do |s|
29
29
  s.add_dependency 'jbuilder', '~> 2.8'
30
30
  s.add_dependency 'jquery-rails'
31
31
  s.add_dependency 'kaminari', '~> 1.1'
32
+ s.add_dependency 'responders'
32
33
  s.add_dependency 'sassc-rails'
33
34
 
34
35
  s.add_dependency 'autoprefixer-rails'
@@ -173,7 +173,7 @@ module Spree
173
173
 
174
174
  context "a return item has an inactive return authorization reason" do
175
175
  before(:each) do
176
- accepted_return_item.update_attributes(return_reason_id: inactive_rma_reason.id)
176
+ accepted_return_item.update(return_reason_id: inactive_rma_reason.id)
177
177
  end
178
178
 
179
179
  it "includes the inactive return authorization reason" do
@@ -61,7 +61,7 @@ describe Spree::Admin::Orders::CustomerDetailsController, type: :controller do
61
61
  before { allow(Spree::Order).to receive_message_chain(:includes, :find_by!) { order } }
62
62
 
63
63
  it "updates + progresses the order" do
64
- expect(order).to receive(:update_attributes) { true }
64
+ expect(order).to receive(:update) { true }
65
65
  expect(order).to receive(:next) { false }
66
66
  attributes = { order_id: order.number, order: { email: "" } }
67
67
  put :update, params: attributes
@@ -109,7 +109,7 @@ describe Spree::Admin::Orders::CustomerDetailsController, type: :controller do
109
109
 
110
110
  context "not false guest checkout param" do
111
111
  it "does not attempt to associate the user" do
112
- allow(order).to receive_messages(update_attributes: true,
112
+ allow(order).to receive_messages(update: true,
113
113
  next: false,
114
114
  refresh_shipment_rates: true)
115
115
 
@@ -193,7 +193,7 @@ describe Spree::Admin::StoreCreditsController do
193
193
  let(:updated_amount) { 300.0 }
194
194
 
195
195
  context "the store credit has been partially used" do
196
- before { store_credit.update_attributes(amount_used: 10.0) }
196
+ before { store_credit.update(amount_used: 10.0) }
197
197
 
198
198
  context "the new amount is greater than the used amount" do
199
199
  let(:updated_amount) { 11.0 }
@@ -117,7 +117,7 @@ describe "Customer Details", type: :feature, js: true do
117
117
  end
118
118
 
119
119
  it "should show validation errors" do
120
- order.update_attributes!(ship_address_id: nil)
120
+ order.update!(ship_address_id: nil)
121
121
  click_link "Customer"
122
122
  click_button "Update"
123
123
  expect(page).to have_content("Shipping address first name can't be blank")
@@ -157,7 +157,6 @@ describe "Customer Details", type: :feature, js: true do
157
157
  end
158
158
 
159
159
  it "sets default country when displaying form" do
160
- click_link "Cart"
161
160
  click_link "Customer"
162
161
  expect(page).to have_field("order_bill_address_attributes_country_id", with: brazil.id, visible: false)
163
162
  end
@@ -154,14 +154,14 @@ describe "New Order", type: :feature do
154
154
  click_on "Update"
155
155
 
156
156
  # Automatically redirected to Shipments page
157
- select2_search product.name, from: I18n.t('spree.name_or_sku')
158
-
159
- click_icon :plus
157
+ within '.no-objects-found' do
158
+ click_on "Cart"
159
+ end
160
160
 
161
- expect(page).to have_css('.stock-item')
161
+ add_line_item product.name
162
162
 
163
163
  click_on "Payments"
164
- click_on "Continue"
164
+ click_on "Update"
165
165
 
166
166
  within(".additional-info") do
167
167
  expect(page).to have_content("Confirm")
@@ -29,7 +29,7 @@ RSpec.describe 'New Refund creation', :js do
29
29
  fill_in 'refund_amount', with: amount
30
30
  select reason.name, from: 'Reason'
31
31
  click_button 'Refund'
32
- expect(find('input[type="submit"]')).to be_disabled
32
+ expect(page).to have_button('Refund', disabled: true)
33
33
  end
34
34
  end
35
35
  end
@@ -76,6 +76,19 @@ describe "Order Details", type: :feature, js: true do
76
76
  expect(page).to have_field('quantity')
77
77
  end
78
78
 
79
+ it "can remove all items with empty cart" do
80
+ expect(page).to have_content("spree t-shirt")
81
+
82
+ accept_confirm "Are you sure you want to delete this record?" do
83
+ click_on 'Empty Cart'
84
+ end
85
+
86
+ expect(page).not_to have_content("spree t-shirt")
87
+
88
+ # Should have a new item row
89
+ expect(page).to have_field('quantity')
90
+ end
91
+
79
92
  # Regression test for https://github.com/spree/spree/issues/3862
80
93
  it "can cancel removing an item from a shipment" do
81
94
  expect(page).to have_content("spree t-shirt")
@@ -278,8 +291,7 @@ describe "Order Details", type: :feature, js: true do
278
291
 
279
292
  context 'A shipment has shipped' do
280
293
  it 'should not show or let me back to the cart page, nor show the shipment edit buttons' do
281
- order = create(:order, state: 'payment')
282
- order.shipments.create!(stock_location_id: stock_location.id, state: 'shipped')
294
+ order = create(:shipped_order, state: 'payment', stock_location: stock_location)
283
295
 
284
296
  visit spree.cart_admin_order_path(order)
285
297
 
@@ -525,8 +537,6 @@ describe "Order Details", type: :feature, js: true do
525
537
  expect(page).not_to have_css('.delete-item')
526
538
  expect(page).not_to have_css('.split-item')
527
539
  expect(page).not_to have_css('.edit-tracking')
528
-
529
- expect(page).not_to have_css('#add-line-item')
530
540
  end
531
541
  end
532
542
 
@@ -26,13 +26,19 @@ describe "Product Display Order", type: :feature do
26
26
  visit spree.edit_admin_product_path(product)
27
27
 
28
28
  assert_selected_taxons([taxon_1])
29
-
30
29
  select2_search "Clothing", from: "Taxon"
31
30
  assert_selected_taxons([taxon_1, taxon_2])
32
31
 
32
+ # Without this line we have a flaky spec probably due to select2 not
33
+ # closing its fixed overlay correctly. Clicking anywhere in the page
34
+ # before submit apparently solves the issue.
35
+ find('.edit_product', visible: true, obscured: false).click
36
+
33
37
  click_button "Update"
34
38
 
35
- expect(find(".flash")).to have_text "Product \"#{product.name}\" has been successfully updated!"
39
+ within('.flash') do
40
+ expect(page).to have_content(%(Product "#{product.name}" has been successfully updated!))
41
+ end
36
42
  assert_selected_taxons([taxon_1, taxon_2])
37
43
  end
38
44
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_backend
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.9.6
4
+ version: 2.10.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Solidus Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-16 00:00:00.000000000 Z
11
+ date: 2019-09-19 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.9.6
19
+ version: 2.10.0.beta1
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.9.6
26
+ version: 2.10.0.beta1
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.9.6
33
+ version: 2.10.0.beta1
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.9.6
40
+ version: 2.10.0.beta1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: coffee-rails
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '1.1'
111
+ - !ruby/object:Gem::Dependency
112
+ name: responders
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: sassc-rails
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -234,7 +248,6 @@ files:
234
248
  - app/assets/javascripts/spree/backend/templates/taxons/_tree.hbs
235
249
  - app/assets/javascripts/spree/backend/templates/taxons/tree.hbs
236
250
  - app/assets/javascripts/spree/backend/templates/variants/autocomplete.hbs
237
- - app/assets/javascripts/spree/backend/templates/variants/autocomplete_stock.hbs
238
251
  - app/assets/javascripts/spree/backend/templates/variants/line_items_autocomplete_stock.hbs
239
252
  - app/assets/javascripts/spree/backend/templates/variants/split.hbs
240
253
  - app/assets/javascripts/spree/backend/translation.js
@@ -243,6 +256,7 @@ files:
243
256
  - app/assets/javascripts/spree/backend/variant_autocomplete.js
244
257
  - app/assets/javascripts/spree/backend/views/calculators/tiered.js
245
258
  - app/assets/javascripts/spree/backend/views/cart/add_line_item_button.js
259
+ - app/assets/javascripts/spree/backend/views/cart/empty_cart_button.js
246
260
  - app/assets/javascripts/spree/backend/views/cart/line_item_row.js
247
261
  - app/assets/javascripts/spree/backend/views/cart/line_item_table.js
248
262
  - app/assets/javascripts/spree/backend/views/images/upload_progress.js
@@ -290,7 +304,7 @@ files:
290
304
  - app/assets/stylesheets/spree/backend/globals/_deprecated_variables.scss
291
305
  - app/assets/stylesheets/spree/backend/globals/_deprecation.scss
292
306
  - app/assets/stylesheets/spree/backend/globals/_functions.scss
293
- - app/assets/stylesheets/spree/backend/globals/_mixins.css
307
+ - app/assets/stylesheets/spree/backend/globals/_mixins.scss
294
308
  - app/assets/stylesheets/spree/backend/globals/_variables.scss
295
309
  - app/assets/stylesheets/spree/backend/globals/_variables_override.scss
296
310
  - app/assets/stylesheets/spree/backend/globals/mixins/_caret.scss
@@ -391,7 +405,6 @@ files:
391
405
  - app/helpers/spree/admin/stock_movements_helper.rb
392
406
  - app/helpers/spree/admin/store_credit_events_helper.rb
393
407
  - app/helpers/spree/promotion_rules_helper.rb
394
- - app/models/spree/backend_configuration.rb
395
408
  - app/views/kaminari/solidus_admin/_first_page.html.erb
396
409
  - app/views/kaminari/solidus_admin/_gap.html.erb
397
410
  - app/views/kaminari/solidus_admin/_last_page.html.erb
@@ -431,7 +444,6 @@ files:
431
444
  - app/views/spree/admin/option_types/index.html.erb
432
445
  - app/views/spree/admin/option_types/new.html.erb
433
446
  - app/views/spree/admin/option_types/new.js.erb
434
- - app/views/spree/admin/orders/_add_product.html.erb
435
447
  - app/views/spree/admin/orders/_adjustments.html.erb
436
448
  - app/views/spree/admin/orders/_carton.html.erb
437
449
  - app/views/spree/admin/orders/_carton_manifest.html.erb
@@ -712,7 +724,9 @@ files:
712
724
  - lib/spree/backend.rb
713
725
  - lib/spree/backend/action_callbacks.rb
714
726
  - lib/spree/backend/callbacks.rb
727
+ - lib/spree/backend/config.rb
715
728
  - lib/spree/backend/engine.rb
729
+ - lib/spree/backend_configuration.rb
716
730
  - lib/spree_backend.rb
717
731
  - script/rails
718
732
  - solidus_backend.gemspec
@@ -811,8 +825,8 @@ files:
811
825
  - spec/javascripts/support/with_translations.js
812
826
  - spec/javascripts/translation_spec.js
813
827
  - spec/javascripts/views/number_with_currency_spec.js
814
- - spec/models/spree/backend_configuration/menu_item_spec.rb
815
- - spec/models/spree/backend_configuration_spec.rb
828
+ - spec/lib/spree/backend_configuration/menu_item_spec.rb
829
+ - spec/lib/spree/backend_configuration_spec.rb
816
830
  - spec/spec_helper.rb
817
831
  - spec/support/appear_before_matcher.rb
818
832
  - spec/support/feature/base_feature_helper.rb
@@ -995,7 +1009,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
995
1009
  version: 1.8.23
996
1010
  requirements:
997
1011
  - none
998
- rubygems_version: 3.0.3
1012
+ rubygems_version: 3.0.6
999
1013
  signing_key:
1000
1014
  specification_version: 4
1001
1015
  summary: Admin interface for the Solidus e-commerce framework.
@@ -1,56 +0,0 @@
1
- <fieldset class="no-border-bottom">
2
- <legend align="center">{{ t "select_stock" }}</legend>
3
- <table class="stock-levels" data-hook="stock-levels">
4
- <colgroup>
5
- <col style="width: 30%;" />
6
- <col style="width: 40%;" />
7
- <col style="width: 20%;" />
8
- <col style="width: 10%;" />
9
- </colgroup>
10
- <thead>
11
- <th>{{ t "location" }}</th>
12
- <th>{{ t "count_on_hand" }}</th>
13
- <th>{{ t "quantity" }}</th>
14
- <th class="actions"></th>
15
- </thead>
16
- <tbody>
17
- {{#each variant.stock_items}}
18
- <tr class="vertical-middle">
19
- <td>{{this.stock_location_name}}</td>
20
- {{#unless ../variant.track_inventory}}
21
- <td>
22
- It doesn't track inventory
23
- </td>
24
- <td>
25
- <form>
26
- <input class="quantity" id="stock_item_quantity" data-stock-location-id="{{this.stock_location_id}}" type="number" min="1" value="1">
27
- </form>
28
- </td>
29
- <td class="actions">
30
- <button class="add_variant no-text fa fa-plus icon_link with-tip" data-stock-location-id="{{this.stock_location_id}}" title="{{ t "add" }}" data-action="add"></button>
31
- </td>
32
- {{else}}
33
- {{#if this.available}}
34
- <td>
35
- {{this.count_on_hand}}
36
- {{#if this.backorderable}} ({{ t "backorders_allowed" }}) {{/if}}
37
- </td>
38
- <td>
39
- <form>
40
- <input class="quantity" id="stock_item_quantity" data-stock-location-id="{{this.stock_location_id}}" type="number" min="1" value="1">
41
- </form>
42
- </td>
43
- <td class="actions">
44
- <button class="add_variant no-text fa fa-plus icon_link with-tip" data-stock-location-id="{{this.stock_location_id}}" title="{{ t "add" }}" data-action="add"></button>
45
- </td>
46
- {{else}}
47
- <td>{{ t "out_of_stock" }}</td>
48
- <td>0</td>
49
- <td></td>
50
- {{/if}}
51
- {{/unless}}
52
- </tr>
53
- {{/each}}
54
- </tbody>
55
- </table>
56
- </fieldset>
@@ -1,12 +0,0 @@
1
- <div id="add-line-item" class="js-shipment-add-variant" data-hook>
2
- <fieldset class="no-border-bottom">
3
- <legend align="center"><%= t('spree.add_product') %></legend>
4
-
5
- <div data-hook="add_product_name" class="field">
6
- <%= label_tag :add_variant_id, t('spree.name_or_sku') %>
7
- <%= text_field_tag :add_variant_id, "", class: "variant_autocomplete fullwidth" %>
8
- </div>
9
- </fieldset>
10
-
11
- <div id="stock_details"></div>
12
- </div>