solidus_backend 2.2.2 → 2.3.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 (186) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/spree/backend.js +1 -2
  3. data/app/assets/javascripts/spree/backend/address_states.js +1 -1
  4. data/app/assets/javascripts/spree/backend/adjustments.js.coffee +1 -1
  5. data/app/assets/javascripts/spree/backend/admin.js +37 -41
  6. data/app/assets/javascripts/spree/backend/components/editable_table.js.coffee +3 -0
  7. data/app/assets/javascripts/spree/backend/images/index.js.coffee +1 -1
  8. data/app/assets/javascripts/spree/backend/images/upload.js +13 -189
  9. data/app/assets/javascripts/spree/backend/models/image_upload.js +76 -0
  10. data/app/assets/javascripts/spree/backend/models/index.js +2 -0
  11. data/app/assets/javascripts/spree/backend/models/taxonomy.js +3 -0
  12. data/app/assets/javascripts/spree/backend/namespaces.js +3 -1
  13. data/app/assets/javascripts/spree/backend/payments/new.js +8 -36
  14. data/app/assets/javascripts/spree/backend/promotions.js.coffee +1 -1
  15. data/app/assets/javascripts/spree/backend/select_payments.js.coffee +0 -12
  16. data/app/assets/javascripts/spree/backend/shipments.js +1 -1
  17. data/app/assets/javascripts/spree/backend/spree-select2.js +1 -1
  18. data/app/assets/javascripts/spree/backend/taxonomy.js.coffee +101 -95
  19. data/app/assets/javascripts/spree/backend/templates/products/upload_progress.hbs +5 -3
  20. data/app/assets/javascripts/spree/backend/views/images/upload_progress.js +48 -0
  21. data/app/assets/javascripts/spree/backend/views/images/upload_zone.js +39 -0
  22. data/app/assets/javascripts/spree/backend/views/index.js +6 -0
  23. data/app/assets/javascripts/spree/backend/views/order/address.js +1 -5
  24. data/app/assets/javascripts/spree/backend/views/payment/edit_credit_card.js +23 -0
  25. data/app/assets/javascripts/spree/backend/views/payment/new.js +25 -0
  26. data/app/assets/javascripts/spree/backend/views/state_select.js +4 -4
  27. data/app/assets/javascripts/spree/backend/views/tables/editable_table.js.coffee +14 -0
  28. data/app/assets/javascripts/spree/backend/views/tables/editable_table_row.js.coffee +45 -0
  29. data/app/assets/stylesheets/spree/backend/components/_date-picker.scss +0 -1
  30. data/app/assets/stylesheets/spree/backend/components/_editable_table.scss +37 -0
  31. data/app/assets/stylesheets/spree/backend/plugins/_bootstrap_tooltip.scss +2 -2
  32. data/app/assets/stylesheets/spree/backend/sections/_products.scss +0 -8
  33. data/app/assets/stylesheets/spree/backend/sections/_style_guide.scss +15 -9
  34. data/app/assets/stylesheets/spree/backend/shared/_icons.scss +14 -14
  35. data/app/assets/stylesheets/spree/backend/shared/_tables.scss +1 -2
  36. data/app/assets/stylesheets/spree/backend/shared/_utilities.scss +13 -0
  37. data/app/assets/stylesheets/spree/backend/spree_admin.scss +1 -1
  38. data/app/controllers/spree/admin/cancellations_controller.rb +1 -1
  39. data/app/controllers/spree/admin/orders/customer_details_controller.rb +1 -1
  40. data/app/controllers/spree/admin/orders_controller.rb +3 -10
  41. data/app/controllers/spree/admin/payment_methods_controller.rb +19 -6
  42. data/app/controllers/spree/admin/payments_controller.rb +2 -2
  43. data/app/controllers/spree/admin/products_controller.rb +3 -9
  44. data/app/controllers/spree/admin/promotion_rules_controller.rb +5 -1
  45. data/app/controllers/spree/admin/promotions_controller.rb +1 -1
  46. data/app/controllers/spree/admin/properties_controller.rb +1 -1
  47. data/app/controllers/spree/admin/reports_controller.rb +24 -21
  48. data/app/controllers/spree/admin/resource_controller.rb +25 -14
  49. data/app/controllers/spree/admin/style_guide_controller.rb +4 -0
  50. data/app/controllers/spree/admin/users_controller.rb +1 -1
  51. data/app/controllers/spree/admin/variants_controller.rb +5 -0
  52. data/app/helpers/spree/admin/navigation_helper.rb +6 -2
  53. data/app/helpers/spree/promotion_rules_helper.rb +2 -2
  54. data/app/models/spree/backend_configuration.rb +1 -0
  55. data/app/views/spree/admin/adjustments/_form.html.erb +1 -1
  56. data/app/views/spree/admin/customer_returns/_return_item_selection.html.erb +2 -2
  57. data/app/views/spree/admin/customer_returns/new.html.erb +1 -1
  58. data/app/views/spree/admin/images/_form.html.erb +1 -1
  59. data/app/views/spree/admin/images/_image_row.html.erb +22 -4
  60. data/app/views/spree/admin/images/create.js.erb +8 -5
  61. data/app/views/spree/admin/images/index.html.erb +4 -8
  62. data/app/views/spree/admin/orders/_risk_analysis.html.erb +6 -7
  63. data/app/views/spree/admin/orders/_shipment.html.erb +1 -1
  64. data/app/views/spree/admin/orders/confirm/_customer_details.html.erb +1 -1
  65. data/app/views/spree/admin/orders/confirm/_payments.html.erb +1 -1
  66. data/app/views/spree/admin/orders/index.html.erb +3 -3
  67. data/app/views/spree/admin/payment_methods/_form.html.erb +5 -5
  68. data/app/views/spree/admin/payments/_form.html.erb +2 -2
  69. data/app/views/spree/admin/payments/_list.html.erb +1 -1
  70. data/app/views/spree/admin/payments/show.html.erb +1 -1
  71. data/app/views/spree/admin/payments/source_forms/_gateway.html.erb +2 -7
  72. data/app/views/spree/admin/prices/_form.html.erb +2 -2
  73. data/app/views/spree/admin/prices/edit.html.erb +2 -0
  74. data/app/views/spree/admin/prices/index.html.erb +5 -4
  75. data/app/views/spree/admin/prices/new.html.erb +4 -0
  76. data/app/views/spree/admin/product_properties/index.html.erb +1 -1
  77. data/app/views/spree/admin/products/_form.html.erb +4 -3
  78. data/app/views/spree/admin/products/index.html.erb +3 -3
  79. data/app/views/spree/admin/products/new.html.erb +2 -2
  80. data/app/views/spree/admin/products/new.js.erb +0 -3
  81. data/app/views/spree/admin/promotion_actions/create.js.erb +2 -6
  82. data/app/views/spree/admin/promotion_rules/create.js.erb +0 -8
  83. data/app/views/spree/admin/promotions/_actions.html.erb +2 -2
  84. data/app/views/spree/admin/promotions/_form.html.erb +1 -1
  85. data/app/views/spree/admin/promotions/_promotion_action.html.erb +3 -4
  86. data/app/views/spree/admin/promotions/_promotion_rule.html.erb +3 -3
  87. data/app/views/spree/admin/promotions/_rules.html.erb +1 -1
  88. data/app/views/spree/admin/promotions/actions/_create_item_adjustments.html.erb +6 -2
  89. data/app/views/spree/admin/promotions/actions/_promotion_calculators_with_custom_fields.html.erb +1 -1
  90. data/app/views/spree/admin/promotions/calculators/distributed_amount/_fields.html.erb +54 -0
  91. data/app/views/spree/admin/promotions/calculators/tiered_flat_rate/_fields.html.erb +33 -14
  92. data/app/views/spree/admin/promotions/calculators/tiered_percent/_fields.html.erb +33 -14
  93. data/app/views/spree/admin/promotions/index.html.erb +1 -1
  94. data/app/views/spree/admin/promotions/rules/_first_repeat_purchase_since.html.erb +1 -1
  95. data/app/views/spree/admin/promotions/rules/_item_total.html.erb +1 -1
  96. data/app/views/spree/admin/promotions/rules/_landing_page.html.erb +1 -1
  97. data/app/views/spree/admin/promotions/rules/_nth_order.html.erb +1 -1
  98. data/app/views/spree/admin/promotions/rules/_product.html.erb +1 -1
  99. data/app/views/spree/admin/promotions/rules/_taxon.html.erb +1 -1
  100. data/app/views/spree/admin/promotions/rules/_user_role.html.erb +2 -2
  101. data/app/views/spree/admin/refunds/edit.html.erb +1 -1
  102. data/app/views/spree/admin/refunds/new.html.erb +1 -1
  103. data/app/views/spree/admin/reimbursements/edit.html.erb +2 -2
  104. data/app/views/spree/admin/reports/sales_total.html.erb +1 -1
  105. data/app/views/spree/admin/return_authorizations/_form.html.erb +4 -4
  106. data/app/views/spree/admin/shared/_address_form.html.erb +2 -2
  107. data/app/views/spree/admin/shared/_calculator_fields.html.erb +1 -1
  108. data/app/views/spree/admin/shared/_product_tabs.html.erb +4 -4
  109. data/app/views/spree/admin/shared/_report_order_criteria.html.erb +1 -1
  110. data/app/views/spree/admin/shared/_variant_search.html.erb +1 -1
  111. data/app/views/spree/admin/shipping_methods/_form.html.erb +1 -1
  112. data/app/views/spree/admin/states/index.html.erb +1 -1
  113. data/app/views/spree/admin/stock_items/_stock_management.html.erb +1 -1
  114. data/app/views/spree/admin/stock_locations/_form.html.erb +1 -1
  115. data/app/views/spree/admin/stock_transfers/edit.html.erb +1 -1
  116. data/app/views/spree/admin/stock_transfers/index.html.erb +1 -1
  117. data/app/views/spree/admin/stock_transfers/new.html.erb +1 -1
  118. data/app/views/spree/admin/store_credits/_form.html.erb +1 -1
  119. data/app/views/spree/admin/store_credits/_update_reason_field.html.erb +1 -1
  120. data/app/views/spree/admin/stores/_form.html.erb +1 -1
  121. data/app/views/spree/admin/style_guide/topics/forms/_building_forms.html.erb +4 -8
  122. data/app/views/spree/admin/style_guide/topics/forms/_buttons.html.erb +6 -0
  123. data/app/views/spree/admin/style_guide/topics/forms/_helper_text.html.erb +13 -0
  124. data/app/views/spree/admin/style_guide/topics/forms/_inputs.html.erb +96 -0
  125. data/app/views/spree/admin/style_guide/topics/forms/_labels.html.erb +6 -0
  126. data/app/views/spree/admin/style_guide/topics/forms/_validation.html.erb +8 -1
  127. data/app/views/spree/admin/style_guide/topics/layout/_full_width_table_layout.html.erb +10 -0
  128. data/app/views/spree/admin/style_guide/topics/layout/_helpful_layout.html.erb +0 -0
  129. data/app/views/spree/admin/style_guide/topics/layout/_sidebar_layout.html.erb +4 -0
  130. data/app/views/spree/admin/style_guide/topics/messaging/_flashes.html.erb +10 -4
  131. data/app/views/spree/admin/style_guide/topics/messaging/_tooltips.html.erb +45 -0
  132. data/app/views/spree/admin/style_guide/topics/tables/_forms_in_tables.html.erb +4 -0
  133. data/app/views/spree/admin/style_guide/topics/typography/_lists.html.erb +1 -1
  134. data/app/views/spree/admin/tax_rates/_form.html.erb +17 -3
  135. data/app/views/spree/admin/tax_rates/index.html.erb +12 -3
  136. data/app/views/spree/admin/taxonomies/edit.erb +1 -8
  137. data/app/views/spree/admin/taxons/_form.html.erb +6 -4
  138. data/app/views/spree/admin/taxons/edit.html.erb +0 -15
  139. data/app/views/spree/admin/taxons/index.html.erb +1 -1
  140. data/app/views/spree/admin/variants/_form.html.erb +8 -9
  141. data/app/views/spree/admin/variants/new.js.erb +0 -1
  142. data/config/routes.rb +1 -1
  143. data/spec/controllers/spree/admin/orders/customer_details_controller_spec.rb +1 -1
  144. data/spec/controllers/spree/admin/orders_controller_spec.rb +16 -4
  145. data/spec/controllers/spree/admin/payment_methods_controller_spec.rb +2 -2
  146. data/spec/controllers/spree/admin/payments_controller_spec.rb +1 -1
  147. data/spec/controllers/spree/admin/products_controller_spec.rb +33 -0
  148. data/spec/controllers/spree/admin/variants_controller_spec.rb +39 -13
  149. data/spec/features/admin/configuration/payment_methods_spec.rb +11 -11
  150. data/spec/features/admin/configuration/shipping_methods_spec.rb +1 -1
  151. data/spec/features/admin/configuration/states_spec.rb +4 -4
  152. data/spec/features/admin/configuration/store_spec.rb +3 -3
  153. data/spec/features/admin/configuration/tax_rates_spec.rb +1 -1
  154. data/spec/features/admin/orders/adjustments_spec.rb +1 -1
  155. data/spec/features/admin/orders/customer_details_spec.rb +10 -11
  156. data/spec/features/admin/orders/listing_spec.rb +1 -1
  157. data/spec/features/admin/orders/new_order_spec.rb +4 -11
  158. data/spec/features/admin/orders/order_details_spec.rb +20 -30
  159. data/spec/features/admin/orders/return_payment_state_spec.rb +60 -0
  160. data/spec/features/admin/orders/shipments_spec.rb +7 -0
  161. data/spec/features/admin/products/edit/images_spec.rb +48 -9
  162. data/spec/features/admin/products/edit/variants_spec.rb +1 -1
  163. data/spec/features/admin/products/option_types_spec.rb +2 -2
  164. data/spec/features/admin/products/products_spec.rb +49 -3
  165. data/spec/features/admin/products/stock_management_spec.rb +1 -3
  166. data/spec/features/admin/products/variant_spec.rb +20 -0
  167. data/spec/features/admin/promotion_adjustments_spec.rb +35 -34
  168. data/spec/features/admin/promotions/option_value_rule_spec.rb +2 -2
  169. data/spec/features/admin/promotions/product_rule_spec.rb +1 -1
  170. data/spec/features/admin/promotions/tiered_calculator_spec.rb +2 -2
  171. data/spec/features/admin/promotions/user_rule_spec.rb +2 -2
  172. data/spec/features/admin/stock_transfer_spec.rb +11 -8
  173. data/spec/helpers/admin/navigation_helper_spec.rb +23 -0
  174. metadata +26 -18
  175. data/app/assets/javascripts/spree/backend/images/new.js.coffee +0 -7
  176. data/app/assets/stylesheets/spree/backend/sections/_payments.scss +0 -14
  177. data/app/helpers/spree/admin/images_helper.rb +0 -17
  178. data/app/views/spree/admin/orders/_add_line_item.html.erb +0 -15
  179. data/app/views/spree/admin/prices/new.js.erb +0 -2
  180. data/app/views/spree/admin/products/_properties_form.erb +0 -10
  181. data/app/views/spree/admin/promotions/_tab.html.erb +0 -1
  182. data/app/views/spree/admin/shared/_report_criteria.html.erb +0 -17
  183. data/app/views/spree/admin/states/_new.html.erb +0 -7
  184. data/app/views/spree/admin/stock_locations/_transfer_stock_form.html.erb +0 -38
  185. data/app/views/spree/admin/stock_transfers/_stock_movements.html.erb +0 -27
  186. data/app/views/spree/admin/taxons/_taxon_table.html.erb +0 -23
