solidus_backend 2.10.0.beta1 → 2.10.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of solidus_backend might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/app/assets/javascripts/spree/backend.js +1 -0
- data/app/assets/javascripts/spree/backend/components/admin_nav.js +24 -0
- data/app/assets/javascripts/spree/backend/components/tabs.js +1 -1
- data/app/assets/javascripts/spree/backend/views/order/address.js +7 -5
- data/app/assets/stylesheets/spree/backend/_bootstrap_custom.scss +2 -0
- data/app/assets/stylesheets/spree/backend/components/_breadcrumb.scss +3 -3
- data/app/assets/stylesheets/spree/backend/components/_messages.scss +4 -0
- data/app/assets/stylesheets/spree/backend/components/_navigation.scss +182 -49
- data/app/assets/stylesheets/spree/backend/globals/_variables.scss +2 -0
- data/app/assets/stylesheets/spree/backend/shared/_header.scss +5 -1
- data/app/assets/stylesheets/spree/backend/shared/_layout.scss +0 -9
- data/app/controllers/spree/admin/orders_controller.rb +2 -2
- data/app/controllers/spree/admin/payment_methods_controller.rb +3 -3
- data/app/controllers/spree/admin/payments_controller.rb +2 -2
- data/app/controllers/spree/admin/product_properties_controller.rb +1 -1
- data/app/controllers/spree/admin/products_controller.rb +1 -1
- data/app/controllers/spree/admin/resource_controller.rb +12 -3
- data/app/controllers/spree/admin/taxons/attachment_controller.rb +20 -0
- data/app/controllers/spree/admin/users_controller.rb +4 -0
- data/app/helpers/spree/admin/orders_helper.rb +1 -1
- data/app/views/spree/admin/customer_returns/new.html.erb +1 -1
- data/app/views/spree/admin/option_types/edit.html.erb +1 -1
- data/app/views/spree/admin/orders/edit.html.erb +1 -1
- data/app/views/spree/admin/payment_methods/new.html.erb +1 -1
- data/app/views/spree/admin/prices/_master_variant_table.html.erb +41 -41
- data/app/views/spree/admin/promotion_code_batches/new.html.erb +1 -1
- data/app/views/spree/admin/promotion_codes/new.html.erb +1 -1
- data/app/views/spree/admin/promotions/_actions.html.erb +1 -0
- data/app/views/spree/admin/return_authorizations/new.html.erb +1 -1
- data/app/views/spree/admin/shared/_calculator_fields.html.erb +5 -0
- data/app/views/spree/admin/shared/_navigation.html.erb +3 -0
- data/app/views/spree/admin/shared/_new_resource_links.html.erb +1 -1
- data/app/views/spree/admin/shared/_settings_sub_menu.html.erb +1 -1
- data/app/views/spree/admin/shipping_methods/_form.html.erb +1 -1
- data/app/views/spree/admin/tax_rates/_form.html.erb +1 -1
- data/app/views/spree/admin/taxonomies/new.html.erb +1 -1
- data/app/views/spree/admin/taxons/_form.html.erb +1 -5
- data/app/views/spree/admin/taxons/attachment_forms/_paperclip.html.erb +16 -0
- data/app/views/spree/admin/users/_form.html.erb +12 -10
- data/app/views/spree/admin/users/edit.html.erb +1 -2
- data/app/views/spree/layouts/admin.html.erb +1 -2
- data/config/routes.rb +4 -6
- data/lib/spree/backend_configuration.rb +2 -1
- data/solidus_backend.gemspec +1 -1
- data/spec/controllers/spree/admin/resource_controller_spec.rb +12 -1
- data/spec/controllers/spree/admin/users_controller_spec.rb +23 -0
- data/spec/features/admin/configuration/payment_methods_spec.rb +11 -2
- data/spec/features/admin/configuration/shipping_methods_spec.rb +13 -1
- data/spec/features/admin/configuration/taxonomies_spec.rb +7 -0
- data/spec/features/admin/orders/customer_returns_spec.rb +20 -7
- data/spec/features/admin/orders/new_order_spec.rb +48 -0
- data/spec/features/admin/orders/return_authorizations_spec.rb +38 -9
- data/spec/features/admin/products/edit/images_spec.rb +1 -1
- data/spec/features/admin/products/products_spec.rb +12 -0
- data/spec/features/admin/promotion_adjustments_spec.rb +9 -0
- data/spec/features/admin/promotions/promotion_code_batches_spec.rb +37 -0
- data/spec/features/admin/promotions/promotion_code_spec.rb +31 -0
- data/spec/features/admin/taxons_spec.rb +12 -0
- data/spec/features/admin/users_spec.rb +18 -8
- data/spec/{support → fixtures/files}/ror_ringer.jpeg +0 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/support/feature/base_feature_helper.rb +6 -1
- data/vendor/assets/stylesheets/solidus_admin/bootstrap/_variables.scss +1 -1
- metadata +17 -12
@@ -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" %>
|
data/config/routes.rb
CHANGED
@@ -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
|
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
|
@@ -17,7 +17,8 @@ module Spree
|
|
17
17
|
:payment_methods, :shipping_methods,
|
18
18
|
:shipping_categories, :stock_locations,
|
19
19
|
:refund_reasons, :reimbursement_types,
|
20
|
-
:return_reasons, :adjustment_reasons
|
20
|
+
:return_reasons, :adjustment_reasons,
|
21
|
+
:store_credit_reasons]
|
21
22
|
PROMOTION_TABS ||= [:promotions, :promotion_categories]
|
22
23
|
STOCK_TABS ||= [:stock_items]
|
23
24
|
USER_TABS ||= [:users, :store_credits]
|
data/solidus_backend.gemspec
CHANGED
@@ -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.
|
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
|
@@ -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 "
|
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 "
|
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
|
@@ -38,6 +38,13 @@ describe "Taxonomies", type: :feature do
|
|
38
38
|
click_button "Create"
|
39
39
|
expect(page).to have_content("can't be blank")
|
40
40
|
end
|
41
|
+
|
42
|
+
it "disables the button at submit", :js do
|
43
|
+
page.execute_script "$('form').submit(function(e) { e.preventDefault()})"
|
44
|
+
fill_in "taxonomy_name", with: "sports"
|
45
|
+
click_button "Create"
|
46
|
+
expect(page).to have_button("Create", disabled: true)
|
47
|
+
end
|
41
48
|
end
|
42
49
|
|
43
50
|
context "edit" do
|
@@ -8,21 +8,34 @@ describe 'Customer returns', type: :feature do
|
|
8
8
|
context 'when the order has more than one line item' do
|
9
9
|
let(:order) { create :shipped_order, line_items_count: 2 }
|
10
10
|
|
11
|
+
def create_customer_return
|
12
|
+
find('#select-all').click
|
13
|
+
page.execute_script "$('select.add-item').val('receive')"
|
14
|
+
select 'NY Warehouse', from: 'Stock Location'
|
15
|
+
click_button 'Create'
|
16
|
+
end
|
17
|
+
|
18
|
+
before do
|
19
|
+
visit spree.new_admin_order_customer_return_path(order)
|
20
|
+
end
|
21
|
+
|
11
22
|
context 'when creating a return with state "Received"' do
|
12
23
|
it 'marks the order as returned', :js do
|
13
|
-
|
14
|
-
|
15
|
-
find('#select-all').click
|
16
|
-
page.execute_script "$('select.add-item').val('receive')"
|
17
|
-
select 'NY Warehouse', from: 'Stock Location'
|
18
|
-
click_button 'Create'
|
24
|
+
create_customer_return
|
19
25
|
|
20
26
|
expect(page).to have_content 'Customer Return has been successfully created'
|
21
|
-
|
22
27
|
within 'dd.order-state' do
|
23
28
|
expect(page).to have_content 'Returned'
|
24
29
|
end
|
25
30
|
end
|
26
31
|
end
|
32
|
+
|
33
|
+
it 'disables the button at submit', :js do
|
34
|
+
page.execute_script "$('form').submit(function(e) { e.preventDefault()})"
|
35
|
+
|
36
|
+
create_customer_return
|
37
|
+
|
38
|
+
expect(page).to have_button("Create", disabled: true)
|
39
|
+
end
|
27
40
|
end
|
28
41
|
end
|
@@ -169,6 +169,54 @@ describe "New Order", type: :feature do
|
|
169
169
|
end
|
170
170
|
end
|
171
171
|
|
172
|
+
context "when changing customer", :js do
|
173
|
+
let!(:other_user) { create :user, bill_address: bill_address }
|
174
|
+
|
175
|
+
context "when one customer address have only textual state" do
|
176
|
+
let(:country) { create :country, iso: "IT" }
|
177
|
+
let(:bill_address) { create :address, country: country, state: nil, state_name: "Veneto" }
|
178
|
+
|
179
|
+
it "changes the bill address state accordingly" do
|
180
|
+
click_on "Customer"
|
181
|
+
|
182
|
+
within "#select-customer" do
|
183
|
+
targetted_select2_search user.email, from: "#s2id_customer_search"
|
184
|
+
end
|
185
|
+
|
186
|
+
expect(find("select#order_bill_address_attributes_state_id").value).to eq user.bill_address.state_id.to_s
|
187
|
+
|
188
|
+
within "#select-customer" do
|
189
|
+
targetted_select2_search other_user.email, from: "#s2id_customer_search"
|
190
|
+
end
|
191
|
+
|
192
|
+
expect(find("select#order_bill_address_attributes_state_id", visible: false).value).to eq ""
|
193
|
+
expect(find("#order_bill_address_attributes_state_name").value).to eq other_user.bill_address.state_name
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
context "when customers have same country but different state" do
|
198
|
+
let(:different_state) { Spree::State.where.not(id: user.bill_address.state_id).first }
|
199
|
+
|
200
|
+
let(:bill_address) { create :address, country: user.bill_address.country, state: different_state }
|
201
|
+
|
202
|
+
it "changes the bill address state accordingly" do
|
203
|
+
click_on "Customer"
|
204
|
+
|
205
|
+
within "#select-customer" do
|
206
|
+
targetted_select2_search user.email, from: "#s2id_customer_search"
|
207
|
+
end
|
208
|
+
|
209
|
+
expect(find('#order_bill_address_attributes_state_id').value).to eq user.bill_address.state_id.to_s
|
210
|
+
|
211
|
+
within "#select-customer" do
|
212
|
+
targetted_select2_search other_user.email, from: "#s2id_customer_search"
|
213
|
+
end
|
214
|
+
|
215
|
+
expect(find('#order_bill_address_attributes_state_id').value).to eq other_user.bill_address.state_id.to_s
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
172
220
|
# Regression test for https://github.com/spree/spree/issues/5327
|
173
221
|
context "customer with default credit card", js: true do
|
174
222
|
let!(:credit_card) { create(:credit_card, user: user) }
|
@@ -8,20 +8,49 @@ describe "ReturnAuthorizations", type: :feature do
|
|
8
8
|
stub_authorization!
|
9
9
|
|
10
10
|
let!(:order) { create(:shipped_order) }
|
11
|
-
let!(:return_authorization) { create(:return_authorization, order: order) }
|
12
11
|
|
13
|
-
|
14
|
-
|
12
|
+
describe "create" do
|
13
|
+
def create_return_authorization
|
14
|
+
find("#select-all").click
|
15
|
+
select "NY Warehouse", from: "Stock Location"
|
16
|
+
click_button "Create"
|
17
|
+
end
|
18
|
+
|
19
|
+
before do
|
20
|
+
visit spree.new_admin_order_return_authorization_path(order)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "creates a return authorization" do
|
24
|
+
create_return_authorization
|
25
|
+
|
26
|
+
expect(page).to have_content "Return Authorization has been successfully created!"
|
27
|
+
end
|
28
|
+
|
29
|
+
it "disables the button at submit", :js do
|
30
|
+
page.execute_script "$('form').submit(function(e) { e.preventDefault()})"
|
31
|
+
|
32
|
+
create_return_authorization
|
33
|
+
|
34
|
+
expect(page).to have_button("Create", disabled: true)
|
35
|
+
end
|
15
36
|
end
|
16
37
|
|
17
|
-
describe "
|
18
|
-
|
19
|
-
|
38
|
+
describe "when a return authorization exists" do
|
39
|
+
let!(:return_authorization) { create(:return_authorization, order: order) }
|
40
|
+
|
41
|
+
it "can visit the return authorizations list page" do
|
42
|
+
visit spree.admin_order_return_authorizations_path(order)
|
20
43
|
end
|
21
44
|
|
22
|
-
|
23
|
-
visit
|
24
|
-
|
45
|
+
describe "edit" do
|
46
|
+
it "can visit the return authorizations edit page" do
|
47
|
+
visit spree.edit_admin_order_return_authorization_path(order, return_authorization)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "return authorizations edit page has a data hook for extensions to add content above, below or within the RA form" do
|
51
|
+
visit spree.edit_admin_order_return_authorization_path(order, return_authorization)
|
52
|
+
expect(page).to have_selector("[data-hook=return-authorization-form-wrapper]")
|
53
|
+
end
|
25
54
|
end
|
26
55
|
end
|
27
56
|
end
|
@@ -5,7 +5,7 @@ require 'spec_helper'
|
|
5
5
|
describe "Product Images", type: :feature do
|
6
6
|
stub_authorization!
|
7
7
|
|
8
|
-
let(:file_path) {
|
8
|
+
let(:file_path) { file_fixture("ror_ringer.jpeg") }
|
9
9
|
let(:product) { create(:product) }
|
10
10
|
|
11
11
|
before do
|
@@ -172,6 +172,18 @@ describe "Products", type: :feature do
|
|
172
172
|
expect(page).to have_content("successfully updated!")
|
173
173
|
end
|
174
174
|
|
175
|
+
it "disables the button at submit", :js do
|
176
|
+
page.execute_script "$('form').submit(function(e) { e.preventDefault()})"
|
177
|
+
fill_in "product_name", with: "Baseball Cap"
|
178
|
+
fill_in "product_sku", with: "B100"
|
179
|
+
fill_in "product_price", with: "100"
|
180
|
+
fill_in "product_available_on", with: "2012/01/24"
|
181
|
+
select @shipping_category.name, from: "product_shipping_category_id"
|
182
|
+
click_button "Create"
|
183
|
+
|
184
|
+
expect(page).to have_button("Create", disabled: true)
|
185
|
+
end
|
186
|
+
|
175
187
|
it "should show validation errors", js: false do
|
176
188
|
fill_in "product_name", with: "Baseball Cap"
|
177
189
|
fill_in "product_sku", with: "B100"
|
@@ -167,6 +167,15 @@ describe "Promotion Adjustments", type: :feature, js: true do
|
|
167
167
|
expect(promotion.actions.first).to be_a(Spree::Promotion::Actions::FreeShipping)
|
168
168
|
end
|
169
169
|
|
170
|
+
it "disables the button at submit", :js do
|
171
|
+
page.execute_script "$('form').submit(function(e) { e.preventDefault()})"
|
172
|
+
fill_in "Name", with: "SAVE SAVE SAVE"
|
173
|
+
choose "Apply to all orders"
|
174
|
+
click_button "Create"
|
175
|
+
|
176
|
+
expect(page).to have_button("Create", disabled: true)
|
177
|
+
end
|
178
|
+
|
170
179
|
it "should allow an admin to create an automatic promotion" do
|
171
180
|
fill_in "Name", with: "SAVE SAVE SAVE"
|
172
181
|
choose "Apply to all orders"
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
feature "Promotion Code Batches", partial_double_verification: false do
|
6
|
+
stub_authorization!
|
7
|
+
|
8
|
+
describe "create" do
|
9
|
+
let(:promotion) { create :promotion }
|
10
|
+
|
11
|
+
before do
|
12
|
+
user = double.as_null_object
|
13
|
+
allow_any_instance_of(ActionView::Base).to receive(:spree_current_user) { user }
|
14
|
+
visit spree.new_admin_promotion_promotion_code_batch_path(promotion)
|
15
|
+
end
|
16
|
+
|
17
|
+
def create_code_batch
|
18
|
+
fill_in "Base code", with: "base"
|
19
|
+
fill_in "Number of codes", with: 3
|
20
|
+
click_button "Create"
|
21
|
+
end
|
22
|
+
|
23
|
+
it "creates a new promotion code batch and disables the submit button", :js do
|
24
|
+
create_code_batch
|
25
|
+
|
26
|
+
expect(page).to have_content "Promotion Code Batch has been successfully created!"
|
27
|
+
|
28
|
+
visit spree.new_admin_promotion_promotion_code_batch_path(promotion)
|
29
|
+
|
30
|
+
page.execute_script "$('form').submit(function(e) { e.preventDefault()})"
|
31
|
+
|
32
|
+
create_code_batch
|
33
|
+
|
34
|
+
expect(page).to have_button("Create", disabled: true)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
feature "Promotion Codes" do
|
6
|
+
stub_authorization!
|
7
|
+
|
8
|
+
describe "create" do
|
9
|
+
let(:promotion) { create :promotion }
|
10
|
+
|
11
|
+
before do
|
12
|
+
visit spree.new_admin_promotion_promotion_code_path(promotion)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "creates a new promotion code" do
|
16
|
+
fill_in "Value", with: "XYZ"
|
17
|
+
click_button "Create"
|
18
|
+
|
19
|
+
expect(page).to have_content "Promotion Code has been successfully created!"
|
20
|
+
end
|
21
|
+
|
22
|
+
it "disables the button at submit", :js do
|
23
|
+
page.execute_script "$('form').submit(function(e) { e.preventDefault()})"
|
24
|
+
|
25
|
+
fill_in "Value", with: "XYZ"
|
26
|
+
click_button "Create"
|
27
|
+
|
28
|
+
expect(page).to have_button("Create", disabled: true)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|