solidus_backend 2.9.5 → 2.10.2

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 (99) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/spree/backend.js +1 -0
  3. data/app/assets/javascripts/spree/backend/components/admin_nav.js +24 -0
  4. data/app/assets/javascripts/spree/backend/components/tabs.js +1 -1
  5. data/app/assets/javascripts/spree/backend/models/order.js +9 -0
  6. data/app/assets/javascripts/spree/backend/orders/cart.js +6 -0
  7. data/app/assets/javascripts/spree/backend/shipments.js +0 -62
  8. data/app/assets/javascripts/spree/backend/templates/index.js +0 -1
  9. data/app/assets/javascripts/spree/backend/views/cart/empty_cart_button.js +29 -0
  10. data/app/assets/javascripts/spree/backend/views/cart/line_item_table.js +5 -0
  11. data/app/assets/javascripts/spree/backend/views/index.js +1 -0
  12. data/app/assets/javascripts/spree/backend/views/order/address.js +7 -5
  13. data/app/assets/stylesheets/spree/backend/_bootstrap_custom.scss +2 -0
  14. data/app/assets/stylesheets/spree/backend/components/_breadcrumb.scss +3 -3
  15. data/app/assets/stylesheets/spree/backend/components/_messages.scss +4 -0
  16. data/app/assets/stylesheets/spree/backend/components/_navigation.scss +182 -49
  17. data/app/assets/stylesheets/spree/backend/globals/{_mixins.css → _mixins.scss} +0 -0
  18. data/app/assets/stylesheets/spree/backend/globals/_variables.scss +2 -0
  19. data/app/assets/stylesheets/spree/backend/shared/_header.scss +5 -1
  20. data/app/assets/stylesheets/spree/backend/shared/_layout.scss +0 -9
  21. data/app/controllers/spree/admin/adjustments_controller.rb +1 -1
  22. data/app/controllers/spree/admin/base_controller.rb +1 -1
  23. data/app/controllers/spree/admin/orders_controller.rb +2 -2
  24. data/app/controllers/spree/admin/payment_methods_controller.rb +4 -4
  25. data/app/controllers/spree/admin/payments_controller.rb +2 -2
  26. data/app/controllers/spree/admin/product_properties_controller.rb +1 -1
  27. data/app/controllers/spree/admin/products_controller.rb +2 -2
  28. data/app/controllers/spree/admin/resource_controller.rb +13 -4
  29. data/app/controllers/spree/admin/style_guide_controller.rb +1 -1
  30. data/app/controllers/spree/admin/taxons/attachment_controller.rb +20 -0
  31. data/app/controllers/spree/admin/users_controller.rb +6 -2
  32. data/app/helpers/spree/admin/navigation_helper.rb +3 -2
  33. data/app/helpers/spree/promotion_rules_helper.rb +1 -1
  34. data/app/views/spree/admin/customer_returns/new.html.erb +1 -1
  35. data/app/views/spree/admin/option_types/edit.html.erb +1 -1
  36. data/app/views/spree/admin/orders/_line_items_edit_form.html.erb +1 -0
  37. data/app/views/spree/admin/orders/edit.html.erb +3 -4
  38. data/app/views/spree/admin/payment_methods/new.html.erb +1 -1
  39. data/app/views/spree/admin/prices/_master_variant_table.html.erb +41 -41
  40. data/app/views/spree/admin/promotion_code_batches/new.html.erb +1 -1
  41. data/app/views/spree/admin/promotion_codes/new.html.erb +1 -1
  42. data/app/views/spree/admin/promotions/_actions.html.erb +1 -0
  43. data/app/views/spree/admin/promotions/index.html.erb +1 -1
  44. data/app/views/spree/admin/return_authorizations/new.html.erb +1 -1
  45. data/app/views/spree/admin/shared/_calculator_fields.html.erb +5 -0
  46. data/app/views/spree/admin/shared/_navigation.html.erb +3 -0
  47. data/app/views/spree/admin/shared/_new_resource_links.html.erb +1 -1
  48. data/app/views/spree/admin/shared/_order_submenu.html.erb +2 -2
  49. data/app/views/spree/admin/shared/_settings_sub_menu.html.erb +1 -1
  50. data/app/views/spree/admin/shipping_methods/_form.html.erb +1 -1
  51. data/app/views/spree/admin/stock_locations/index.html.erb +1 -1
  52. data/app/views/spree/admin/store_credit_reasons/index.html.erb +1 -1
  53. data/app/views/spree/admin/store_credits/index.html.erb +1 -1
  54. data/app/views/spree/admin/tax_rates/_form.html.erb +1 -1
  55. data/app/views/spree/admin/taxonomies/new.html.erb +1 -1
  56. data/app/views/spree/admin/taxons/_form.html.erb +1 -5
  57. data/app/views/spree/admin/taxons/attachment_forms/_paperclip.html.erb +16 -0
  58. data/app/views/spree/admin/users/_form.html.erb +12 -10
  59. data/app/views/spree/admin/users/_tabs.html.erb +1 -1
  60. data/app/views/spree/admin/users/edit.html.erb +1 -2
  61. data/app/views/spree/layouts/admin.html.erb +1 -2
  62. data/config/routes.rb +4 -6
  63. data/lib/spree/backend.rb +1 -0
  64. data/lib/spree/backend/config.rb +9 -0
  65. data/lib/spree/backend/engine.rb +5 -3
  66. data/{app/models → lib}/spree/backend_configuration.rb +5 -2
  67. data/solidus_backend.gemspec +2 -1
  68. data/spec/controllers/spree/admin/customer_returns_controller_spec.rb +1 -1
  69. data/spec/controllers/spree/admin/orders/customer_details_controller_spec.rb +2 -2
  70. data/spec/controllers/spree/admin/resource_controller_spec.rb +12 -1
  71. data/spec/controllers/spree/admin/store_credits_controller_spec.rb +1 -1
  72. data/spec/controllers/spree/admin/users_controller_spec.rb +23 -0
  73. data/spec/features/admin/configuration/payment_methods_spec.rb +11 -2
  74. data/spec/features/admin/configuration/shipping_methods_spec.rb +13 -1
  75. data/spec/features/admin/configuration/taxonomies_spec.rb +7 -0
  76. data/spec/features/admin/orders/customer_details_spec.rb +1 -2
  77. data/spec/features/admin/orders/customer_returns_spec.rb +20 -7
  78. data/spec/features/admin/orders/new_order_spec.rb +53 -5
  79. data/spec/features/admin/orders/new_refund_spec.rb +1 -1
  80. data/spec/features/admin/orders/order_details_spec.rb +14 -4
  81. data/spec/features/admin/orders/return_authorizations_spec.rb +38 -9
  82. data/spec/features/admin/products/edit/images_spec.rb +1 -1
  83. data/spec/features/admin/products/edit/taxons_spec.rb +8 -2
  84. data/spec/features/admin/products/products_spec.rb +12 -0
  85. data/spec/features/admin/promotion_adjustments_spec.rb +9 -0
  86. data/spec/features/admin/promotions/promotion_code_batches_spec.rb +37 -0
  87. data/spec/features/admin/promotions/promotion_code_spec.rb +31 -0
  88. data/spec/features/admin/taxons_spec.rb +12 -0
  89. data/spec/features/admin/users_spec.rb +18 -8
  90. data/spec/{support → fixtures/files}/ror_ringer.jpeg +0 -0
  91. data/spec/{models → lib}/spree/backend_configuration/menu_item_spec.rb +0 -0
  92. data/spec/{models → lib}/spree/backend_configuration_spec.rb +0 -0
  93. data/spec/spec_helper.rb +1 -0
  94. data/spec/support/feature/base_feature_helper.rb +6 -1
  95. data/spec/teaspoon_env.rb +8 -23
  96. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_variables.scss +1 -1
  97. metadata +33 -14
  98. data/app/assets/javascripts/spree/backend/templates/variants/autocomplete_stock.hbs +0 -56
  99. data/app/views/spree/admin/orders/_add_product.html.erb +0 -12
