solidus_core 2.0.3 → 2.1.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_core might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +62 -3
- data/app/assets/javascripts/spree.js.coffee.erb +4 -1
- data/app/helpers/spree/base_helper.rb +7 -48
- data/app/models/spree/address.rb +5 -1
- data/app/models/spree/adjustment.rb +3 -3
- data/app/models/spree/app_configuration.rb +13 -0
- data/app/models/spree/calculator.rb +3 -2
- data/app/models/spree/calculator/default_tax.rb +6 -10
- data/app/models/spree/calculator/flat_percent_item_total.rb +0 -4
- data/app/models/spree/calculator/flat_rate.rb +0 -4
- data/app/models/spree/calculator/flexi_rate.rb +0 -4
- data/app/models/spree/calculator/free_shipping.rb +0 -3
- data/app/models/spree/calculator/percent_on_line_item.rb +0 -4
- data/app/models/spree/calculator/percent_per_item.rb +0 -4
- data/app/models/spree/calculator/price_sack.rb +0 -4
- data/app/models/spree/calculator/returns/default_refund_amount.rb +0 -3
- data/app/models/spree/calculator/shipping/flat_percent_item_total.rb +0 -4
- data/app/models/spree/calculator/shipping/flat_rate.rb +0 -4
- data/app/models/spree/calculator/shipping/flexi_rate.rb +0 -4
- data/app/models/spree/calculator/shipping/per_item.rb +0 -4
- data/app/models/spree/calculator/shipping/price_sack.rb +0 -4
- data/app/models/spree/calculator/tiered_flat_rate.rb +0 -4
- data/app/models/spree/calculator/tiered_percent.rb +0 -4
- data/app/models/spree/credit_card.rb +27 -14
- data/app/models/spree/gateway.rb +4 -0
- data/app/models/spree/inventory_unit.rb +2 -0
- data/app/models/spree/line_item.rb +31 -26
- data/app/models/spree/option_type.rb +0 -3
- data/app/models/spree/order.rb +28 -31
- data/app/models/spree/order/checkout.rb +0 -2
- data/app/models/spree/order_contents.rb +0 -45
- data/app/models/spree/order_merger.rb +6 -6
- data/app/models/spree/order_update_attributes.rb +0 -2
- data/app/models/spree/order_updater.rb +91 -13
- data/app/models/spree/payment.rb +9 -2
- data/app/models/spree/payment/processing.rb +15 -9
- data/app/models/spree/payment_method.rb +48 -5
- data/app/models/spree/price.rb +7 -9
- data/app/models/spree/product.rb +1 -25
- data/app/models/spree/promotion.rb +22 -14
- data/app/models/spree/promotion/actions/create_adjustment.rb +12 -1
- data/app/models/spree/promotion/actions/create_item_adjustments.rb +15 -1
- data/app/models/spree/promotion/actions/create_quantity_adjustments.rb +5 -3
- data/app/models/spree/promotion/actions/free_shipping.rb +14 -0
- data/app/models/spree/promotion/rules/taxon.rb +7 -2
- data/app/models/spree/promotion/rules/user_role.rb +43 -0
- data/app/models/spree/promotion_action.rb +19 -2
- data/app/models/spree/promotion_handler/coupon.rb +1 -4
- data/app/models/spree/promotion_handler/free_shipping.rb +22 -17
- data/app/models/spree/promotion_rule_role.rb +6 -0
- data/app/models/spree/property.rb +0 -3
- data/app/models/spree/return_authorization.rb +2 -0
- data/app/models/spree/shipment.rb +5 -21
- data/app/models/spree/shipping_method.rb +23 -2
- data/app/models/spree/shipping_rate.rb +3 -0
- data/app/models/spree/stock/estimator.rb +1 -1
- data/app/models/spree/stock_location.rb +3 -0
- data/app/models/spree/store.rb +7 -0
- data/app/models/spree/tax/item_adjuster.rb +27 -12
- data/app/models/spree/tax/order_adjuster.rb +2 -5
- data/app/models/spree/tax/tax_helpers.rb +4 -8
- data/app/models/spree/tax_rate.rb +1 -15
- data/app/models/spree/taxon.rb +0 -3
- data/app/models/spree/transfer_item.rb +1 -1
- data/app/models/spree/user_class_handle.rb +14 -9
- data/app/models/spree/variant/pricing_options.rb +1 -1
- data/app/models/spree/wallet/add_payment_sources_to_wallet.rb +1 -1
- data/app/models/spree/zone.rb +20 -13
- data/config/locales/en.yml +144 -62
- data/db/migrate/20120831092320_spree_one_two.rb +0 -7
- data/db/migrate/20150723224133_remove_unnecessary_indexes.rb +0 -2
- data/db/migrate/20160924135758_remove_is_default_from_prices.rb +5 -0
- data/db/migrate/20161009141333_remove_currency_from_line_items.rb +5 -0
- data/db/migrate/20161014221052_add_available_to_columns_and_remove_display_on_from_payment_methods.rb +28 -0
- data/db/migrate/20161123154034_add_available_to_users_and_remove_display_on_from_shipping_methods.rb +20 -0
- data/lib/generators/spree/custom_user/templates/authentication_helpers.rb.tt +4 -0
- data/lib/generators/spree/dummy/dummy_generator.rb +0 -2
- data/lib/spree/core.rb +0 -5
- data/lib/spree/core/controller_helpers/pricing.rb +2 -1
- data/lib/spree/core/engine.rb +14 -0
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/deprecation.rb +1 -1
- data/lib/spree/localized_number.rb +3 -2
- data/lib/spree/permission_sets/configuration_display.rb +0 -1
- data/lib/spree/permission_sets/configuration_management.rb +0 -1
- data/lib/spree/permission_sets/product_display.rb +0 -1
- data/lib/spree/permission_sets/product_management.rb +0 -1
- data/lib/spree/permission_sets/user_management.rb +2 -4
- data/lib/spree/permitted_attributes.rb +3 -2
- data/lib/spree/testing_support/capybara_ext.rb +0 -12
- data/lib/spree/testing_support/factories/address_factory.rb +1 -1
- data/lib/spree/testing_support/factories/line_item_factory.rb +0 -1
- data/lib/spree/testing_support/factories/payment_factory.rb +4 -0
- data/lib/spree/testing_support/factories/payment_method_factory.rb +8 -1
- data/lib/spree/testing_support/factories/user_factory.rb +2 -2
- data/solidus_core.gemspec +4 -3
- data/spec/helpers/base_helper_spec.rb +0 -40
- data/spec/lib/spree/core/controller_helpers/pricing_spec.rb +16 -0
- data/spec/lib/spree/core/importer/order_spec.rb +27 -18
- data/spec/lib/spree/core/price_migrator_spec.rb +3 -1
- data/spec/lib/spree/core/testing_support/factories/order_factory_spec.rb +16 -0
- data/spec/lib/spree/core/unreturned_item_charger_spec.rb +0 -2
- data/spec/lib/tasks/exchanges_spec.rb +4 -2
- data/spec/lib/tasks/migrations/create_vat_prices_spec.rb +5 -3
- data/spec/models/spree/adjustment_spec.rb +136 -0
- data/spec/models/spree/calculator/default_tax_spec.rb +13 -7
- data/spec/models/spree/calculator/flat_percent_item_total_spec.rb +3 -0
- data/spec/models/spree/calculator/flat_rate_spec.rb +3 -0
- data/spec/models/spree/calculator/flexi_rate_spec.rb +3 -0
- data/spec/models/spree/calculator/free_shipping_spec.rb +6 -0
- data/spec/models/spree/calculator/percent_on_line_item_spec.rb +9 -4
- data/spec/models/spree/calculator/percent_per_item_spec.rb +10 -0
- data/spec/models/spree/calculator/price_sack_spec.rb +3 -0
- data/spec/models/spree/calculator/refunds/default_refund_amount_spec.rb +3 -0
- data/spec/models/spree/calculator/shipping/flat_percent_item_total_spec.rb +3 -0
- data/spec/models/spree/calculator/shipping/flat_rate_spec.rb +3 -0
- data/spec/models/spree/calculator/shipping/flexi_rate_spec.rb +3 -0
- data/spec/models/spree/calculator/shipping/per_item_spec.rb +3 -0
- data/spec/models/spree/calculator/shipping/price_sack_spec.rb +4 -1
- data/spec/models/spree/calculator/tiered_flat_rate_spec.rb +3 -0
- data/spec/models/spree/calculator/tiered_percent_spec.rb +3 -0
- data/spec/models/spree/credit_card_spec.rb +27 -1
- data/spec/models/spree/line_item_spec.rb +58 -65
- data/spec/models/spree/order/checkout_spec.rb +2 -1
- data/spec/models/spree/order/payment_spec.rb +9 -10
- data/spec/models/spree/order/tax_spec.rb +22 -7
- data/spec/models/spree/order/updating_spec.rb +1 -3
- data/spec/models/spree/order_cancellations_spec.rb +6 -4
- data/spec/models/spree/order_contents_spec.rb +34 -50
- data/spec/models/spree/order_inventory_spec.rb +3 -5
- data/spec/models/spree/order_merger_spec.rb +20 -0
- data/spec/models/spree/order_spec.rb +28 -64
- data/spec/models/spree/order_update_attributes_spec.rb +1 -5
- data/spec/models/spree/order_updater_spec.rb +251 -0
- data/spec/models/spree/payment_method_spec.rb +178 -28
- data/spec/models/spree/payment_spec.rb +35 -19
- data/spec/models/spree/permission_sets/configuration_display.rb +0 -4
- data/spec/models/spree/permission_sets/configuration_management_spec.rb +0 -2
- data/spec/models/spree/permission_sets/product_display_spec.rb +0 -4
- data/spec/models/spree/permission_sets/product_management_spec.rb +0 -2
- data/spec/models/spree/permission_sets/user_management_spec.rb +9 -2
- data/spec/models/spree/price_spec.rb +16 -1
- data/spec/models/spree/product_spec.rb +0 -75
- data/spec/models/spree/promotion/actions/create_adjustment_spec.rb +20 -0
- data/spec/models/spree/promotion/actions/create_item_adjustments_spec.rb +39 -15
- data/spec/models/spree/promotion/actions/create_quantity_adjustments_spec.rb +203 -22
- data/spec/models/spree/promotion/actions/free_shipping_spec.rb +22 -3
- data/spec/models/spree/promotion/rules/taxon_spec.rb +26 -0
- data/spec/models/spree/promotion/rules/user_role_spec.rb +86 -0
- data/spec/models/spree/promotion_action_spec.rb +38 -0
- data/spec/models/spree/promotion_handler/coupon_spec.rb +36 -33
- data/spec/models/spree/promotion_handler/free_shipping_spec.rb +21 -22
- data/spec/models/spree/promotion_spec.rb +46 -6
- data/spec/models/spree/reimbursement_spec.rb +1 -1
- data/spec/models/spree/reimbursement_tax_calculator_spec.rb +2 -2
- data/spec/models/spree/shipment_spec.rb +68 -50
- data/spec/models/spree/shipping_method_spec.rb +41 -0
- data/spec/models/spree/shipping_rate_spec.rb +9 -3
- data/spec/models/spree/stock/estimator_spec.rb +4 -2
- data/spec/models/spree/store_credit_spec.rb +3 -3
- data/spec/models/spree/tax/item_adjuster_spec.rb +31 -21
- data/spec/models/spree/tax/order_adjuster_spec.rb +6 -10
- data/spec/models/spree/tax/taxation_integration_spec.rb +19 -0
- data/spec/models/spree/tax_rate_spec.rb +5 -26
- data/spec/models/spree/transfer_item_spec.rb +11 -0
- data/spec/models/spree/variant/pricing_options_spec.rb +7 -17
- data/spec/models/spree/variant_spec.rb +2 -4
- data/spec/models/spree/zone_spec.rb +60 -20
- data/spec/shared_examples/calculator_shared_examples.rb +8 -0
- metadata +19 -24
- data/app/models/spree/item_adjustments.rb +0 -89
- data/app/models/spree/option_type_prototype.rb +0 -6
- data/app/models/spree/property_prototype.rb +0 -6
- data/app/models/spree/prototype.rb +0 -14
- data/app/models/spree/prototype_taxon.rb +0 -6
- data/app/models/spree/tracker.rb +0 -8
- data/db/migrate/20150128032538_remove_environment_from_tracker.rb +0 -6
- data/lib/generators/spree/dummy/templates/initializers/custom_user.rb +0 -1
- data/lib/spree/core/delegate_belongs_to.rb +0 -94
- data/lib/spree/testing_support/factories/prototype_factory.rb +0 -8
- data/lib/spree/testing_support/factories/tracker_factory.rb +0 -6
- data/spec/lib/spree/core/delegate_belongs_to_spec.rb +0 -24
- data/spec/lib/spree/core/testing_support/factories/prototype_factory_spec.rb +0 -12
- data/spec/lib/spree/core/testing_support/factories/tracker_factory_spec.rb +0 -12
- data/spec/models/spree/item_adjustments_spec.rb +0 -306
- data/spec/models/spree/tracker_spec.rb +0 -21
@@ -1,30 +1,101 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Spree::PaymentMethod, type: :model do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
let!(:payment_method_nil_display) { create(:payment_method, active: true,
|
5
|
+
available_to_users: true,
|
6
|
+
available_to_admin: true) }
|
7
|
+
let!(:payment_method_both_display) { create(:payment_method, active: true,
|
8
|
+
available_to_users: true,
|
9
|
+
available_to_admin: true) }
|
10
|
+
let!(:payment_method_front_display){ create(:payment_method, active: true,
|
11
|
+
available_to_users: true,
|
12
|
+
available_to_admin: false) }
|
13
|
+
let!(:payment_method_back_display) { create(:payment_method, active: true,
|
14
|
+
available_to_users: false,
|
15
|
+
available_to_admin: true) }
|
16
|
+
|
17
|
+
describe "available_to_[<users>, <admin>, <store>]" do
|
18
|
+
context "when searching for payment methods available to users and admins" do
|
19
|
+
subject { Spree::PaymentMethod.available_to_users.available_to_admin }
|
20
|
+
|
21
|
+
it { is_expected.to contain_exactly(payment_method_both_display, payment_method_nil_display) }
|
22
|
+
|
23
|
+
context "with a store" do
|
24
|
+
let!(:extra_payment_method_both_display) { create(:payment_method, active: true,
|
25
|
+
available_to_users: true,
|
26
|
+
available_to_admin: true) }
|
27
|
+
let!(:store_1) do
|
28
|
+
create(:store, payment_methods:[payment_method_nil_display,
|
29
|
+
payment_method_both_display,
|
30
|
+
payment_method_front_display,
|
31
|
+
payment_method_back_display])
|
32
|
+
end
|
33
|
+
|
34
|
+
subject { Spree::PaymentMethod.available_to_store( store_1 ).available_to_users.available_to_admin }
|
35
|
+
|
36
|
+
it { is_expected.to contain_exactly(payment_method_both_display, payment_method_nil_display) }
|
37
|
+
|
38
|
+
context "when the store has no payment methods" do
|
39
|
+
subject { Spree::PaymentMethod.available_to_store(store_without_payment_methods) }
|
40
|
+
let!(:store_without_payment_methods) do
|
41
|
+
create(:store, payment_methods:[])
|
42
|
+
end
|
43
|
+
|
44
|
+
it "returns all payment methods" do
|
45
|
+
expect(subject.all.size).to eq(5)
|
46
|
+
end
|
47
|
+
|
48
|
+
it "is further scopeable for admin availability" do
|
49
|
+
expect(subject.available_to_admin).not_to include(payment_method_front_display)
|
50
|
+
end
|
51
|
+
|
52
|
+
it "is further scopeable for users availability" do
|
53
|
+
expect(subject.available_to_users).not_to include(payment_method_back_display)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
9
58
|
|
59
|
+
context "when searching for payment methods available to users" do
|
60
|
+
subject { Spree::PaymentMethod.available_to_users }
|
61
|
+
|
62
|
+
it { is_expected.to contain_exactly(payment_method_front_display, payment_method_both_display, payment_method_nil_display) }
|
63
|
+
end
|
64
|
+
|
65
|
+
context "when searching for payment methods available to admin" do
|
66
|
+
subject { Spree::PaymentMethod.available_to_admin }
|
67
|
+
|
68
|
+
it { is_expected.to contain_exactly(payment_method_back_display, payment_method_both_display, payment_method_nil_display)}
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe ".available" do
|
10
73
|
it "should have 4 total methods" do
|
11
74
|
expect(Spree::PaymentMethod.all.size).to eq(4)
|
12
75
|
end
|
13
76
|
|
14
77
|
it "should return all methods available to front-end/back-end when no parameter is passed" do
|
15
|
-
|
78
|
+
Spree::Deprecation.silence do
|
79
|
+
expect(Spree::PaymentMethod.available.size).to eq(2)
|
80
|
+
end
|
16
81
|
end
|
17
82
|
|
18
|
-
it "should return all methods available to front-end/back-end when
|
19
|
-
|
83
|
+
it "should return all methods available to front-end/back-end when passed :both" do
|
84
|
+
Spree::Deprecation.silence do
|
85
|
+
expect(Spree::PaymentMethod.available(:both).size).to eq(2)
|
86
|
+
end
|
20
87
|
end
|
21
88
|
|
22
|
-
it "should return all methods available to front-end when
|
23
|
-
|
89
|
+
it "should return all methods available to front-end when passed :front_end" do
|
90
|
+
Spree::Deprecation.silence do
|
91
|
+
expect(Spree::PaymentMethod.available(:front_end).size).to eq(3)
|
92
|
+
end
|
24
93
|
end
|
25
94
|
|
26
|
-
it "should return all methods available to back-end when
|
27
|
-
|
95
|
+
it "should return all methods available to back-end when passed :back_end" do
|
96
|
+
Spree::Deprecation.silence do
|
97
|
+
expect(Spree::PaymentMethod.available(:back_end).size).to eq(3)
|
98
|
+
end
|
28
99
|
end
|
29
100
|
|
30
101
|
context 'with stores' do
|
@@ -51,14 +122,33 @@ describe Spree::PaymentMethod, type: :model do
|
|
51
122
|
context 'when the store is specified' do
|
52
123
|
context 'when the store has payment methods' do
|
53
124
|
it 'finds the payment methods for the store' do
|
54
|
-
|
55
|
-
|
56
|
-
|
125
|
+
Spree::Deprecation.silence do
|
126
|
+
expect(Spree::PaymentMethod.available(:both, store: store_1)).to match_array(
|
127
|
+
[payment_method_nil_display, payment_method_both_display]
|
128
|
+
)
|
129
|
+
end
|
57
130
|
end
|
58
131
|
end
|
59
132
|
|
60
133
|
context "when store does not have payment_methods" do
|
61
134
|
it "returns all matching payment methods regardless of store" do
|
135
|
+
Spree::Deprecation.silence do
|
136
|
+
expect(Spree::PaymentMethod.available(:both)).to match_array(
|
137
|
+
[
|
138
|
+
payment_method_nil_display,
|
139
|
+
payment_method_both_display,
|
140
|
+
store_2_payment_method,
|
141
|
+
no_store_payment_method
|
142
|
+
]
|
143
|
+
)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
context 'when the store is not specified' do
|
150
|
+
it "returns all matching payment methods regardless of store" do
|
151
|
+
Spree::Deprecation.silence do
|
62
152
|
expect(Spree::PaymentMethod.available(:both)).to match_array(
|
63
153
|
[
|
64
154
|
payment_method_nil_display,
|
@@ -70,19 +160,6 @@ describe Spree::PaymentMethod, type: :model do
|
|
70
160
|
end
|
71
161
|
end
|
72
162
|
end
|
73
|
-
|
74
|
-
context 'when the store is not specified' do
|
75
|
-
it "returns all matching payment methods regardless of store" do
|
76
|
-
expect(Spree::PaymentMethod.available(:both)).to match_array(
|
77
|
-
[
|
78
|
-
payment_method_nil_display,
|
79
|
-
payment_method_both_display,
|
80
|
-
store_2_payment_method,
|
81
|
-
no_store_payment_method
|
82
|
-
]
|
83
|
-
)
|
84
|
-
end
|
85
|
-
end
|
86
163
|
end
|
87
164
|
end
|
88
165
|
|
@@ -143,4 +220,77 @@ describe Spree::PaymentMethod, type: :model do
|
|
143
220
|
end
|
144
221
|
end
|
145
222
|
end
|
223
|
+
|
224
|
+
describe "display_on=" do
|
225
|
+
around do |example|
|
226
|
+
Spree::Deprecation.silence do
|
227
|
+
example.run
|
228
|
+
end
|
229
|
+
end
|
230
|
+
let(:payment) { described_class.new(display_on: display_on) }
|
231
|
+
|
232
|
+
context 'with empty string' do
|
233
|
+
let(:display_on) { "" }
|
234
|
+
|
235
|
+
it "should be available to admins" do
|
236
|
+
expect(payment.available_to_admin).to be true
|
237
|
+
end
|
238
|
+
|
239
|
+
it "should be available to users" do
|
240
|
+
expect(payment.available_to_users).to be true
|
241
|
+
end
|
242
|
+
|
243
|
+
it "should have the same value for display_on" do
|
244
|
+
expect(payment.display_on).to eq ""
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
context 'with "back_end"' do
|
249
|
+
let(:display_on) { "back_end" }
|
250
|
+
|
251
|
+
it "should be available to admins" do
|
252
|
+
expect(payment.available_to_admin).to be true
|
253
|
+
end
|
254
|
+
|
255
|
+
it "should not be available to users" do
|
256
|
+
expect(payment.available_to_users).to be false
|
257
|
+
end
|
258
|
+
|
259
|
+
it "should have the same value for display_on" do
|
260
|
+
expect(payment.display_on).to eq "back_end"
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
context 'with "front_end"' do
|
265
|
+
let(:display_on) { "front_end" }
|
266
|
+
|
267
|
+
it "should be available to admins" do
|
268
|
+
expect(payment.available_to_admin).to be false
|
269
|
+
end
|
270
|
+
|
271
|
+
it "should not be available to users" do
|
272
|
+
expect(payment.available_to_users).to be true
|
273
|
+
end
|
274
|
+
|
275
|
+
it "should have the same value for display_on" do
|
276
|
+
expect(payment.display_on).to eq "front_end"
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
context 'with any other string' do
|
281
|
+
let(:display_on) { "foobar" }
|
282
|
+
|
283
|
+
it "should be available to admins" do
|
284
|
+
expect(payment.available_to_admin).to be false
|
285
|
+
end
|
286
|
+
|
287
|
+
it "should not be available to users" do
|
288
|
+
expect(payment.available_to_users).to be false
|
289
|
+
end
|
290
|
+
|
291
|
+
it "should have none for display_on" do
|
292
|
+
expect(payment.display_on).to eq "none"
|
293
|
+
end
|
294
|
+
end
|
295
|
+
end
|
146
296
|
end
|
@@ -17,12 +17,12 @@ describe Spree::Payment, type: :model do
|
|
17
17
|
let(:card) { create :credit_card }
|
18
18
|
|
19
19
|
let(:payment) do
|
20
|
-
Spree::Payment.
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
20
|
+
payment = Spree::Payment.new
|
21
|
+
payment.source = card
|
22
|
+
payment.order = order
|
23
|
+
payment.payment_method = gateway
|
24
|
+
payment.amount = 5
|
25
|
+
payment
|
26
26
|
end
|
27
27
|
|
28
28
|
let(:amount_in_cents) { (payment.amount * 100).round }
|
@@ -39,6 +39,11 @@ describe Spree::Payment, type: :model do
|
|
39
39
|
ActiveMerchant::Billing::Response.new(false, '', {}, {})
|
40
40
|
end
|
41
41
|
|
42
|
+
before(:each) do
|
43
|
+
# So it doesn't create log entries every time a processing method is called
|
44
|
+
allow(payment.log_entries).to receive(:create!)
|
45
|
+
end
|
46
|
+
|
42
47
|
context '.risky' do
|
43
48
|
let!(:payment_1) { create(:payment, avs_response: 'Y', cvv_response_code: 'M', cvv_response_message: 'Match') }
|
44
49
|
let!(:payment_2) { create(:payment, avs_response: 'Y', cvv_response_code: 'M', cvv_response_message: '') }
|
@@ -241,9 +246,8 @@ describe Spree::Payment, type: :model do
|
|
241
246
|
|
242
247
|
it "should log the response" do
|
243
248
|
payment.save!
|
244
|
-
expect
|
245
|
-
|
246
|
-
}.to change { payment.log_entries.count }.by(1)
|
249
|
+
expect(payment.log_entries).to receive(:create!).with(details: anything)
|
250
|
+
payment.authorize!
|
247
251
|
end
|
248
252
|
|
249
253
|
describe 'billing_address option' do
|
@@ -351,9 +355,8 @@ describe Spree::Payment, type: :model do
|
|
351
355
|
|
352
356
|
it "should log the response" do
|
353
357
|
payment.save!
|
354
|
-
expect
|
355
|
-
|
356
|
-
}.to change { payment.log_entries.count }.by(1)
|
358
|
+
expect(payment.log_entries).to receive(:create!).with(details: anything)
|
359
|
+
payment.purchase!
|
357
360
|
end
|
358
361
|
|
359
362
|
context "if successful" do
|
@@ -529,9 +532,8 @@ describe Spree::Payment, type: :model do
|
|
529
532
|
end
|
530
533
|
|
531
534
|
it "should log the response" do
|
532
|
-
expect
|
533
|
-
|
534
|
-
}.to change { payment.log_entries.count }.by(1)
|
535
|
+
expect(payment.log_entries).to receive(:create!).with(details: anything)
|
536
|
+
payment.void_transaction!
|
535
537
|
end
|
536
538
|
|
537
539
|
context "if successful" do
|
@@ -653,13 +655,12 @@ describe Spree::Payment, type: :model do
|
|
653
655
|
end
|
654
656
|
|
655
657
|
context "completed orders" do
|
656
|
-
let(:payment_method) { create(:check_payment_method) }
|
657
658
|
before { allow(order).to receive_messages completed?: true }
|
658
659
|
|
659
660
|
it "updates payment_state and shipments" do
|
660
661
|
expect(order.updater).to receive(:update_payment_state)
|
661
662
|
expect(order.updater).to receive(:update_shipment_state)
|
662
|
-
Spree::Payment.create
|
663
|
+
Spree::Payment.create(amount: 100, order: order)
|
663
664
|
end
|
664
665
|
end
|
665
666
|
|
@@ -690,8 +691,6 @@ describe Spree::Payment, type: :model do
|
|
690
691
|
end
|
691
692
|
|
692
693
|
it "should not try to create profiles on old failed payment attempts" do
|
693
|
-
order.payments.destroy_all
|
694
|
-
|
695
694
|
allow_any_instance_of(Spree::Payment).to receive(:payment_method) { gateway }
|
696
695
|
|
697
696
|
order.payments.create!(
|
@@ -744,6 +743,23 @@ describe Spree::Payment, type: :model do
|
|
744
743
|
invalid_payment.save
|
745
744
|
expect(payment.reload.state).to eq('checkout')
|
746
745
|
end
|
746
|
+
|
747
|
+
describe "invalidating payments updates in memory objects" do
|
748
|
+
before do
|
749
|
+
Spree::PaymentCreate.new(order, amount: 1).build.save!
|
750
|
+
expect(order.payments.map(&:state)).to contain_exactly(
|
751
|
+
'checkout'
|
752
|
+
)
|
753
|
+
Spree::PaymentCreate.new(order, amount: 2).build.save!
|
754
|
+
end
|
755
|
+
|
756
|
+
it 'should not have stale payments' do
|
757
|
+
expect(order.payments.map(&:state)).to contain_exactly(
|
758
|
+
'invalid',
|
759
|
+
'checkout'
|
760
|
+
)
|
761
|
+
end
|
762
|
+
end
|
747
763
|
end
|
748
764
|
|
749
765
|
describe "#apply_source_attributes" do
|
@@ -22,7 +22,6 @@ describe Spree::PermissionSets::ConfigurationDisplay do
|
|
22
22
|
it { is_expected.to be_able_to(:display, Spree::ShippingCategory) }
|
23
23
|
it { is_expected.to be_able_to(:display, Spree::StockLocation) }
|
24
24
|
it { is_expected.to be_able_to(:display, Spree::StockMovement) }
|
25
|
-
it { is_expected.to be_able_to(:display, Spree::Tracker) }
|
26
25
|
it { is_expected.to be_able_to(:display, Spree::RefundReason) }
|
27
26
|
it { is_expected.to be_able_to(:display, Spree::ReimbursementType) }
|
28
27
|
it { is_expected.to be_able_to(:display, Spree::ReturnReason) }
|
@@ -38,7 +37,6 @@ describe Spree::PermissionSets::ConfigurationDisplay do
|
|
38
37
|
it { is_expected.to be_able_to(:admin, Spree::ShippingCategory) }
|
39
38
|
it { is_expected.to be_able_to(:admin, Spree::StockLocation) }
|
40
39
|
it { is_expected.to be_able_to(:admin, Spree::StockMovement) }
|
41
|
-
it { is_expected.to be_able_to(:admin, Spree::Tracker) }
|
42
40
|
it { is_expected.to be_able_to(:admin, Spree::RefundReason) }
|
43
41
|
it { is_expected.to be_able_to(:admin, Spree::ReimbursementType) }
|
44
42
|
it { is_expected.to be_able_to(:admin, Spree::ReturnReason) }
|
@@ -57,7 +55,6 @@ describe Spree::PermissionSets::ConfigurationDisplay do
|
|
57
55
|
it { is_expected.not_to be_able_to(:display, Spree::ShippingCategory) }
|
58
56
|
it { is_expected.not_to be_able_to(:display, Spree::StockLocation) }
|
59
57
|
it { is_expected.not_to be_able_to(:display, Spree::StockMovement) }
|
60
|
-
it { is_expected.not_to be_able_to(:display, Spree::Tracker) }
|
61
58
|
it { is_expected.not_to be_able_to(:display, Spree::RefundReason) }
|
62
59
|
it { is_expected.not_to be_able_to(:display, Spree::ReimbursementType) }
|
63
60
|
it { is_expected.not_to be_able_to(:display, Spree::ReturnReason) }
|
@@ -73,7 +70,6 @@ describe Spree::PermissionSets::ConfigurationDisplay do
|
|
73
70
|
it { is_expected.not_to be_able_to(:admin, Spree::ShippingCategory) }
|
74
71
|
it { is_expected.not_to be_able_to(:admin, Spree::StockLocation) }
|
75
72
|
it { is_expected.not_to be_able_to(:admin, Spree::StockMovement) }
|
76
|
-
it { is_expected.not_to be_able_to(:admin, Spree::Tracker) }
|
77
73
|
it { is_expected.not_to be_able_to(:admin, Spree::RefundReason) }
|
78
74
|
it { is_expected.not_to be_able_to(:admin, Spree::ReimbursementType) }
|
79
75
|
it { is_expected.not_to be_able_to(:admin, Spree::ReturnReason) }
|
@@ -22,7 +22,6 @@ describe Spree::PermissionSets::ConfigurationManagement do
|
|
22
22
|
it { is_expected.to be_able_to(:manage, Spree::ShippingCategory) }
|
23
23
|
it { is_expected.to be_able_to(:manage, Spree::StockLocation) }
|
24
24
|
it { is_expected.to be_able_to(:manage, Spree::StockMovement) }
|
25
|
-
it { is_expected.to be_able_to(:manage, Spree::Tracker) }
|
26
25
|
it { is_expected.to be_able_to(:manage, Spree::RefundReason) }
|
27
26
|
it { is_expected.to be_able_to(:manage, Spree::ReimbursementType) }
|
28
27
|
it { is_expected.to be_able_to(:manage, Spree::ReturnReason) }
|
@@ -41,7 +40,6 @@ describe Spree::PermissionSets::ConfigurationManagement do
|
|
41
40
|
it { is_expected.not_to be_able_to(:manage, Spree::ShippingCategory) }
|
42
41
|
it { is_expected.not_to be_able_to(:manage, Spree::StockLocation) }
|
43
42
|
it { is_expected.not_to be_able_to(:manage, Spree::StockMovement) }
|
44
|
-
it { is_expected.not_to be_able_to(:manage, Spree::Tracker) }
|
45
43
|
it { is_expected.not_to be_able_to(:manage, Spree::RefundReason) }
|
46
44
|
it { is_expected.not_to be_able_to(:manage, Spree::ReimbursementType) }
|
47
45
|
it { is_expected.not_to be_able_to(:manage, Spree::ReturnReason) }
|
@@ -17,7 +17,6 @@ describe Spree::PermissionSets::ProductDisplay do
|
|
17
17
|
it { is_expected.to be_able_to(:display, Spree::ProductProperty) }
|
18
18
|
it { is_expected.to be_able_to(:display, Spree::OptionType) }
|
19
19
|
it { is_expected.to be_able_to(:display, Spree::Property) }
|
20
|
-
it { is_expected.to be_able_to(:display, Spree::Prototype) }
|
21
20
|
it { is_expected.to be_able_to(:display, Spree::Taxonomy) }
|
22
21
|
it { is_expected.to be_able_to(:display, Spree::Taxon) }
|
23
22
|
it { is_expected.to be_able_to(:admin, Spree::Product) }
|
@@ -27,7 +26,6 @@ describe Spree::PermissionSets::ProductDisplay do
|
|
27
26
|
it { is_expected.to be_able_to(:admin, Spree::ProductProperty) }
|
28
27
|
it { is_expected.to be_able_to(:admin, Spree::OptionType) }
|
29
28
|
it { is_expected.to be_able_to(:admin, Spree::Property) }
|
30
|
-
it { is_expected.to be_able_to(:admin, Spree::Prototype) }
|
31
29
|
it { is_expected.to be_able_to(:admin, Spree::Taxonomy) }
|
32
30
|
it { is_expected.to be_able_to(:admin, Spree::Taxon) }
|
33
31
|
it { is_expected.to be_able_to(:edit, Spree::Product) }
|
@@ -41,7 +39,6 @@ describe Spree::PermissionSets::ProductDisplay do
|
|
41
39
|
it { is_expected.not_to be_able_to(:display, Spree::ProductProperty) }
|
42
40
|
it { is_expected.not_to be_able_to(:display, Spree::OptionType) }
|
43
41
|
it { is_expected.not_to be_able_to(:display, Spree::Property) }
|
44
|
-
it { is_expected.not_to be_able_to(:display, Spree::Prototype) }
|
45
42
|
it { is_expected.not_to be_able_to(:display, Spree::Taxonomy) }
|
46
43
|
it { is_expected.not_to be_able_to(:display, Spree::Taxon) }
|
47
44
|
it { is_expected.not_to be_able_to(:admin, Spree::Product) }
|
@@ -51,7 +48,6 @@ describe Spree::PermissionSets::ProductDisplay do
|
|
51
48
|
it { is_expected.not_to be_able_to(:admin, Spree::ProductProperty) }
|
52
49
|
it { is_expected.not_to be_able_to(:admin, Spree::OptionType) }
|
53
50
|
it { is_expected.not_to be_able_to(:admin, Spree::Property) }
|
54
|
-
it { is_expected.not_to be_able_to(:admin, Spree::Prototype) }
|
55
51
|
it { is_expected.not_to be_able_to(:admin, Spree::Taxonomy) }
|
56
52
|
it { is_expected.not_to be_able_to(:admin, Spree::Taxon) }
|
57
53
|
it { is_expected.not_to be_able_to(:edit, Spree::Product) }
|
@@ -17,7 +17,6 @@ describe Spree::PermissionSets::ProductManagement do
|
|
17
17
|
it { is_expected.to be_able_to(:manage, Spree::ProductProperty) }
|
18
18
|
it { is_expected.to be_able_to(:manage, Spree::OptionType) }
|
19
19
|
it { is_expected.to be_able_to(:manage, Spree::Property) }
|
20
|
-
it { is_expected.to be_able_to(:manage, Spree::Prototype) }
|
21
20
|
it { is_expected.to be_able_to(:manage, Spree::Taxonomy) }
|
22
21
|
it { is_expected.to be_able_to(:manage, Spree::Taxon) }
|
23
22
|
it { is_expected.to be_able_to(:manage, Spree::Classification) }
|
@@ -31,7 +30,6 @@ describe Spree::PermissionSets::ProductManagement do
|
|
31
30
|
it { is_expected.not_to be_able_to(:manage, Spree::ProductProperty) }
|
32
31
|
it { is_expected.not_to be_able_to(:manage, Spree::OptionType) }
|
33
32
|
it { is_expected.not_to be_able_to(:manage, Spree::Property) }
|
34
|
-
it { is_expected.not_to be_able_to(:manage, Spree::Prototype) }
|
35
33
|
it { is_expected.not_to be_able_to(:manage, Spree::Taxonomy) }
|
36
34
|
it { is_expected.not_to be_able_to(:manage, Spree::Taxon) }
|
37
35
|
it { is_expected.not_to be_able_to(:manage, Spree::Classification) }
|