@@ -8,10 +8,12 @@
8
8
 
9
9
  <%= f.field_container :permalink_part do %>
10
10
  <%= label_tag :permalink_part, Spree::Taxon.human_attribute_name(:permalink), class: 'required' %><br />
11
- <%= text_field_tag :permalink_part, @permalink_part, class: 'fullwidth' %><br />
12
- <span class="info" id="permalink_part_display">
13
- <%= @taxon.permalink.split('/')[0...-1].join('/') + '/' %>
14
- </span>
11
+ <div class="input-group">
12
+ <% if @taxon.parent %>
13
+ <span class="input-group-addon"><%= @taxon.permalink.split('/')[0...-1].join('/') + '/' %></span>
14
+ <% end %>
15
+ <%= text_field_tag :permalink_part, @permalink_part, class: 'fullwidth form-control' %><br />
16
+ </div>
15
17
  <% end %>
16
18
 
17
19
  <%= f.field_container :icon do %>
@@ -17,18 +17,3 @@
17
17
  <%= button_link_to Spree.t('actions.cancel'), edit_admin_taxonomy_url(@taxonomy) %>
18
18
  </div>
19
19
  <% end %>
20
-
21
- <% content_for :head do %>
22
- <%= javascript_tag do -%>
23
- $(document).ready(function() {
24
- var field = $('#permalink_part'),
25
- target = $('#permalink_part_display'),
26
- permalink_part_default = target.text().trim();
27
-
28
- target.text(permalink_part_default + field.val());
29
- field.on('keyup blur', function () {
30
- target.text(permalink_part_default + $(this).val());
31
- });
32
- });
33
- <% end -%>
34
- <% end %>
@@ -1,4 +1,4 @@
1
- <% admin_breadcrumb(link_to Spree::Product.model_name.human(count: :other), spree.admin_products_path) %>
1
+ <% admin_breadcrumb(link_to plural_resource_name(Spree::Product), spree.admin_products_path) %>
2
2
  <% admin_breadcrumb(Spree.t('admin.taxons.display_order')) %>
