solidus_core 1.0.6 → 1.0.7
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d38685bcc1d7ee47ba79564d398c99a21dd0d480
|
4
|
+
data.tar.gz: 7397b8dc2aa601f44baef214fd09939ed87d5d1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59cad15903b2db9b9168b62aae5da114d58bf2550abdd21f1bf583f32d60430eb4f373289bf7301013b0dd7ccb75039c10118daed54a134816e833c25858bf67
|
7
|
+
data.tar.gz: 180d7e3848e58b98e1e17e7ffaa29b8339f915f07cd1f8f06c57c9859526015c068cd7eb96c66d708625a91d77d0dffcc6fdfe5352bce99ed90bf8938cd6c0e7
|
data/app/models/spree/order.rb
CHANGED
@@ -713,6 +713,23 @@ module Spree
|
|
713
713
|
Spree::Money.new(total_available_store_credit - total_applicable_store_credit, { currency: currency })
|
714
714
|
end
|
715
715
|
|
716
|
+
def payments_attributes=(attributes)
|
717
|
+
validate_payments_attributes(attributes)
|
718
|
+
super(attributes)
|
719
|
+
end
|
720
|
+
|
721
|
+
def validate_payments_attributes(attributes)
|
722
|
+
attributes = Array.wrap(attributes)
|
723
|
+
# Ensure the payment methods specified are allowed for this user
|
724
|
+
payment_methods = Spree::PaymentMethod.where(id: available_payment_methods)
|
725
|
+
attributes.each do |payment_attributes|
|
726
|
+
payment_method_id = payment_attributes[:payment_method_id]
|
727
|
+
|
728
|
+
# raise RecordNotFound unless it is an allowed payment method
|
729
|
+
payment_methods.find(payment_method_id) if payment_method_id
|
730
|
+
end
|
731
|
+
end
|
732
|
+
|
716
733
|
private
|
717
734
|
|
718
735
|
def link_by_email
|
data/app/models/spree/payment.rb
CHANGED
@@ -1409,4 +1409,56 @@ describe Spree::Order, :type => :model do
|
|
1409
1409
|
end
|
1410
1410
|
end
|
1411
1411
|
end
|
1412
|
+
|
1413
|
+
describe "#validate_payments_attributes" do
|
1414
|
+
let(:attributes) { [ActionController::Parameters.new(payment_method_id: payment_method.id)] }
|
1415
|
+
subject do
|
1416
|
+
order.validate_payments_attributes(attributes)
|
1417
|
+
end
|
1418
|
+
|
1419
|
+
context "with empty array" do
|
1420
|
+
let(:attributes) { [] }
|
1421
|
+
it "doesn't error" do
|
1422
|
+
subject
|
1423
|
+
end
|
1424
|
+
end
|
1425
|
+
|
1426
|
+
context "with no payment method specified" do
|
1427
|
+
let(:attributes) { [ActionController::Parameters.new({})] }
|
1428
|
+
it "doesn't error" do
|
1429
|
+
subject
|
1430
|
+
end
|
1431
|
+
end
|
1432
|
+
|
1433
|
+
context "with valid payment method" do
|
1434
|
+
let(:payment_method) { create(:check_payment_method) }
|
1435
|
+
it "doesn't error" do
|
1436
|
+
subject
|
1437
|
+
end
|
1438
|
+
end
|
1439
|
+
|
1440
|
+
context "with inactive payment method" do
|
1441
|
+
let(:payment_method) { create(:check_payment_method, active: false) }
|
1442
|
+
|
1443
|
+
it "raises RecordNotFound" do
|
1444
|
+
expect { subject }.to raise_error(ActiveRecord::RecordNotFound)
|
1445
|
+
end
|
1446
|
+
end
|
1447
|
+
|
1448
|
+
context "with unavailable payment method" do
|
1449
|
+
let(:payment_method) { create(:check_payment_method, display_on: "back_end") }
|
1450
|
+
|
1451
|
+
it "raises RecordNotFound" do
|
1452
|
+
expect { subject }.to raise_error(ActiveRecord::RecordNotFound)
|
1453
|
+
end
|
1454
|
+
end
|
1455
|
+
|
1456
|
+
context "with soft-deleted payment method" do
|
1457
|
+
let(:payment_method) { create(:check_payment_method, deleted_at: Time.current) }
|
1458
|
+
|
1459
|
+
it "raises RecordNotFound" do
|
1460
|
+
expect { subject }.to raise_error(ActiveRecord::RecordNotFound)
|
1461
|
+
end
|
1462
|
+
end
|
1463
|
+
end
|
1412
1464
|
end
|
@@ -618,12 +618,13 @@ describe Spree::Payment, :type => :model do
|
|
618
618
|
end
|
619
619
|
|
620
620
|
context "completed orders" do
|
621
|
+
let(:payment_method) { create(:check_payment_method) }
|
621
622
|
before { allow(order).to receive_messages completed?: true }
|
622
623
|
|
623
624
|
it "updates payment_state and shipments" do
|
624
625
|
expect(order.updater).to receive(:update_payment_state)
|
625
626
|
expect(order.updater).to receive(:update_shipment_state)
|
626
|
-
Spree::Payment.create(:
|
627
|
+
Spree::Payment.create!(amount: 100, order: order, payment_method: payment_method)
|
627
628
|
end
|
628
629
|
end
|
629
630
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solidus_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Solidus Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemerchant
|
@@ -1250,7 +1250,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1250
1250
|
version: '0'
|
1251
1251
|
requirements: []
|
1252
1252
|
rubyforge_project:
|
1253
|
-
rubygems_version: 2.
|
1253
|
+
rubygems_version: 2.6.11
|
1254
1254
|
signing_key:
|
1255
1255
|
specification_version: 4
|
1256
1256
|
summary: Essential models, mailers, and classes for the Solidus e-commerce project.
|