spree_backend 3.1.5 → 3.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/spree/admin/orders_controller.rb +1 -3
- data/app/controllers/spree/admin/products_controller.rb +1 -1
- data/app/views/spree/admin/products/_form.html.erb +8 -8
- data/app/views/spree/admin/products/index.html.erb +1 -1
- data/app/views/spree/admin/shared/_product_tabs.html.erb +4 -4
- data/app/views/spree/admin/taxons/edit.html.erb +1 -1
- data/spree_backend.gemspec +1 -1
- metadata +7 -98
- data/spec/controllers/spree/admin/base_controller_spec.rb +0 -46
- data/spec/controllers/spree/admin/customer_returns_controller_spec.rb +0 -185
- data/spec/controllers/spree/admin/general_settings_controller_spec.rb +0 -41
- data/spec/controllers/spree/admin/missing_products_controller_spec.rb +0 -18
- data/spec/controllers/spree/admin/orders/customer_details_controller_spec.rb +0 -197
- data/spec/controllers/spree/admin/orders_controller_spec.rb +0 -254
- data/spec/controllers/spree/admin/payment_methods_controller_spec.rb +0 -49
- data/spec/controllers/spree/admin/payments_controller_spec.rb +0 -97
- data/spec/controllers/spree/admin/products_controller_spec.rb +0 -99
- data/spec/controllers/spree/admin/promotion_actions_controller_spec.rb +0 -21
- data/spec/controllers/spree/admin/promotion_rules_controller_spec.rb +0 -21
- data/spec/controllers/spree/admin/promotions_controller_spec.rb +0 -44
- data/spec/controllers/spree/admin/refunds_controller_spec.rb +0 -32
- data/spec/controllers/spree/admin/reimbursements_controller_spec.rb +0 -74
- data/spec/controllers/spree/admin/reports_controller_spec.rb +0 -42
- data/spec/controllers/spree/admin/resource_controller_spec.rb +0 -252
- data/spec/controllers/spree/admin/return_authorizations_controller_spec.rb +0 -225
- data/spec/controllers/spree/admin/return_index_controller_spec.rb +0 -37
- data/spec/controllers/spree/admin/return_items_controller_spec.rb +0 -27
- data/spec/controllers/spree/admin/root_controller_spec.rb +0 -35
- data/spec/controllers/spree/admin/search_controller_spec.rb +0 -56
- data/spec/controllers/spree/admin/shipping_methods_controller_spec.rb +0 -14
- data/spec/controllers/spree/admin/stock_items_controller_spec.rb +0 -19
- data/spec/controllers/spree/admin/stock_locations_controller_spec.rb +0 -41
- data/spec/controllers/spree/admin/stock_transfers_controller_spec.rb +0 -41
- data/spec/controllers/spree/admin/tax_categories_controller_spec.rb +0 -34
- data/spec/controllers/spree/admin/users_controller_spec.rb +0 -161
- data/spec/controllers/spree/admin/variants_controller_spec.rb +0 -32
- data/spec/features/admin/configuration/analytics_tracker_spec.rb +0 -47
- data/spec/features/admin/configuration/countries_spec.rb +0 -24
- data/spec/features/admin/configuration/general_settings_spec.rb +0 -44
- data/spec/features/admin/configuration/payment_methods_spec.rb +0 -63
- data/spec/features/admin/configuration/roles_spec.rb +0 -47
- data/spec/features/admin/configuration/shipping_methods_spec.rb +0 -62
- data/spec/features/admin/configuration/states_spec.rb +0 -68
- data/spec/features/admin/configuration/stock_locations_spec.rb +0 -48
- data/spec/features/admin/configuration/store_credit_categories_spec.rb +0 -50
- data/spec/features/admin/configuration/tax_categories_spec.rb +0 -56
- data/spec/features/admin/configuration/tax_rates_spec.rb +0 -18
- data/spec/features/admin/configuration/zones_spec.rb +0 -39
- data/spec/features/admin/homepage_spec.rb +0 -89
- data/spec/features/admin/locale_spec.rb +0 -31
- data/spec/features/admin/orders/adjustments_promotions_spec.rb +0 -53
- data/spec/features/admin/orders/adjustments_spec.rb +0 -129
- data/spec/features/admin/orders/cancelling_and_resuming_spec.rb +0 -47
- data/spec/features/admin/orders/customer_details_spec.rb +0 -154
- data/spec/features/admin/orders/line_items_spec.rb +0 -51
- data/spec/features/admin/orders/listing_spec.rb +0 -222
- data/spec/features/admin/orders/log_entries_spec.rb +0 -55
- data/spec/features/admin/orders/new_order_spec.rb +0 -160
- data/spec/features/admin/orders/order_details_spec.rb +0 -662
- data/spec/features/admin/orders/payments_spec.rb +0 -230
- data/spec/features/admin/orders/risk_analysis_spec.rb +0 -48
- data/spec/features/admin/orders/shipments_spec.rb +0 -64
- data/spec/features/admin/orders/state_changes_spec.rb +0 -21
- data/spec/features/admin/products/edit/images_spec.rb +0 -86
- data/spec/features/admin/products/edit/products_spec.rb +0 -64
- data/spec/features/admin/products/edit/taxons_spec.rb +0 -41
- data/spec/features/admin/products/edit/variants_spec.rb +0 -56
- data/spec/features/admin/products/option_types_spec.rb +0 -114
- data/spec/features/admin/products/products_spec.rb +0 -445
- data/spec/features/admin/products/properties_spec.rb +0 -147
- data/spec/features/admin/products/prototypes_spec.rb +0 -112
- data/spec/features/admin/products/stock_management_spec.rb +0 -124
- data/spec/features/admin/products/taxonomies_spec.rb +0 -52
- data/spec/features/admin/products/variant_spec.rb +0 -50
- data/spec/features/admin/promotions/adjustments_spec.rb +0 -259
- data/spec/features/admin/promotions/option_value_rule_spec.rb +0 -70
- data/spec/features/admin/promotions/tiered_calculator_spec.rb +0 -70
- data/spec/features/admin/refund_reasons/refund_reasons_spec.rb +0 -57
- data/spec/features/admin/reports_spec.rb +0 -61
- data/spec/features/admin/return_authorization_reasons/return_authorization_reasons_spec.rb +0 -63
- data/spec/features/admin/returns/customer_returns_spec.rb +0 -80
- data/spec/features/admin/returns/return_authorizations_spec.rb +0 -152
- data/spec/features/admin/stock_transfer_spec.rb +0 -75
- data/spec/features/admin/store_credits_spec.rb +0 -93
- data/spec/features/admin/taxons_spec.rb +0 -47
- data/spec/features/admin/users_spec.rb +0 -286
- data/spec/helpers/admin/base_helper_spec.rb +0 -30
- data/spec/helpers/admin/navigation_helper_spec.rb +0 -106
- data/spec/helpers/admin/stock_movements_helper_spec.rb +0 -30
- data/spec/helpers/promotion_rules_helper_spec.rb +0 -12
- data/spec/models/spree/resource_spec.rb +0 -48
- data/spec/routing/admin_path_spec.rb +0 -22
- data/spec/spec_helper.rb +0 -134
- data/spec/support/appear_before_matcher.rb +0 -8
- data/spec/support/ror_ringer.jpeg +0 -0
- data/spec/test_views/spree/admin/submodule/posts/edit.html.erb +0 -1
- data/spec/test_views/spree/admin/submodule/posts/new.html.erb +0 -1
- data/spec/test_views/spree/admin/widgets/edit.html.erb +0 -1
- data/spec/test_views/spree/admin/widgets/new.html.erb +0 -1
@@ -1,259 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "Promotion Adjustments", type: :feature, js: true do
|
4
|
-
stub_authorization!
|
5
|
-
|
6
|
-
context "coupon promotions" do
|
7
|
-
before(:each) do
|
8
|
-
visit spree.admin_promotions_path
|
9
|
-
click_on "New Promotion"
|
10
|
-
end
|
11
|
-
|
12
|
-
it "should allow an admin to create a flat rate discount coupon promo" do
|
13
|
-
fill_in "Name", with: "Promotion"
|
14
|
-
fill_in "Code", with: "order"
|
15
|
-
click_button "Create"
|
16
|
-
promotion = Spree::Promotion.find_by_name("Promotion")
|
17
|
-
expect(page).to have_content(promotion.name)
|
18
|
-
|
19
|
-
select2 "Item total", from: "Add rule of type"
|
20
|
-
within('#rule_fields') { click_button "Add" }
|
21
|
-
|
22
|
-
eventually_fill_in "promotion_promotion_rules_attributes_#{Spree::Promotion.count}_preferred_amount_min", :with => 30
|
23
|
-
eventually_fill_in "promotion_promotion_rules_attributes_#{Spree::Promotion.count}_preferred_amount_max", :with => 60
|
24
|
-
within('#rule_fields') { click_button "Update" }
|
25
|
-
|
26
|
-
select2 "Create whole-order adjustment", from: "Add action of type"
|
27
|
-
within('#action_fields') { click_button "Add" }
|
28
|
-
select2 "Flat Rate", from: "Calculator"
|
29
|
-
within('#actions_container') { click_button "Update" }
|
30
|
-
|
31
|
-
within('.calculator-fields') { fill_in "Amount", with: 5 }
|
32
|
-
within('#actions_container') { click_button "Update" }
|
33
|
-
|
34
|
-
expect(promotion.code).to eq("order")
|
35
|
-
|
36
|
-
first_rule = promotion.rules.first
|
37
|
-
expect(first_rule.class).to eq(Spree::Promotion::Rules::ItemTotal)
|
38
|
-
expect(first_rule.preferred_amount_min).to eq(30)
|
39
|
-
expect(first_rule.preferred_amount_max).to eq(60)
|
40
|
-
|
41
|
-
first_action = promotion.actions.first
|
42
|
-
expect(first_action.class).to eq(Spree::Promotion::Actions::CreateAdjustment)
|
43
|
-
first_action_calculator = first_action.calculator
|
44
|
-
expect(first_action_calculator.class).to eq(Spree::Calculator::FlatRate)
|
45
|
-
expect(first_action_calculator.preferred_amount).to eq(5)
|
46
|
-
end
|
47
|
-
|
48
|
-
it "should allow an admin to create a single user coupon promo with flat rate discount" do
|
49
|
-
fill_in "Name", with: "Promotion"
|
50
|
-
fill_in "Usage Limit", with: "1"
|
51
|
-
fill_in "Code", with: "single_use"
|
52
|
-
click_button "Create"
|
53
|
-
promotion = Spree::Promotion.find_by_name("Promotion")
|
54
|
-
expect(page).to have_content(promotion.name)
|
55
|
-
|
56
|
-
select2 "Create whole-order adjustment", from: "Add action of type"
|
57
|
-
within('#action_fields') { click_button "Add" }
|
58
|
-
select2 "Flat Rate", from: "Calculator"
|
59
|
-
within('#actions_container') { click_button "Update" }
|
60
|
-
within('#action_fields') { fill_in "Amount", with: "5" }
|
61
|
-
within('#actions_container') { click_button "Update" }
|
62
|
-
|
63
|
-
expect(promotion.usage_limit).to eq(1)
|
64
|
-
expect(promotion.code).to eq("single_use")
|
65
|
-
|
66
|
-
first_action = promotion.actions.first
|
67
|
-
expect(first_action.class).to eq(Spree::Promotion::Actions::CreateAdjustment)
|
68
|
-
first_action_calculator = first_action.calculator
|
69
|
-
expect(first_action_calculator.class).to eq(Spree::Calculator::FlatRate)
|
70
|
-
expect(first_action_calculator.preferred_amount).to eq(5)
|
71
|
-
end
|
72
|
-
|
73
|
-
it "should allow an admin to create an automatic promo with flat percent discount" do
|
74
|
-
fill_in "Name", with: "Promotion"
|
75
|
-
click_button "Create"
|
76
|
-
promotion = Spree::Promotion.find_by_name("Promotion")
|
77
|
-
|
78
|
-
expect(page).to have_content(promotion.name)
|
79
|
-
|
80
|
-
select2 "Item total", from: "Add rule of type"
|
81
|
-
within('#rule_fields') { click_button "Add" }
|
82
|
-
|
83
|
-
eventually_fill_in "promotion_promotion_rules_attributes_1_preferred_amount_min", with: 30
|
84
|
-
eventually_fill_in "promotion_promotion_rules_attributes_1_preferred_amount_max", with: 60
|
85
|
-
within('#rule_fields') { click_button "Update" }
|
86
|
-
|
87
|
-
select2 "Create whole-order adjustment", from: "Add action of type"
|
88
|
-
within('#action_fields') { click_button "Add" }
|
89
|
-
select2 "Flat Percent", from: "Calculator"
|
90
|
-
within('#actions_container') { click_button "Update" }
|
91
|
-
within('.calculator-fields') { fill_in "Flat Percent", with: "10" }
|
92
|
-
within('#actions_container') { click_button "Update" }
|
93
|
-
|
94
|
-
expect(promotion.code).to be_blank
|
95
|
-
|
96
|
-
first_rule = promotion.rules.first
|
97
|
-
expect(first_rule.class).to eq(Spree::Promotion::Rules::ItemTotal)
|
98
|
-
expect(first_rule.preferred_amount_min).to eq(30)
|
99
|
-
expect(first_rule.preferred_amount_max).to eq(60)
|
100
|
-
|
101
|
-
first_action = promotion.actions.first
|
102
|
-
expect(first_action.class).to eq(Spree::Promotion::Actions::CreateAdjustment)
|
103
|
-
first_action_calculator = first_action.calculator
|
104
|
-
expect(first_action_calculator.class).to eq(Spree::Calculator::FlatPercentItemTotal)
|
105
|
-
expect(first_action_calculator.preferred_flat_percent).to eq(10)
|
106
|
-
end
|
107
|
-
|
108
|
-
it "should allow an admin to create an product promo with percent per item discount" do
|
109
|
-
create(:product, name: "RoR Mug")
|
110
|
-
|
111
|
-
fill_in "Name", with: "Promotion"
|
112
|
-
click_button "Create"
|
113
|
-
promotion = Spree::Promotion.find_by_name("Promotion")
|
114
|
-
|
115
|
-
expect(page).to have_content(promotion.name)
|
116
|
-
|
117
|
-
select2 "Product(s)", from: "Add rule of type"
|
118
|
-
within("#rule_fields") { click_button "Add" }
|
119
|
-
select2_search "RoR Mug", from: "Choose products"
|
120
|
-
within('#rule_fields') { click_button "Update" }
|
121
|
-
|
122
|
-
select2 "Create per-line-item adjustment", from: "Add action of type"
|
123
|
-
within('#action_fields') { click_button "Add" }
|
124
|
-
select2 "Percent Per Item", from: "Calculator"
|
125
|
-
within('#actions_container') { click_button "Update" }
|
126
|
-
within('.calculator-fields') { fill_in "Percent", with: "10" }
|
127
|
-
within('#actions_container') { click_button "Update" }
|
128
|
-
|
129
|
-
expect(promotion.code).to be_blank
|
130
|
-
|
131
|
-
first_rule = promotion.rules.first
|
132
|
-
expect(first_rule.class).to eq(Spree::Promotion::Rules::Product)
|
133
|
-
expect(first_rule.products.map(&:name)).to include("RoR Mug")
|
134
|
-
|
135
|
-
first_action = promotion.actions.first
|
136
|
-
expect(first_action.class).to eq(Spree::Promotion::Actions::CreateItemAdjustments)
|
137
|
-
first_action_calculator = first_action.calculator
|
138
|
-
expect(first_action_calculator.class).to eq(Spree::Calculator::PercentOnLineItem)
|
139
|
-
expect(first_action_calculator.preferred_percent).to eq(10)
|
140
|
-
end
|
141
|
-
|
142
|
-
xit "should allow an admin to create an automatic promotion with free shipping (no code)" do
|
143
|
-
fill_in "Name", with: "Promotion"
|
144
|
-
click_button "Create"
|
145
|
-
expect(page).to have_content("Editing Promotion")
|
146
|
-
|
147
|
-
select2 "Item total", from: "Add rule of type"
|
148
|
-
within('#rule_fields') { click_button "Add" }
|
149
|
-
eventually_fill_in "promotion_promotion_rules_attributes_1_preferred_amount", with: "30"
|
150
|
-
within('#rule_fields') { click_button "Update" }
|
151
|
-
|
152
|
-
select2 "Create whole-order adjustment", from: "Add action of type"
|
153
|
-
within('#action_fields') { click_button "Add" }
|
154
|
-
select2 "Free Shipping", from: "Calculator"
|
155
|
-
within('#actions_container') { click_button "Update" }
|
156
|
-
|
157
|
-
promotion = Spree::Promotion.find_by_name("Promotion")
|
158
|
-
expect(promotion.code).to be_blank
|
159
|
-
|
160
|
-
first_rule = promotion.rules.first
|
161
|
-
expect(first_rule.class).to eq(Spree::Promotion::Rules::ItemTotal)
|
162
|
-
|
163
|
-
first_action = promotion.actions.first
|
164
|
-
expect(first_action.class).to eq(Spree::Promotion::Actions::CreateAdjustment)
|
165
|
-
first_action_calculator = first_action.calculator
|
166
|
-
expect(first_action_calculator.class).to eq(Spree::Calculator::FreeShipping)
|
167
|
-
end
|
168
|
-
|
169
|
-
it "should allow an admin to create an automatic promo requiring a landing page to be visited" do
|
170
|
-
fill_in "Name", with: "Promotion"
|
171
|
-
fill_in "Path", with: "content/cvv"
|
172
|
-
click_button "Create"
|
173
|
-
promotion = Spree::Promotion.find_by_name("Promotion")
|
174
|
-
|
175
|
-
expect(page).to have_content(promotion.name)
|
176
|
-
|
177
|
-
select2 "Create whole-order adjustment", from: "Add action of type"
|
178
|
-
within('#action_fields') { click_button "Add" }
|
179
|
-
select2 "Flat Rate", from: "Calculator"
|
180
|
-
within('#actions_container') { click_button "Update" }
|
181
|
-
within('.calculator-fields') { fill_in "Amount", with: "4" }
|
182
|
-
within('#actions_container') { click_button "Update" }
|
183
|
-
|
184
|
-
expect(promotion.path).to eq("content/cvv")
|
185
|
-
expect(promotion.code).to be_blank
|
186
|
-
expect(promotion.rules).to be_blank
|
187
|
-
|
188
|
-
first_action = promotion.actions.first
|
189
|
-
expect(first_action.class).to eq(Spree::Promotion::Actions::CreateAdjustment)
|
190
|
-
first_action_calculator = first_action.calculator
|
191
|
-
expect(first_action_calculator.class).to eq(Spree::Calculator::FlatRate)
|
192
|
-
expect(first_action_calculator.preferred_amount).to eq(4)
|
193
|
-
end
|
194
|
-
|
195
|
-
it "should allow an admin to create a promotion that adds a 'free' item to the cart" do
|
196
|
-
create(:product, name: "RoR Mug")
|
197
|
-
fill_in "Name", with: "Promotion"
|
198
|
-
fill_in "Code", with: "complex"
|
199
|
-
click_button "Create"
|
200
|
-
promotion = Spree::Promotion.find_by_name("Promotion")
|
201
|
-
|
202
|
-
expect(page).to have_content(promotion.name)
|
203
|
-
|
204
|
-
select2 "Create line items", from: "Add action of type"
|
205
|
-
|
206
|
-
within('#action_fields') { click_button "Add" }
|
207
|
-
|
208
|
-
page.find('.create_line_items .select2-choice').click
|
209
|
-
page.find('.select2-input').set('RoR Mug')
|
210
|
-
page.find('.select2-highlighted').click
|
211
|
-
|
212
|
-
within('#actions_container') { click_button "Update" }
|
213
|
-
|
214
|
-
select2 "Create whole-order adjustment", from: "Add action of type"
|
215
|
-
within('#new_promotion_action_form') { click_button "Add" }
|
216
|
-
select2 "Flat Rate", from: "Calculator"
|
217
|
-
within('#actions_container') { click_button "Update" }
|
218
|
-
within('.create_adjustment .calculator-fields') { fill_in "Amount", with: "40.00" }
|
219
|
-
within('#actions_container') { click_button "Update" }
|
220
|
-
|
221
|
-
expect(promotion.code).to eq("complex")
|
222
|
-
|
223
|
-
first_action = promotion.actions.first
|
224
|
-
expect(first_action.class).to eq(Spree::Promotion::Actions::CreateLineItems)
|
225
|
-
line_item = expect(first_action.promotion_action_line_items).not_to be_empty
|
226
|
-
end
|
227
|
-
|
228
|
-
it "ceasing to be eligible for a promotion with item total rule then becoming eligible again" do
|
229
|
-
fill_in "Name", with: "Promotion"
|
230
|
-
click_button "Create"
|
231
|
-
promotion = Spree::Promotion.find_by_name("Promotion")
|
232
|
-
|
233
|
-
expect(page).to have_content(promotion.name)
|
234
|
-
|
235
|
-
select2 "Item total", from: "Add rule of type"
|
236
|
-
within('#rule_fields') { click_button "Add" }
|
237
|
-
eventually_fill_in "promotion_promotion_rules_attributes_1_preferred_amount_min", with: "50"
|
238
|
-
eventually_fill_in "promotion_promotion_rules_attributes_1_preferred_amount_max", with: "150"
|
239
|
-
within('#rule_fields') { click_button "Update" }
|
240
|
-
|
241
|
-
select2 "Create whole-order adjustment", from: "Add action of type"
|
242
|
-
within('#action_fields') { click_button "Add" }
|
243
|
-
select2 "Flat Rate", from: "Calculator"
|
244
|
-
within('#actions_container') { click_button "Update" }
|
245
|
-
within('.calculator-fields') { fill_in "Amount", with: "5" }
|
246
|
-
within('#actions_container') { click_button "Update" }
|
247
|
-
|
248
|
-
first_rule = promotion.rules.first
|
249
|
-
expect(first_rule.class).to eq(Spree::Promotion::Rules::ItemTotal)
|
250
|
-
expect(first_rule.preferred_amount_min).to eq(50)
|
251
|
-
expect(first_rule.preferred_amount_max).to eq(150)
|
252
|
-
|
253
|
-
first_action = promotion.actions.first
|
254
|
-
expect(first_action.class).to eq(Spree::Promotion::Actions::CreateAdjustment)
|
255
|
-
expect(first_action.calculator.class).to eq(Spree::Calculator::FlatRate)
|
256
|
-
expect(first_action.calculator.preferred_amount).to eq(5)
|
257
|
-
end
|
258
|
-
end
|
259
|
-
end
|
@@ -1,70 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
feature 'Promotion with option value rule' do
|
4
|
-
stub_authorization!
|
5
|
-
|
6
|
-
given(:variant) { create :variant }
|
7
|
-
given!(:product) { variant.product }
|
8
|
-
given!(:option_value) { variant.option_values.first }
|
9
|
-
|
10
|
-
given(:promotion) { create :promotion }
|
11
|
-
|
12
|
-
background do
|
13
|
-
visit spree.edit_admin_promotion_path(promotion)
|
14
|
-
end
|
15
|
-
|
16
|
-
scenario "adding an option value rule", js: true do
|
17
|
-
select2 "Option Value(s)", from: "Add rule of type"
|
18
|
-
within("#rule_fields") { click_button "Add" }
|
19
|
-
|
20
|
-
within("#rules .promotion-block") do
|
21
|
-
click_button "Add"
|
22
|
-
|
23
|
-
expect(page.body).to have_content("Product")
|
24
|
-
expect(page.body).to have_content("Option Values")
|
25
|
-
end
|
26
|
-
|
27
|
-
within('.promo-rule-option-value') do
|
28
|
-
targetted_select2_search product.name, from: '.js-promo-rule-option-value-product-select'
|
29
|
-
targetted_select2_search(
|
30
|
-
option_value.name,
|
31
|
-
from: '.js-promo-rule-option-value-option-values-select'
|
32
|
-
)
|
33
|
-
end
|
34
|
-
|
35
|
-
within('#rules_container') { click_button "Update" }
|
36
|
-
|
37
|
-
first_rule = promotion.rules(true).first
|
38
|
-
expect(first_rule.class).to eq Spree::Promotion::Rules::OptionValue
|
39
|
-
expect(first_rule.preferred_eligible_values).to eq Hash[product.id => [option_value.id]]
|
40
|
-
end
|
41
|
-
|
42
|
-
context "with an existing option value rule" do
|
43
|
-
given(:variant1) { create :variant }
|
44
|
-
given(:variant2) { create :variant }
|
45
|
-
background do
|
46
|
-
rule = Spree::Promotion::Rules::OptionValue.new
|
47
|
-
rule.promotion = promotion
|
48
|
-
rule.preferred_eligible_values = Hash[
|
49
|
-
variant1.product_id => variant1.option_values.pluck(:id),
|
50
|
-
variant2.product_id => variant2.option_values.pluck(:id)
|
51
|
-
]
|
52
|
-
rule.save!
|
53
|
-
|
54
|
-
visit spree.edit_admin_promotion_path(promotion)
|
55
|
-
end
|
56
|
-
|
57
|
-
scenario "deleting a product", js: true do
|
58
|
-
within(".promo-rule-option-value:last-child") do
|
59
|
-
find(".delete").click
|
60
|
-
end
|
61
|
-
|
62
|
-
within('#rule_fields') { click_button "Update" }
|
63
|
-
|
64
|
-
first_rule = promotion.rules(true).first
|
65
|
-
expect(first_rule.preferred_eligible_values).to eq(
|
66
|
-
Hash[variant1.product_id => variant1.option_values.pluck(:id)]
|
67
|
-
)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
@@ -1,70 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
feature "Tiered Calculator Promotions" do
|
4
|
-
stub_authorization!
|
5
|
-
|
6
|
-
let(:promotion) { create :promotion }
|
7
|
-
|
8
|
-
background do
|
9
|
-
visit spree.edit_admin_promotion_path(promotion)
|
10
|
-
end
|
11
|
-
|
12
|
-
scenario "adding a tiered percent calculator", js: true do
|
13
|
-
select2 "Create whole-order adjustment", from: "Add action of type"
|
14
|
-
within('#action_fields') { click_button "Add" }
|
15
|
-
|
16
|
-
select2 "Tiered Percent", from: "Calculator"
|
17
|
-
within('#actions_container') { click_button "Update" }
|
18
|
-
|
19
|
-
within("#actions_container .settings") do
|
20
|
-
expect(page.body).to have_content("Base Percent")
|
21
|
-
expect(page.body).to have_content("Tiers")
|
22
|
-
|
23
|
-
click_button "Add"
|
24
|
-
end
|
25
|
-
|
26
|
-
fill_in "Base Percent", with: 5
|
27
|
-
|
28
|
-
within(".tier") do
|
29
|
-
find(".js-base-input").set(100)
|
30
|
-
page.execute_script("$('.js-base-input').change();")
|
31
|
-
find(".js-value-input").set(10)
|
32
|
-
page.execute_script("$('.js-value-input').change();")
|
33
|
-
end
|
34
|
-
within('#actions_container') { click_button "Update" }
|
35
|
-
|
36
|
-
first_action = promotion.actions.first
|
37
|
-
expect(first_action.class).to eq Spree::Promotion::Actions::CreateAdjustment
|
38
|
-
|
39
|
-
first_action_calculator = first_action.calculator
|
40
|
-
expect(first_action_calculator.class).to eq Spree::Calculator::TieredPercent
|
41
|
-
expect(first_action_calculator.preferred_base_percent).to eq 5
|
42
|
-
expect(first_action_calculator.preferred_tiers).to eq Hash[100.0 => 10.0]
|
43
|
-
end
|
44
|
-
|
45
|
-
context "with an existing tiered flat rate calculator" do
|
46
|
-
let(:promotion) { create :promotion, :with_order_adjustment }
|
47
|
-
|
48
|
-
background do
|
49
|
-
action = promotion.actions.first
|
50
|
-
|
51
|
-
action.calculator = Spree::Calculator::TieredFlatRate.new
|
52
|
-
action.calculator.preferred_base_amount = 5
|
53
|
-
action.calculator.preferred_tiers = Hash[100 => 10, 200 => 15, 300 => 20]
|
54
|
-
action.calculator.save!
|
55
|
-
|
56
|
-
visit spree.edit_admin_promotion_path(promotion)
|
57
|
-
end
|
58
|
-
|
59
|
-
scenario "deleting a tier", js: true do
|
60
|
-
within(".tier:nth-child(2)") do
|
61
|
-
click_icon :delete
|
62
|
-
end
|
63
|
-
|
64
|
-
within('#actions_container') { click_button "Update" }
|
65
|
-
|
66
|
-
calculator = promotion.actions.first.calculator
|
67
|
-
expect(calculator.preferred_tiers).to eq Hash[100.0 => 10.0, 300.0 => 20.0]
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe 'RefundReason', type: :feature, js: true do
|
4
|
-
stub_authorization!
|
5
|
-
|
6
|
-
let!(:amount) { 100.0 }
|
7
|
-
let!(:payment_amount) { amount * 2 }
|
8
|
-
let!(:payment_method) { create(:credit_card_payment_method) }
|
9
|
-
let!(:payment) { create(:payment, amount: payment_amount, payment_method: payment_method) }
|
10
|
-
let!(:refund_reason) { create(:default_refund_reason, name: 'Reason #1', mutable: true) }
|
11
|
-
let!(:refund_reason2) { create(:refund_reason, name: 'Reason #2', mutable: true) }
|
12
|
-
let!(:refund) { create(:refund, payment: payment, amount: amount, reason: refund_reason, transaction_id: nil) }
|
13
|
-
|
14
|
-
before { visit spree.admin_refund_reasons_path }
|
15
|
-
|
16
|
-
describe 'destroy' do
|
17
|
-
it 'has refund reasons' do
|
18
|
-
within('.table #refund_reasons') do
|
19
|
-
expect(page).to have_content(refund_reason.name)
|
20
|
-
expect(page).to have_content(refund_reason2.name)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
context 'should not destroy an associated option type' do
|
25
|
-
before { within_row(1) { delete_product_property } }
|
26
|
-
|
27
|
-
it 'has persisted refund reasons' do
|
28
|
-
within('.table #refund_reasons') do
|
29
|
-
expect(page).to have_content(refund_reason.name)
|
30
|
-
expect(page).to have_content(refund_reason2.name)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
it(js: false) { expect(Spree::RefundReason.all).to include(refund_reason) }
|
35
|
-
it(js: false) { expect(Spree::RefundReason.all).to include(refund_reason2) }
|
36
|
-
end
|
37
|
-
|
38
|
-
context 'should allow an admin to destroy a non associated option type' do
|
39
|
-
before { within_row(2) { delete_product_property } }
|
40
|
-
|
41
|
-
it 'has persisted refund reasons' do
|
42
|
-
within('.table #refund_reasons') do
|
43
|
-
expect(page).to have_content(refund_reason.name)
|
44
|
-
expect(page).not_to have_content(refund_reason2.name)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
it(js: false) { expect(Spree::RefundReason.all).to include(refund_reason) }
|
49
|
-
it(js: false) { expect(Spree::RefundReason.all).not_to include(refund_reason2) }
|
50
|
-
end
|
51
|
-
|
52
|
-
def delete_product_property
|
53
|
-
click_icon :delete
|
54
|
-
wait_for_ajax
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|