3
3
 
4
4
  <% content_for :table_filter_title do %>
@@ -17,13 +17,12 @@
17
17
  </div>
18
18
  </div>
19
19
  </fieldset>
20
- <% if f.object.new_record? %>
21
- <fieldset class="no-border-top no-border-bottom">
22
- <div class="row">
20
+ <fieldset class="no-border-top no-border-bottom">
21
+ <div class="row">
23
22
  <% @product.option_types.each_with_index do |option_type, index| %>
24
23
  <div class="col-3">
25
24
  <div class="field" data-hook="presentation">
26
- <%= label :new_variant, option_type.presentation %>
25
+ <%= label 'option_value_ids', option_type.presentation %>
27
26
  <%= f.collection_select 'option_value_ids',
28
27
  option_type.option_values,
29
28
  :id,
@@ -31,14 +30,14 @@
31
30
  { include_blank: true },
32
31
  {
33
32
  name: 'variant[option_value_ids][]',
34
- class: "select2 fullwidth"
33
+ class: "custom-select fullwidth",
34
+ id: "option_value_ids_#{option_type.presentation}"
35
35
  } %>
36
36
  </div>
37
37
  </div>
38
38
  <% end %>
39
- </div>
40
- </fieldset>
41
- <% end %>
39
+ </div>
40
+ </fieldset>
42
41
  </div>
