solidus_backend 2.7.4 → 2.8.0
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.
- checksums.yaml +4 -4
- data/README.md +12 -8
- data/app/assets/images/favicon.ico +0 -0
- data/app/assets/javascripts/spree/backend.js +0 -2
- data/app/assets/javascripts/spree/backend/adjustments.js +1 -1
- data/app/assets/javascripts/spree/backend/components/tooltips.js +21 -17
- data/app/assets/javascripts/spree/backend/option_type_autocomplete.js +1 -1
- data/app/assets/javascripts/spree/backend/product_picker.js +1 -1
- data/app/assets/javascripts/spree/backend/shipments.js +6 -1
- data/app/assets/javascripts/spree/backend/stock_management.js +9 -0
- data/app/assets/javascripts/spree/backend/store_credits.js +18 -2
- data/app/assets/javascripts/spree/backend/taxons.js +1 -1
- data/app/assets/javascripts/spree/backend/templates/stock_items/stock_location_stock_item.hbs +24 -25
- data/app/assets/javascripts/spree/backend/user_picker.js +1 -1
- data/app/assets/javascripts/spree/backend/variant_autocomplete.js +1 -1
- data/app/assets/javascripts/spree/backend/views/order/customer_select.js +1 -1
- data/app/assets/javascripts/spree/backend/views/order/summary.js +2 -2
- data/app/assets/javascripts/spree/backend/views/stock/add_stock_item.js +15 -4
- data/app/assets/javascripts/spree/backend/views/stock/edit_stock_item_row.js +30 -10
- data/app/assets/stylesheets/spree/backend/globals/_functions.scss +1 -2
- data/app/assets/stylesheets/spree/backend/sections/_orders.scss +8 -0
- data/app/assets/stylesheets/spree/backend/sections/_stock_management.scss +77 -2
- data/app/assets/stylesheets/spree/backend/spree_admin.scss +0 -1
- data/app/controllers/spree/admin/cancellations_controller.rb +2 -2
- data/app/controllers/spree/admin/locale_controller.rb +1 -1
- data/app/controllers/spree/admin/orders/customer_details_controller.rb +8 -1
- data/app/controllers/spree/admin/orders_controller.rb +1 -11
- data/app/controllers/spree/admin/products_controller.rb +10 -6
- data/app/controllers/spree/admin/promotion_codes_controller.rb +19 -1
- data/app/controllers/spree/admin/promotions_controller.rb +1 -1
- data/app/controllers/spree/admin/reimbursements_controller.rb +7 -2
- data/app/controllers/spree/admin/resource_controller.rb +1 -0
- data/app/controllers/spree/admin/store_credit_reasons_controller.rb +8 -0
- data/app/controllers/spree/admin/store_credits_controller.rb +11 -11
- data/app/helpers/spree/admin/navigation_helper.rb +1 -1
- data/app/models/spree/backend_configuration.rb +38 -21
- data/app/views/spree/admin/cancellations/index.html.erb +3 -1
- data/app/views/spree/admin/images/_image_row.html.erb +1 -1
- data/app/views/spree/admin/images/edit.html.erb +3 -3
- data/app/views/spree/admin/images/index.html.erb +2 -2
- data/app/views/spree/admin/log_entries/index.html.erb +2 -2
- data/app/views/spree/admin/orders/_carton_manifest.html.erb +3 -1
- data/app/views/spree/admin/orders/_shipment_manifest.html.erb +3 -1
- data/app/views/spree/admin/orders/confirm/_line_items.html.erb +3 -2
- data/app/views/spree/admin/orders/confirm/_shipment_manifest.html.erb +3 -1
- data/app/views/spree/admin/orders/index.html.erb +1 -1
- data/app/views/spree/admin/products/_form.html.erb +7 -7
- data/app/views/spree/admin/products/edit.html.erb +5 -0
- data/app/views/spree/admin/products/index.html.erb +3 -1
- data/app/views/spree/admin/promotion_categories/index.html.erb +1 -1
- data/app/views/spree/admin/promotion_code_batches/index.html.erb +1 -1
- data/app/views/spree/admin/promotion_codes/index.html.erb +5 -1
- data/app/views/spree/admin/promotion_codes/new.html.erb +31 -0
- data/app/views/spree/admin/promotions/_actions.html.erb +1 -1
- data/app/views/spree/admin/promotions/_activations_edit.html.erb +1 -1
- data/app/views/spree/admin/promotions/_form.html.erb +4 -3
- data/app/views/spree/admin/promotions/_rules.html.erb +1 -1
- data/app/views/spree/admin/promotions/edit.html.erb +3 -1
- data/app/views/spree/admin/refunds/new.html.erb +1 -1
- data/app/views/spree/admin/shared/_address_form.html.erb +10 -3
- data/app/views/spree/admin/shared/_edit_resource_links.html.erb +1 -1
- data/app/views/spree/admin/shared/_head.html.erb +1 -0
- data/app/views/spree/admin/shared/_image.html.erb +2 -2
- data/app/views/spree/admin/shared/_product_sub_menu.html.erb +1 -1
- data/app/views/spree/admin/shared/_settings_checkout_tabs.html.erb +4 -0
- data/app/views/spree/admin/shared/_settings_sub_menu.html.erb +3 -3
- data/app/views/spree/admin/shared/_tabs.html.erb +3 -2
- data/app/views/spree/admin/shared/_variant_search.html.erb +1 -1
- data/app/views/spree/admin/stock_items/_stock_management.html.erb +56 -38
- data/app/views/spree/admin/stock_locations/_form.html.erb +133 -121
- data/app/views/spree/admin/stock_locations/edit.html.erb +4 -2
- data/app/views/spree/admin/store_credit_reasons/edit.html.erb +15 -0
- data/app/views/spree/admin/store_credit_reasons/index.html.erb +56 -0
- data/app/views/spree/admin/store_credit_reasons/new.html.erb +18 -0
- data/app/views/spree/admin/store_credit_reasons/shared/_form.html.erb +15 -0
- data/app/views/spree/admin/store_credits/_store_credit_reason_field.html.erb +7 -0
- data/app/views/spree/admin/store_credits/edit_amount.html.erb +1 -1
- data/app/views/spree/admin/store_credits/edit_validity.html.erb +1 -1
- data/app/views/spree/admin/store_credits/show.html.erb +2 -2
- data/app/views/spree/admin/users/items.html.erb +3 -1
- data/app/views/spree/admin/users/orders.html.erb +1 -1
- data/config/routes.rb +2 -8
- data/lib/spree/backend.rb +1 -1
- data/solidus_backend.gemspec +3 -4
- data/spec/controllers/spree/admin/base_controller_spec.rb +1 -1
- data/spec/controllers/spree/admin/cancellations_controller_spec.rb +7 -3
- data/spec/controllers/spree/admin/orders/customer_details_controller_spec.rb +50 -2
- data/spec/controllers/spree/admin/orders_controller_spec.rb +23 -11
- data/spec/controllers/spree/admin/payments_controller_spec.rb +1 -1
- data/spec/controllers/spree/admin/products_controller_spec.rb +72 -0
- data/spec/controllers/spree/admin/promotion_codes_controller_spec.rb +13 -1
- data/spec/controllers/spree/admin/reimbursements_controller_spec.rb +11 -0
- data/spec/controllers/spree/admin/resource_controller_spec.rb +22 -0
- data/spec/controllers/spree/admin/stock_items_controller_spec.rb +1 -1
- data/spec/controllers/spree/admin/store_credits_controller_spec.rb +7 -7
- data/spec/features/admin/configuration/payment_methods_spec.rb +2 -2
- data/spec/features/admin/configuration/shipping_methods_spec.rb +2 -2
- data/spec/features/admin/homepage_spec.rb +1 -6
- data/spec/features/admin/orders/listing_spec.rb +1 -1
- data/spec/features/admin/orders/new_order_spec.rb +117 -0
- data/spec/features/admin/orders/new_refund_spec.rb +35 -0
- data/spec/features/admin/orders/order_details_spec.rb +2 -2
- data/spec/features/admin/orders/payments_spec.rb +2 -2
- data/spec/features/admin/orders/return_payment_state_spec.rb +3 -0
- data/spec/features/admin/orders/shipments_spec.rb +28 -0
- data/spec/features/admin/products/products_spec.rb +1 -1
- data/spec/features/admin/products/stock_management_spec.rb +10 -13
- data/spec/features/admin/promotion_adjustments_spec.rb +12 -12
- data/spec/features/admin/promotions/option_value_rule_spec.rb +2 -2
- data/spec/features/admin/promotions/product_rule_spec.rb +1 -1
- data/spec/features/admin/promotions/tiered_calculator_spec.rb +1 -1
- data/spec/features/admin/promotions/user_rule_spec.rb +2 -2
- data/spec/features/admin/reimbursements_spec.rb +1 -1
- data/spec/features/admin/store_credits_spec.rb +51 -2
- data/spec/features/admin/taxons_spec.rb +35 -0
- data/spec/features/admin/users_spec.rb +22 -11
- data/spec/helpers/admin/navigation_helper_spec.rb +4 -2
- data/spec/helpers/admin/store_credit_events_helper_spec.rb +2 -2
- data/spec/javascripts/spec_helper.js +2 -0
- data/spec/models/spree/backend_configuration/menu_item_spec.rb +17 -0
- data/spec/models/spree/backend_configuration_spec.rb +22 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/support/feature/order_feature_helper.rb +1 -1
- data/spec/views/spree/admin/shared/navigation_footer_spec.rb +1 -1
- data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_en-US.js +10 -0
- metadata +26 -34
- data/app/controllers/spree/admin/reports_controller.rb +0 -82
- data/app/views/spree/admin/reports/index.html.erb +0 -19
- data/app/views/spree/admin/reports/sales_total.html.erb +0 -35
- data/app/views/spree/admin/shared/_report_order_criteria.html.erb +0 -19
- data/app/views/spree/admin/store_credits/_update_reason_field.html.erb +0 -7
- data/spec/controllers/spree/admin/reports_controller_spec.rb +0 -133
- data/spec/features/admin/reports_spec.rb +0 -63
@@ -32,6 +32,13 @@ describe Spree::Admin::WidgetsController, type: :controller do
|
|
32
32
|
model do
|
33
33
|
acts_as_list
|
34
34
|
validates :name, presence: true
|
35
|
+
before_destroy :check_destroy_constraints
|
36
|
+
|
37
|
+
def check_destroy_constraints
|
38
|
+
return unless name == 'undestroyable'
|
39
|
+
errors.add :base, "You can't destroy undestroyable things!"
|
40
|
+
throw(:abort)
|
41
|
+
end
|
35
42
|
end
|
36
43
|
end
|
37
44
|
|
@@ -146,6 +153,21 @@ describe Spree::Admin::WidgetsController, type: :controller do
|
|
146
153
|
it 'destroys the resource' do
|
147
154
|
expect { subject }.to change { Widget.count }.from(1).to(0)
|
148
155
|
end
|
156
|
+
|
157
|
+
context 'failure' do
|
158
|
+
let(:widget) { Widget.create!(name: 'undestroyable') }
|
159
|
+
let(:params) { { id: widget.id } }
|
160
|
+
|
161
|
+
context 'js format' do
|
162
|
+
subject { delete :destroy, params: params, format: 'js' }
|
163
|
+
|
164
|
+
it 'responds with error message' do
|
165
|
+
subject
|
166
|
+
expect(response).to be_unprocessable
|
167
|
+
expect(response.body).to eq assigns(:widget).errors.full_messages.join(', ')
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
149
171
|
end
|
150
172
|
|
151
173
|
describe '#update_positions' do
|
@@ -13,7 +13,7 @@ module Spree
|
|
13
13
|
let(:stock_item) { variant.stock_items.first }
|
14
14
|
let!(:user) { create :user }
|
15
15
|
|
16
|
-
before { expect(controller).to receive(:
|
16
|
+
before { expect(controller).to receive(:try_spree_current_user).and_return(user) }
|
17
17
|
before { request.env["HTTP_REFERER"] = "product_admin_page" }
|
18
18
|
|
19
19
|
subject do
|
@@ -3,8 +3,8 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
shared_examples "update reason loader" do
|
6
|
-
it "sets the
|
7
|
-
expect(assigns(:
|
6
|
+
it "sets the store_credit_reasons variable to a list of categories sorted by category name " do
|
7
|
+
expect(assigns(:store_credit_reasons)).to eq [store_credit_reason]
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
@@ -16,11 +16,11 @@ describe Spree::Admin::StoreCreditsController do
|
|
16
16
|
|
17
17
|
let!(:b_credit_category) { create(:store_credit_category, name: "B category") }
|
18
18
|
let!(:a_credit_category) { create(:store_credit_category, name: "A category") }
|
19
|
-
let!(:
|
19
|
+
let!(:store_credit_reason) { create(:store_credit_reason) }
|
20
20
|
|
21
21
|
describe "#show" do
|
22
22
|
let!(:store_credit) { create(:store_credit, user: user, category: a_credit_category) }
|
23
|
-
let!(:event)
|
23
|
+
let!(:event) { create(:store_credit_auth_event, store_credit: store_credit, created_at: 5.days.ago) }
|
24
24
|
|
25
25
|
before { get :show, params: { user_id: user.id, id: store_credit.id } }
|
26
26
|
|
@@ -173,12 +173,12 @@ describe Spree::Admin::StoreCreditsController do
|
|
173
173
|
describe "#update_amount" do
|
174
174
|
let(:original_amount) { 100.0 }
|
175
175
|
let!(:store_credit) { create(:store_credit, user: user, amount: original_amount) }
|
176
|
-
let!(:
|
176
|
+
let!(:store_credit_reason) { create(:store_credit_reason) }
|
177
177
|
let(:parameters) do
|
178
178
|
{
|
179
179
|
user_id: user.id,
|
180
180
|
id: store_credit.id,
|
181
|
-
|
181
|
+
store_credit_reason_id: store_credit_reason.id,
|
182
182
|
store_credit: {
|
183
183
|
amount: updated_amount
|
184
184
|
}
|
@@ -271,7 +271,7 @@ describe Spree::Admin::StoreCreditsController do
|
|
271
271
|
{
|
272
272
|
user_id: user.id,
|
273
273
|
id: store_credit.id,
|
274
|
-
|
274
|
+
store_credit_reason_id: store_credit_reason.id
|
275
275
|
}
|
276
276
|
end
|
277
277
|
|
@@ -21,8 +21,8 @@ describe "Payment Methods", type: :feature do
|
|
21
21
|
within("table#listing_payment_methods") do
|
22
22
|
expect(all("th")[1].text).to eq("Name")
|
23
23
|
expect(all("th")[2].text).to eq("Type")
|
24
|
-
expect(all("th")[3].text).to eq("Available to
|
25
|
-
expect(all("th")[4].text).to eq("Available to
|
24
|
+
expect(all("th")[3].text).to eq("Available to Users")
|
25
|
+
expect(all("th")[4].text).to eq("Available to Admin")
|
26
26
|
expect(all("th")[5].text).to eq("State")
|
27
27
|
end
|
28
28
|
|
@@ -18,7 +18,7 @@ describe "Shipping Methods", type: :feature do
|
|
18
18
|
within_row(1) do
|
19
19
|
expect(column_text(1)).to eq(shipping_method.name)
|
20
20
|
expect(column_text(2)).to eq(zone.name)
|
21
|
-
expect(column_text(3)).to eq("Flat
|
21
|
+
expect(column_text(3)).to eq("Flat Rate")
|
22
22
|
expect(column_text(4)).to eq("Yes")
|
23
23
|
end
|
24
24
|
end
|
@@ -99,7 +99,7 @@ describe "Shipping Methods", type: :feature do
|
|
99
99
|
click_icon :edit
|
100
100
|
end
|
101
101
|
|
102
|
-
select 'Flexible Rate per
|
102
|
+
select 'Flexible Rate per Package Item', from: 'Base Calculator'
|
103
103
|
|
104
104
|
fill_in 'First Item', with: 10
|
105
105
|
fill_in 'Additional Item', with: 20
|
@@ -23,10 +23,6 @@ describe "Homepage", type: :feature do
|
|
23
23
|
expect(page).to have_link("Products", href: "/admin/products", count: 2)
|
24
24
|
end
|
25
25
|
|
26
|
-
it "should have a link to reports" do
|
27
|
-
expect(page).to have_link("Reports", href: "/admin/reports")
|
28
|
-
end
|
29
|
-
|
30
26
|
it "should have a link to configuration" do
|
31
27
|
expect(page).to have_link("Settings", href: "/admin/stores")
|
32
28
|
end
|
@@ -71,7 +67,7 @@ describe "Homepage", type: :feature do
|
|
71
67
|
|
72
68
|
context 'as fakedispatch user' do
|
73
69
|
before do
|
74
|
-
allow_any_instance_of(Spree::Admin::BaseController).to receive(:
|
70
|
+
allow_any_instance_of(Spree::Admin::BaseController).to receive(:try_spree_current_user).and_return(nil)
|
75
71
|
end
|
76
72
|
|
77
73
|
custom_authorization! do |_user|
|
@@ -84,7 +80,6 @@ describe "Homepage", type: :feature do
|
|
84
80
|
expect(page).to have_link('Orders')
|
85
81
|
expect(page).not_to have_link('Products')
|
86
82
|
expect(page).not_to have_link('Promotions')
|
87
|
-
expect(page).not_to have_link('Reports')
|
88
83
|
expect(page).not_to have_link('Settings')
|
89
84
|
end
|
90
85
|
end
|
@@ -47,7 +47,7 @@ describe "Orders Listing", type: :feature, js: true do
|
|
47
47
|
within_row(1) { expect(page).to have_content("R100") }
|
48
48
|
within_row(2) { expect(page).to have_content("R200") }
|
49
49
|
|
50
|
-
click_link "Completed
|
50
|
+
click_link "Completed at", exact: false
|
51
51
|
|
52
52
|
# Completed at desc
|
53
53
|
within_row(1) { expect(page).to have_content("R200") }
|
@@ -201,6 +201,123 @@ describe "New Order", type: :feature do
|
|
201
201
|
end
|
202
202
|
end
|
203
203
|
|
204
|
+
context 'with a checkout_zone set as the country of Canada' do
|
205
|
+
let!(:canada) { create(:country, iso: 'CA', states_required: true) }
|
206
|
+
let!(:canada_state) { create(:state, country: canada) }
|
207
|
+
let!(:checkout_zone) { create(:zone, name: 'Checkout Zone', countries: [canada]) }
|
208
|
+
|
209
|
+
before do
|
210
|
+
Spree::Country.update_all(states_required: true)
|
211
|
+
Spree::Config.checkout_zone = checkout_zone.name
|
212
|
+
end
|
213
|
+
|
214
|
+
context 'and default_country_iso of the United States' do
|
215
|
+
before do
|
216
|
+
Spree::Config.default_country_iso = Spree::Country.find_by!(iso: 'US').iso
|
217
|
+
end
|
218
|
+
|
219
|
+
it 'the shipping address country select includes only options for Canada' do
|
220
|
+
visit spree.new_admin_order_path
|
221
|
+
click_link 'Customer'
|
222
|
+
within '#shipping' do
|
223
|
+
expect(page).to have_select(
|
224
|
+
'Country',
|
225
|
+
options: ['Canada']
|
226
|
+
)
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
it 'does not show any shipping address state' do
|
231
|
+
visit spree.new_admin_order_path
|
232
|
+
click_link 'Customer'
|
233
|
+
within '#shipping' do
|
234
|
+
expect(page).to have_select(
|
235
|
+
'State',
|
236
|
+
disabled: true,
|
237
|
+
visible: false,
|
238
|
+
options: ['']
|
239
|
+
)
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
it 'the billing address country select includes only options for Canada' do
|
244
|
+
visit spree.new_admin_order_path
|
245
|
+
click_link 'Customer'
|
246
|
+
within '#billing' do
|
247
|
+
expect(page).to have_select(
|
248
|
+
'Country',
|
249
|
+
options: ['Canada']
|
250
|
+
)
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
it 'does not show any billing address state' do
|
255
|
+
visit spree.new_admin_order_path
|
256
|
+
click_link 'Customer'
|
257
|
+
within '#billing' do
|
258
|
+
expect(page).to have_select(
|
259
|
+
'State',
|
260
|
+
disabled: true,
|
261
|
+
visible: false,
|
262
|
+
options: ['']
|
263
|
+
)
|
264
|
+
end
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
context 'and default_country_iso of Canada' do
|
269
|
+
before do
|
270
|
+
Spree::Config.default_country_iso = Spree::Country.find_by!(iso: 'CA').iso
|
271
|
+
end
|
272
|
+
|
273
|
+
it 'defaults the shipping address country to Canada' do
|
274
|
+
visit spree.new_admin_order_path
|
275
|
+
click_link 'Customer'
|
276
|
+
within '#shipping' do
|
277
|
+
expect(page).to have_select(
|
278
|
+
'Country',
|
279
|
+
selected: 'Canada',
|
280
|
+
options: ['Canada']
|
281
|
+
)
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
285
|
+
it 'shows relevant shipping address states' do
|
286
|
+
visit spree.new_admin_order_path
|
287
|
+
click_link 'Customer'
|
288
|
+
within '#shipping' do
|
289
|
+
expect(page).to have_select(
|
290
|
+
'State',
|
291
|
+
options: [''] + canada.states.map(&:name)
|
292
|
+
)
|
293
|
+
end
|
294
|
+
end
|
295
|
+
|
296
|
+
it 'defaults the billing address country to Canada' do
|
297
|
+
visit spree.new_admin_order_path
|
298
|
+
click_link 'Customer'
|
299
|
+
within '#billing' do
|
300
|
+
expect(page).to have_select(
|
301
|
+
'Country',
|
302
|
+
selected: 'Canada',
|
303
|
+
options: ['Canada']
|
304
|
+
)
|
305
|
+
end
|
306
|
+
end
|
307
|
+
|
308
|
+
it 'shows relevant billing address states' do
|
309
|
+
visit spree.new_admin_order_path
|
310
|
+
click_link 'Customer'
|
311
|
+
within '#billing' do
|
312
|
+
expect(page).to have_select(
|
313
|
+
'State',
|
314
|
+
options: [''] + canada.states.map(&:name)
|
315
|
+
)
|
316
|
+
end
|
317
|
+
end
|
318
|
+
end
|
319
|
+
end
|
320
|
+
|
204
321
|
def fill_in_address
|
205
322
|
fill_in "First Name", with: "John 99"
|
206
323
|
fill_in "Last Name", with: "Doe"
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe 'New Refund creation', :js do
|
6
|
+
stub_authorization!
|
7
|
+
|
8
|
+
let(:order) { create :order_ready_to_ship }
|
9
|
+
let(:payment) { order.payments.first }
|
10
|
+
let(:amount) { '10.99' }
|
11
|
+
let!(:reason) { create :refund_reason }
|
12
|
+
|
13
|
+
it 'creates a new refund' do
|
14
|
+
visit spree.new_admin_order_payment_refund_path(order, payment)
|
15
|
+
expect(page).not_to have_selector 'td', text: amount
|
16
|
+
within '.new_refund' do
|
17
|
+
fill_in 'refund_amount', with: amount
|
18
|
+
select reason.name, from: 'Reason'
|
19
|
+
click_button 'Refund'
|
20
|
+
end
|
21
|
+
expect(page).to have_content 'Refund has been successfully created!'
|
22
|
+
expect(page).to have_selector 'td', text: amount
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'disables the button at submit' do
|
26
|
+
visit spree.new_admin_order_payment_refund_path(order, payment)
|
27
|
+
page.execute_script "$('form').submit(function(e) { e.preventDefault()})"
|
28
|
+
within '.new_refund' do
|
29
|
+
fill_in 'refund_amount', with: amount
|
30
|
+
select reason.name, from: 'Reason'
|
31
|
+
click_button 'Refund'
|
32
|
+
expect(find('input[type="submit"]')).to be_disabled
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -415,7 +415,7 @@ describe "Order Details", type: :feature, js: true do
|
|
415
415
|
it 'should not allow a shipment to split stock to itself' do
|
416
416
|
visit spree.edit_admin_order_path(order)
|
417
417
|
within('tr', text: line_item.sku) { click_icon 'arrows-h' }
|
418
|
-
click_on 'Choose
|
418
|
+
click_on 'Choose Location'
|
419
419
|
within '.select2-results' do
|
420
420
|
expect(page).to have_content(shipment2.number)
|
421
421
|
expect(page).not_to have_content(shipment1.number)
|
@@ -499,7 +499,7 @@ describe "Order Details", type: :feature, js: true do
|
|
499
499
|
|
500
500
|
context 'with only read permissions' do
|
501
501
|
before do
|
502
|
-
allow_any_instance_of(Spree::Admin::BaseController).to receive(:
|
502
|
+
allow_any_instance_of(Spree::Admin::BaseController).to receive(:try_spree_current_user).and_return(nil)
|
503
503
|
end
|
504
504
|
|
505
505
|
custom_authorization! do |_user|
|
@@ -22,7 +22,7 @@ describe 'Payments', type: :feature do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
# Regression tests for https://github.com/spree/spree/issues/1453
|
25
|
-
context 'with a check payment' do
|
25
|
+
context 'with a check payment', js: true do
|
26
26
|
let(:order) { create(:completed_order_with_totals, number: 'R100') }
|
27
27
|
let!(:payment) do
|
28
28
|
create(:payment,
|
@@ -205,7 +205,7 @@ describe 'Payments', type: :feature do
|
|
205
205
|
visit spree.admin_order_payments_path(order.reload)
|
206
206
|
end
|
207
207
|
|
208
|
-
it "can successfully be created and captured" do
|
208
|
+
it "can successfully be created and captured", js: true do
|
209
209
|
click_on 'Update'
|
210
210
|
expect(page).to have_content("Payment has been successfully created!")
|
211
211
|
click_icon(:capture)
|
@@ -7,9 +7,12 @@ describe "Return payment state spec" do
|
|
7
7
|
|
8
8
|
before do
|
9
9
|
Spree::RefundReason.create!(name: Spree::RefundReason::RETURN_PROCESSING_REASON, mutable: false)
|
10
|
+
allow_any_instance_of(Spree::Admin::ReimbursementsController).to receive(:try_spree_current_user).
|
11
|
+
and_return(user)
|
10
12
|
end
|
11
13
|
|
12
14
|
let!(:order) { create(:shipped_order) }
|
15
|
+
let(:user) { create(:admin_user) }
|
13
16
|
|
14
17
|
# Regression test for https://github.com/spree/spree/issues/6229
|
15
18
|
it "refunds and has outstanding_balance of zero", js: true do
|
@@ -58,6 +58,34 @@ describe "Shipments", type: :feature do
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
+
context "destroying a shipment", js: true do
|
62
|
+
before do
|
63
|
+
visit spree.admin_path
|
64
|
+
click_link "Orders"
|
65
|
+
within_row(1) do
|
66
|
+
click_link "R100"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
context "when the line item cannot be found" do
|
71
|
+
it "shows the proper error message" do
|
72
|
+
expect(page).to have_selector '.delete-item'
|
73
|
+
order.shipments.first.line_items.each(&:destroy)
|
74
|
+
accept_alert { first('.delete-item').click }
|
75
|
+
expect(page).to have_content 'The resource you were looking for could not be found.'
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
context "when the shipment has already been shipped" do
|
80
|
+
it "shows the proper error message" do
|
81
|
+
expect(page).to have_selector '.delete-item'
|
82
|
+
order.shipments.first.ship!
|
83
|
+
accept_alert { first('.delete-item').click }
|
84
|
+
expect(page).to have_content 'Cannot remove items from a shipped shipment'
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
61
89
|
context "moving variants between shipments", js: true do
|
62
90
|
let!(:order) { create(:completed_order_with_pending_payment, number: "R100", state: "complete", line_items_count: 5) }
|
63
91
|
let!(:la) { create(:stock_location, name: "LA") }
|
@@ -299,7 +299,7 @@ describe "Products", type: :feature do
|
|
299
299
|
|
300
300
|
context 'with only product permissions' do
|
301
301
|
before do
|
302
|
-
allow_any_instance_of(Spree::Admin::BaseController).to receive(:
|
302
|
+
allow_any_instance_of(Spree::Admin::BaseController).to receive(:try_spree_current_user).and_return(nil)
|
303
303
|
end
|
304
304
|
|
305
305
|
custom_authorization! do |_user|
|
@@ -44,31 +44,28 @@ describe "Product Stock", type: :feature do
|
|
44
44
|
it "can create a positive stock adjustment", js: true do
|
45
45
|
adjust_count_on_hand('14')
|
46
46
|
stock_item.reload
|
47
|
-
expect(stock_item.count_on_hand).to eq
|
47
|
+
expect(stock_item.count_on_hand).to eq 24
|
48
48
|
expect(stock_item.stock_movements.count).to eq 1
|
49
|
-
expect(stock_item.stock_movements.first.quantity).to eq
|
49
|
+
expect(stock_item.stock_movements.first.quantity).to eq 14
|
50
50
|
end
|
51
51
|
|
52
52
|
it "can create a negative stock adjustment", js: true do
|
53
|
-
adjust_count_on_hand('4')
|
53
|
+
adjust_count_on_hand('-4')
|
54
54
|
stock_item.reload
|
55
|
-
expect(stock_item.count_on_hand).to eq
|
55
|
+
expect(stock_item.count_on_hand).to eq 6
|
56
56
|
expect(stock_item.stock_movements.count).to eq 1
|
57
|
-
expect(stock_item.stock_movements.first.quantity).to eq(-
|
57
|
+
expect(stock_item.stock_movements.first.quantity).to eq(-4)
|
58
58
|
end
|
59
59
|
|
60
60
|
def adjust_count_on_hand(count_on_hand)
|
61
|
-
within(
|
62
|
-
|
63
|
-
|
64
|
-
find(:css, "input[type='number']").set(count_on_hand)
|
65
|
-
click_icon :check
|
66
|
-
end
|
61
|
+
within("tr#spree_variant_#{variant.id}") do
|
62
|
+
find(:css, "input[type='number']").set(count_on_hand)
|
63
|
+
click_icon :check
|
67
64
|
end
|
68
|
-
expect(page).to have_content('Updated
|
65
|
+
expect(page).to have_content('Updated Successfully')
|
69
66
|
end
|
70
67
|
|
71
|
-
context "with
|
68
|
+
context "with stock locations that don't have stock items for variant yet" do
|
72
69
|
before do
|
73
70
|
create(:stock_location, name: 'Other location', propagate_all_variants: false)
|
74
71
|
end
|