@@ -4,6 +4,11 @@
4
4
  <div id="preference-settings">
5
5
  <div class="field">
6
6
  <%= f.label(:calculator_type, Spree::Calculator.model_name.human) %>
7
+
8
+ <% if local_assigns.has_key? :hint %>
9
+ <%= admin_hint t("spree.#{hint}"), t(hint, scope: [:spree, :hints, "spree/calculator"]) %>
10
+ <% end %>
11
+
7
12
  <%= f.select(:calculator_type, @calculators.map { |c| [c.description, c.name] }, {}, {class: 'custom-select fullwidth js-calculator-type'}) %>
8
13
  </div>
9
14
 
@@ -3,6 +3,9 @@
3
3
  <div class="admin-nav-sticky">
4
4
  <%= render partial: 'spree/admin/shared/menu' %>
5
5
  <div class="admin-nav-footer">
6
+ <%= button_tag class: 'btn fa fa-chevron-circle-left', id: 'admin-nav-toggle', type: :button do %>
7
+ <span class="text"><%= t('spree.minimize_menu') %></span>
8
+ <% end %>
6
9
  <%= render partial: 'spree/admin/shared/locale_selection' %>
7
10
  <%= render partial: 'spree/admin/shared/navigation_footer' %>
8
11
  </div>