43
42
 
44
43
  <div data-hook="admin_variant_form_additional_fields">
@@ -92,7 +91,7 @@
92
91
  :id,
93
92
  :name,
94
93
  { include_blank: t('.use_product_tax_category') },
95
- { class: 'select2 fullwidth' } %>
94
+ { class: 'custom-select fullwidth' } %>
96
95
  </div>
97
96
  </div>
98
97
  </div>
@@ -1,2 +1 @@
1
1
  $(".js-content-below-tabs").html('<%= escape_javascript(render template: 'spree/admin/variants/new', formats: [:html], handlers: [:erb]) %>');
2
- $(".js-content-below-tabs .select2").select2();
data/config/routes.rb CHANGED
@@ -45,7 +45,7 @@ Spree::Core::Engine.routes.draw do
45
45
  end
46
46
  end
47
47
  member do
48
- get :clone
48
+ post :clone
49
49
  end
50
50
  resources :variants do
51
51
  collection do
@@ -8,7 +8,7 @@ describe Spree::Admin::Orders::CustomerDetailsController, type: :controller do
8
8
 
9
9
  let(:order) { create(:order, number: "R123456789") }
10
10
 
11
- before { allow(Spree::Order).to receive(:find_by_number!) { order } }
11
+ before { allow(Spree::Order).to receive_message_chain(:includes, :find_by!) { order } }
12
12
 