@@ -1,4 +1,4 @@
1
1
  <div class="form-buttons filter-actions actions" data-hook="buttons">
2
- <%= button_tag t('spree.actions.create'), class: 'btn btn-primary' %>
2
+ <%= submit_tag t('spree.actions.create'), class: 'btn btn-primary' %>
3
3
  <%= link_to t('spree.actions.cancel'), collection_url, class: 'button' %>
4
4
  </div>
@@ -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>
@@ -13,7 +13,7 @@
13
13
 
14
14
  <% if can?(:display, Spree::RefundReason) || can?(:display, Spree::ReimbursementType) ||
15
15
  can?(:display, Spree::ReturnReason) || can?(:display, Spree::AdjustmentReason) %>
16
- <%= tab :checkout, url: spree.admin_refund_reasons_path, match_path: %r(refund_reasons|reimbursement_types|return_reasons|adjustment_reasons) %>
16
+ <%= tab :checkout, url: spree.admin_refund_reasons_path, match_path: %r(refund_reasons|reimbursement_types|return_reasons|adjustment_reasons|store_credit_reasons) %>
17
17
  <% end %>
18
18
 
19
19
  <% if can?(:display, Spree::ShippingMethod) || can?(:display, Spree::ShippingCategory) || can?(:display, Spree::StockLocation) %>
@@ -100,7 +100,7 @@
100
100
  </div>
101
101
  <div class="col-5">
102
102
  <div data-hook="admin_shipping_method_form_calculator_fields">
103
- <%= render partial: 'spree/admin/shared/calculator_fields', locals: { f: f } %>
103
+ <%= render partial: 'spree/admin/shared/calculator_fields', locals: { f: f, hint: :shipping_methods } %>
104
104
  </div>
105
105
  <div>
106
106
  <fieldset class="tax_categories no-border-bottom">
@@ -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 %>
@@ -58,5 +58,5 @@
58
58
 
59
59
  <div class="clear"></div>
60
60
 
61
- <%= render 'spree/admin/shared/calculator_fields', f: f %>
61
+ <%= render partial: 'spree/admin/shared/calculator_fields', locals: { f: f, hint: :tax_rates } %>
62
62
  </div>
@@ -12,7 +12,7 @@
12
12
  <fieldset class="no-border-top">
13
13
  <br>
14
14
  <div class="filter-actions actions" data-hook="buttons">
15
- <%= button_tag t('spree.actions.create'), class: 'btn btn-primary' %>
15
+ <%= f.submit t('spree.actions.create'), class: 'btn btn-primary' %>
16
16
  </div>
17
17
  </fieldset>
18
18
  <% end %>
@@ -20,11 +20,7 @@
20
20
  </div>
21
21
  <% end %>
22
22
 
23
- <%= f.field_container :icon do %>
24
- <%= f.label :icon %><br />
25
- <%= f.file_field :icon %>
26
- <%= image_tag f.object.icon(:mini) if f.object.icon_present? %>
27
- <% end %>
23
+ <%= render "spree/admin/taxons/attachment_forms/#{f.object.attachment_partial_name}", f: f %>
28
24
  </div>
29
25
 
30
26
  <div class="col-5">
@@ -0,0 +1,16 @@
1
+ <% f.object.class.attachment_definitions.each do |attachment, definition| %>
2
+ <%= f.field_container attachment do %>
3
+ <%= f.label attachment %><br>
4
+ <%= f.file_field attachment %>
5
+ <% if f.object.send(attachment).exists? %>
6
+ <%= image_tag f.object.send(attachment, definition[:default_style]) %>
7
+ <%= link_to t('spree.actions.remove'),
8
+ admin_taxonomy_taxon_attachment_path(@taxonomy,
9
+ @taxon.id,
10
+ attachment_definition: attachment,
11
+ authenticity_token: form_authenticity_token),
12
+ method: :delete,
13
+ class: 'btn btn-sm btn-danger' %>
14
+ <% end %>
15
+ <% end %>
16
+ <% end %>
@@ -60,18 +60,20 @@
60
60
  </div>
61
61
 