13
13
  context "#update" do
14
14
  it "updates + progresses the order" do
@@ -30,7 +30,7 @@ describe Spree::Admin::OrdersController, type: :controller do
30
30
  let(:adjustments) { double('adjustments') }
31
31
 
32
32
  before do
33
- allow(Spree::Order).to receive_messages(find_by_number!: order)
33
+ allow(Spree::Order).to receive_message_chain(:includes, find_by!: order)
34
34
  allow(order).to receive_messages(contents: Spree::OrderContents.new(order))
35
35
  end
36
36
 
@@ -58,6 +58,17 @@ describe Spree::Admin::OrdersController, type: :controller do
58
58
  end
59
59
  end
60
60
 
61
+ context "#resend" do
62
+ let(:order) { create(:completed_order_with_totals) }
63
+ it "resends order email" do
64
+ mail_message = double "Mail::Message"
65
+ expect(Spree::OrderMailer).to receive(:confirm_email).with(order, true).and_return mail_message
66
+ expect(mail_message).to receive :deliver_later
67
+ post :resend, params: { id: order.number }
68
+ expect(flash[:success]).to eq Spree.t(:order_email_resent)
69
+ end
70
+ end
71
+
61
72
  context "pagination" do
62
73
  it "can page through the orders" do
63
74
  get :index, params: { page: 2, per_page: 10 }
@@ -96,7 +107,7 @@ describe Spree::Admin::OrdersController, type: :controller do
96
107
 
97
108
  context "when a user_id is passed as a parameter" do
98
109
  let(:user) { mock_model(Spree.user_class) }
99
- before { allow(Spree.user_class).to receive_messages find_by_id: user }
110
+ before { allow(Spree.user_class).to receive_messages find_by: user }
100
111
 
101
112
  it "imports a new order and assigns the user to the order" do
102
113
  expect(Spree::Core::Importer::Order).to receive(:import)
@@ -113,6 +124,7 @@ describe Spree::Admin::OrdersController, type: :controller do
113
124
  end
114
125
 
115
126
  # Regression test for https://github.com/spree/spree/issues/3684
127
+ # Rendering a form should under no circumstance mutate the order
116
128
  context "#edit" do
117
129
  it "does not refresh rates if the order is completed" do
118
130
  allow(order).to receive_messages completed?: true
@@ -120,9 +132,9 @@ describe Spree::Admin::OrdersController, type: :controller do
120
132
  get :edit, params: { id: order.number }
121
133
  end
122
134
 
123
- it "does refresh the rates if the order is incomplete" do
135
+ it "does not refresh the rates if the order is incomplete" do
124
136
  allow(order).to receive_messages completed?: false
125
- expect(order).to receive :refresh_shipment_rates
137
+ expect(order).not_to receive :refresh_shipment_rates
126
138
  get :edit, params: { id: order.number }
127
139
  end
128
140
 
@@ -28,13 +28,13 @@ module Spree
28
28
 
29
29
  context "tries to save invalid payment" do
30
30
  it "doesn't break, responds nicely" do
31
- post :create, params: { payment_method: { name: "", type: "Spree::Gateway::Bogus" } }
31
+ post :create, params: { payment_method: { name: "", type: "Spree::PaymentMethod::BogusCreditCard" } }
32
32
  end
33
33
  end
34
34
 
35
35
  it "can create a payment method of a valid type" do
36
36
  expect {
37
- post :create, params: { payment_method: { name: "Test Method", type: "Spree::Gateway::Bogus" } }
37
+ post :create, params: { payment_method: { name: "Test Method", type: "Spree::PaymentMethod::BogusCreditCard" } }
38
38
  }.to change(Spree::PaymentMethod, :count).by(1)
39
39
 
40
40
  expect(response).to be_redirect
@@ -13,7 +13,7 @@ module Spree
13
13
  describe '#create' do
14
14
  context "with a valid credit card" do
15
15
  let(:order) { create(:order_with_line_items, state: "payment") }
16
- let(:payment_method) { create(:credit_card_payment_method, available_to_admin: true, available_to_users: false) }
16
+ let(:payment_method) { create(:credit_card_payment_method, available_to_admin: true) }
17
17
  let(:attributes) do