62
62
  <div data-hook="admin_user_form_password_fields" class="col-6">
63
- <%= f.field_container :password do %>
64
- <%= f.label :password %>
65
- <%= f.password_field :password, class: 'fullwidth' %>
66
- <%= f.error_message_on :password %>
67
- <% end %>
63
+ <% if can? :update_password, @user %>
64
+ <%= f.field_container :password do %>
65
+ <%= f.label :password %>
66
+ <%= f.password_field :password, class: 'fullwidth' %>
67
+ <%= f.error_message_on :password %>
68
+ <% end %>
68
69
 
69
70
 
70
- <% if f.object.respond_to?(:password_confirmation) %>
71
- <%= f.field_container :password do %>
72
- <%= f.label :password_confirmation %>
73
- <%= f.password_field :password_confirmation, class: 'fullwidth' %>
74
- <%= f.error_message_on :password_confirmation %>
71
+ <% if f.object.respond_to?(:password_confirmation) %>
72
+ <%= f.field_container :password do %>
73
+ <%= f.label :password_confirmation %>
74
+ <%= f.password_field :password_confirmation, class: 'fullwidth' %>
75
+ <%= f.error_message_on :password_confirmation %>
76
+ <% end %>
75
77
  <% end %>
76
78
  <% end %>
77
79
  </div>
@@ -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>
@@ -1,6 +1,5 @@
1
1
  <% admin_breadcrumb(link_to plural_resource_name(Spree::LegacyUser), spree.admin_users_path) %>
2
- <% admin_breadcrumb(@user.email) %>
3
-
2
+ <% admin_breadcrumb(@user.valid? ? @user.email : @user.email_was) %>
4
3
 
5
4
  <%= render 'spree/admin/users/sidebar' %>
6
5
  <%= render 'spree/admin/users/tabs', current: :account %>
@@ -3,8 +3,7 @@
3
3
  <head data-hook="admin_inside_head">
4
4
  <%= render 'spree/admin/shared/head' %>
5
5
  </head>
6
-
7
- <body class="admin">
6
+ <body class="admin <%= "admin-nav-hidden" if cookies[:admin_nav_hidden] == "true" %>">
8
7
  <%= render "spree/admin/shared/navigation" %>
9
8
  <%= render "spree/admin/shared/header" %>
10
9
  <%= render "spree/admin/shared/flash" %>
@@ -66,11 +66,7 @@ Spree::Core::Engine.routes.draw do
66
66
 
67
67
  delete '/option_values/:id', to: "option_values#destroy", as: :option_value
68
68
 
69
- resources :properties do
70
- collection do
71
- get :filtered
72
- end
73
- end
69
+ resources :properties
74
70
 
75
71
  delete '/product_properties/:id', to: "product_properties#destroy", as: :product_property
76
72
 
@@ -132,7 +128,9 @@ Spree::Core::Engine.routes.draw do
132
128
  collection do
133
129
  post :update_positions
134
130
  end
135
- resources :taxons
131
+ resources :taxons do
132
+ resource :attachment, controller: 'taxons/attachment', only: [:destroy]
133
+ end
136
134
  end
137
135
 
138
136
  resources :taxons, only: [:index, :show] do
@@ -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,
@@ -15,7 +17,8 @@ module Spree
15
17
  :payment_methods, :shipping_methods,
16
18
  :shipping_categories, :stock_locations,
17
19
  :refund_reasons, :reimbursement_types,
18
- :return_reasons, :adjustment_reasons]
20
+ :return_reasons, :adjustment_reasons,
21
+ :store_credit_reasons]
19
22
  PROMOTION_TABS ||= [:promotions, :promotion_categories]
20
23
  STOCK_TABS ||= [:stock_items]
21
24
  USER_TABS ||= [:users, :store_credits]
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
18
18
  s.require_path = 'lib'
19
19
  s.requirements << 'none'
20
20
 
21
- s.required_ruby_version = '>= 2.2.2'
21
+ s.required_ruby_version = '>= 2.4.0'
22
22
  s.required_rubygems_version = '>= 1.8.23'
23
23
 
24
24
  s.add_dependency 'solidus_api', s.version
@@ -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
 
@@ -37,6 +37,7 @@ describe Spree::Admin::WidgetsController, type: :controller do
37
37
  def check_destroy_constraints
38
38
  return unless name == 'undestroyable'
39
39
  errors.add :base, "You can't destroy undestroyable things!"
40
+ errors.add :base, "Terrible things might happen."
40
41
  throw(:abort)