18
18
  {
19
19
  order_id: order.number,
@@ -13,6 +13,29 @@ describe Spree::Admin::ProductsController, type: :controller do
13
13
  expect(assigns[:collection]).not_to be_empty
14
14
  expect(assigns[:collection]).to include(product)
15
15
  end
16
+
17
+ # Regression test for https://github.com/spree/spree/issues/1903
18
+ context 'when soft deleted products exist' do
19
+ let!(:soft_deleted_product) { create(:product, sku: "ABC123").destroy }
20
+
21
+ context 'when params[:q][:with_deleted] is not set' do
22
+ let(:params) { { q: {} } }
23
+
24
+ it 'filters out soft-deleted products by default' do
25
+ get :index, params: params
26
+ expect(assigns[:collection]).to_not include(soft_deleted_product)
27
+ end
28
+ end
29
+
30
+ context 'when params[:q][:with_deleted] is set to "true"' do
31
+ let(:params) { { q: { with_deleted: 'true' } } }
32
+
33
+ it 'includes soft-deleted products' do
34
+ get :index, params: params
35
+ expect(assigns[:collection]).to include(soft_deleted_product)
36
+ end
37
+ end
38
+ end
16
39
  end
17
40
 
18
41
  # regression test for https://github.com/spree/spree/issues/1370
@@ -143,6 +166,16 @@ describe Spree::Admin::ProductsController, type: :controller do
143
166
  end
144
167
  end
145
168
 
169
+ context "cloning a product" do
170
+ let!(:product) { create(:product) }
171
+
172
+ it "duplicates the product" do
173
+ expect do
174
+ post :clone, params: { id: product.id }
175
+ end.to change { Spree::Product.count }.by(1)
176
+ end
177
+ end
178
+
146
179
  # regression test for https://github.com/spree/spree/issues/801
147
180
  context "destroying a product" do
148
181
  let(:product) do
@@ -7,24 +7,50 @@ module Spree
7
7
 
8
8
  describe "#index" do
9
9
  let(:product) { create(:product) }
10
- let!(:variant_1) { create(:variant, product: product) }
11
- let!(:variant_2) { create(:variant, product: product) }
10
+ let(:params) { { product_id: product.slug } }
12
11
 
13
- before { variant_2.destroy }
12
+ subject { get :index, params: params }
14
13
 
15
- context "deleted is not requested" do
16
- it "does not assign deleted variants for a requested product" do
17
- get :index, params: { product_id: product.slug }
18
- expect(assigns(:collection)).to include variant_1
19
- expect(assigns(:collection)).not_to include variant_2
14
+ context "the value of @parent" do
15
+ it "is the product" do
16
+ subject
17
+ expect(assigns(:parent)).to eq product
18
+ end
19
+
20
+ context "with a deleted product" do
21
+ before { product.destroy! }
22
+
23
+ it "is the product" do
24
+ subject
25
+ expect(assigns(:parent)).to eq product
26
+ end
20
27
  end
21
28
  end
22
29
 
23
- context "deleted is requested" do
24
- it "assigns deleted along with non-deleted variants for a requested product" do
25
- get :index, params: { product_id: product.slug, deleted: "on" }
26
- expect(assigns(:collection)).to include variant_1
27
- expect(assigns(:collection)).to include variant_2
30
+ context "the value of @collection" do
31
+ let!(:variant) { create(:variant, product: product) }
32
+ let!(:deleted_variant) { create(:variant, product: product) }
33
+
34
+ context "with deleted variants" do
35
+ before { deleted_variant.destroy }
36
+
37
+ context "when deleted is not requested" do
38
+ it "excludes deleted variants" do
39
+ subject
40
+ expect(assigns(:collection)).to include variant
41
+ expect(assigns(:collection)).not_to include deleted_variant
42
+ end
43
+ end
44
+
45
+ context "when deleted is requested" do
46
+ let(:params) { { product_id: product.slug, deleted: "on" } }
47
+
48
+ it "includes deleted variants" do
49
+ subject
50
+ expect(assigns(:collection)).to include variant
51
+ expect(assigns(:collection)).to include deleted_variant
52
+ end
53
+ end
28
54
  end
29
55
  end
30
56
  end
@@ -16,7 +16,7 @@ describe "Payment Methods", type: :feature do
16
16
 
17
17
  within("table#listing_payment_methods") do
18
18
  expect(all("th")[1].text).to eq("Name")
19
- expect(all("th")[2].text).to eq("Provider")
19
+ expect(all("th")[2].text).to eq("Type")
20
20
  expect(all("th")[3].text).to eq("Available to users")
21
21
  expect(all("th")[4].text).to eq("Available to admin")
22
22
  expect(all("th")[5].text).to eq("Active")
@@ -35,7 +35,7 @@ describe "Payment Methods", type: :feature do
35
35
  expect(page).to have_content("New Payment Method")
36
36
  fill_in "payment_method_name", with: "check90"
37
37
  fill_in "payment_method_description", with: "check90 desc"
38
- select "Spree::PaymentMethod::Check", from: "gtwy-type"
38
+ select "Spree::PaymentMethod::Check", from: "Type"
39
39
  click_button "Create"
40
40
  expect(page).to have_content("successfully created!")
41
41
  end
@@ -67,7 +67,7 @@ describe "Payment Methods", type: :feature do
67
67
  context "changing type and payment_source", js: true do
68
68
  after do
69
69
  # cleanup
70
- Spree::Config.static_model_preferences.for_class(Spree::Gateway::Bogus).clear
70
+ Spree::Config.static_model_preferences.for_class(Spree::PaymentMethod::BogusCreditCard).clear
71
71
  end
72
72
 
73
73
  it "displays message when changing type" do
@@ -76,48 +76,48 @@ describe "Payment Methods", type: :feature do
76
76
  click_icon :edit
77
77
  expect(page).to have_content('Test Mode')
78
78
 
79
- select2_search 'Spree::PaymentMethod::Check', from: 'Provider'
79
+ select 'Spree::PaymentMethod::Check', from: 'Type'
80
80
  expect(page).to have_content('you must save first')
81
81
  expect(page).to have_no_content('Test Mode')
82
82
 
83
83
  # change back
84
- select2_search 'Spree::Gateway::Bogus', from: 'Provider'
84
+ select 'Spree::PaymentMethod::BogusCreditCard', from: 'Type'
85
85
  expect(page).to have_no_content('you must save first')
86
86
  expect(page).to have_content('Test Mode')
87
87
  end
88
88
 
89
89
  it "displays message when changing preference source" do
90
- Spree::Config.static_model_preferences.add(Spree::Gateway::Bogus, 'my_prefs', {})
90
+ Spree::Config.static_model_preferences.add(Spree::PaymentMethod::BogusCreditCard, 'my_prefs', {})
91
91
 
92
92
  create(:credit_card_payment_method)
93
93
  click_link "Payment Methods"
94
94
  click_icon :edit
95
95
  expect(page).to have_content('Test Mode')
96
96
 
97
- select2_search 'my_prefs', from: 'Preference Source'
97
+ select 'my_prefs', from: 'Preference Source'
98
98
  expect(page).to have_content('you must save first')
99
99
  expect(page).to have_no_content('Test Mode')
100
100
 
101
101
  # change back
102
- select2_search 'Custom', from: 'Preference Source'
102
+ select '(custom)', from: 'Preference Source'
103
103
  expect(page).to have_no_content('you must save first')
104
104
  expect(page).to have_content('Test Mode')
105
105
  end
106
106
 
107
107
  it "updates successfully and keeps secrets" do
108
- Spree::Config.static_model_preferences.add(Spree::Gateway::Bogus, 'my_prefs', { server: 'secret' })
108
+ Spree::Config.static_model_preferences.add(Spree::PaymentMethod::BogusCreditCard, 'my_prefs', { server: 'secret' })
109
109
 
110
110
  create(:credit_card_payment_method)
111
111
  click_link "Payment Methods"
112
112
  click_icon :edit
113
113
 
114
- select2_search 'my_prefs', from: 'Preference Source'
114
+ select 'my_prefs', from: 'Preference Source'
115
115
  click_on 'Update'
116
116
  expect(page).to have_content('Using static preferences')
117
117
  expect(page).to have_no_content('secret')
118
118
 
119
119
  # change back
120
- select2_search 'Custom', from: 'Preference Source'
120
+ select '(custom)', from: 'Preference Source'
121
121
  click_on 'Update'
122
122
  expect(page).to have_content('Test Mode')
123
123
  expect(page).to have_no_content('secret')
@@ -57,7 +57,7 @@ describe "Shipping Methods", type: :feature do
57
57
  click_icon :edit
58
58
  end
59
59
 
60
- select2_search('Flexible Rate', from: 'Calculator')
60
+ select 'Flexible Rate per package item', from: 'Base Calculator'
61
61
 
62
62
  fill_in 'First Item', with: 10
63
63
  fill_in 'Additional Item', with: 20
@@ -26,7 +26,7 @@ describe "States", type: :feature do
26
26
  context "creating and editing states" do
27
27
  it "should allow an admin to edit existing states", js: true do
28
28
  go_to_states_page
29
- select2 country.name, from: 'Country'
29
+ select country.name, from: 'Country'
30
30
 
31
31
  click_link "new_state_link"
32
32
  fill_in "state_name", with: "Calgary"
@@ -38,7 +38,7 @@ describe "States", type: :feature do
38
38
 
39
39
  it "should allow an admin to create states for non default countries", js: true do
40
40
  go_to_states_page
41
- select2 hungary.name, from: 'Country'
41
+ select "Hungary", from: 'Country'
42
42
 
43
43
  click_link "new_state_link"
44
44
  fill_in "state_name", with: "Pest megye"
@@ -46,12 +46,12 @@ describe "States", type: :feature do
46
46
  click_button "Create"
47
47
  expect(page).to have_content("successfully created!")
48
48
  expect(page).to have_content("Pest megye")
49
- expect(find("#s2id_country")).to have_content("Hungary")
49
+ expect(page).to have_select('Country', selected: "Hungary")
50
50
  end
51
51
 
52
52
  it "should show validation errors", js: true do
53
53
  go_to_states_page
54
- select2 country.name, from: 'Country'
54
+ select country.name, from: 'Country'
55
55
 
56
56
  click_link "new_state_link"
57
57
 
@@ -38,13 +38,13 @@ describe "Store", type: :feature, js: true do
38
38
  end
39
39
 
40
40
  it "should be able to update the default cart tax country" do
41
- expect(page).to have_select('Tax Country for Empty Carts', selected: 'No taxes on carts without address', visible: false)
41
+ expect(page).to have_select('Tax Country for Empty Carts', selected: 'No taxes on carts without address')
42
42
 
43
- select "Germany", from: "Tax Country for Empty Carts", visible: false
43
+ select "Germany", from: "Tax Country for Empty Carts"
44
44
  click_button "Update"
45
45
 
46
46
  expect(page).to have_content("has been successfully updated")
47
- expect(page).to have_select("Tax Country for Empty Carts", selected: "Germany", visible: false)
47
+ expect(page).to have_select("Tax Country for Empty Carts", selected: "Germany")
48
48
  end
49
49
  end
50
50