41
42
  end
42
43
  end
@@ -164,7 +165,17 @@ describe Spree::Admin::WidgetsController, type: :controller do
164
165
  it 'responds with error message' do
165
166
  subject
166
167
  expect(response).to be_unprocessable
167
- expect(response.body).to eq assigns(:widget).errors.full_messages.join(', ')
168
+ expect(response.body).to eq assigns(:widget).errors.full_messages.to_sentence
169
+ end
170
+ end
171
+
172
+ context 'html format' do
173
+ subject { delete :destroy, params: params }
174
+
175
+ it 'responds with error message' do
176
+ subject
177
+ expect(response).to be_redirect
178
+ expect(flash[:error]).to eq assigns(:widget).errors.full_messages.to_sentence
168
179
  end
169
180
  end
170
181
  end
@@ -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 }
@@ -202,6 +202,29 @@ describe Spree::Admin::UsersController, type: :controller do
202
202
  end
203
203
  end
204
204
 
205
+ context "allowed to update passwords" do
206
+ it "can change password of a user" do
207
+ expect {
208
+ put :update, params: { id: user.id, user: { password: "diff123", password_confirmation: "diff123" } }
209
+ }.to_not raise_error
210
+ end
211
+ end
212
+
213
+ context "not allowed to update passwords" do
214
+ stub_authorization! do |_user|
215
+ can [:admin, :update], Spree.user_class
216
+ end
217
+
218
+ it "cannot change password of a user" do
219
+ allow(ActionController::Parameters).
220
+ to receive(:action_on_unpermitted_parameters).and_return(:raise)
221
+
222
+ expect {
223
+ put :update, params: { id: user.id, user: { password: "diff123", password_confirmation: "diff123" } }
224
+ }.to raise_error(ActionController::UnpermittedParameters)
225
+ end
226
+ end
227
+
205
228
  it "can update ship_address attributes" do
206
229
  post :update, params: { id: user.id, user: { ship_address_attributes: valid_address_attributes } }
207
230
  expect(user.reload.ship_address.city).to eq('New York')
@@ -32,8 +32,8 @@ describe "Payment Methods", type: :feature do
32
32
  end
33
33
  end
34
34
 
35
- context "admin creating a new payment method" do
36
- it "should be able to create a new payment method" do
35
+ context "admin creating a new payment method", :js do
36
+ it "creates a new payment method and disables the form" do
37
37
  click_link "Payments"
38
38
  expect(page).to have_link 'Payment Methods'
39
39
  click_link "admin_new_payment_methods_link"
@@ -43,6 +43,15 @@ describe "Payment Methods", type: :feature do
43
43
  select Spree::PaymentMethod::Check.model_name.human, from: "Type"
44
44
  click_button "Create"
45
45
  expect(page).to have_content("successfully created!")
46
+
47
+ visit spree.new_admin_payment_method_path
48
+ page.execute_script "$('form').submit(function(e) { e.preventDefault()})"
49
+ fill_in "payment_method_name", with: "check90"
50
+ fill_in "payment_method_description", with: "check90 desc"
51
+ select Spree::PaymentMethod::Check.model_name.human, from: "Type"
52
+ click_button "Create"
53
+
54
+ expect(page).to have_button("Create", disabled: true)
46
55
  end
47
56
  end
48
57
 
@@ -25,7 +25,7 @@ describe "Shipping Methods", type: :feature do
25
25
  end
26
26
 
27
27
  context "create", js: true do
28
- it "should be able to create a new shipping method" do
28
+ it "creates a new shipping method and disables the submit button", :js do
29
29
  click_link "New Shipping Method"
30
30
 
31
31
  fill_in "shipping_method_name", with: "bullock cart"
@@ -36,6 +36,18 @@ describe "Shipping Methods", type: :feature do
36
36
 
37
37
  click_on "Create"
38
38
  expect(current_path).to eql(spree.edit_admin_shipping_method_path(Spree::ShippingMethod.last))
39
+
40
+ visit spree.new_admin_shipping_method_path
41
+ page.execute_script "$('form').submit(function(e) { e.preventDefault()})"
42
+ fill_in "shipping_method_name", with: "bullock cart"
43
+
44
+ within("#shipping_method_categories_field") do
45
+ check first("input[type='checkbox']")["name"]
46
+ end
47
+
48
+ click_on "Create"
49
+
50
+ expect(page).to have_button("Create", disabled: true)
39
51
  end
40
52
 
41
53
  context 'with shipping method having a calculator with array or hash preference type' do