solidus_core 1.1.3 → 1.1.4

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_core might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fb628effcfda240354e15e2ae099740a7e10d5d6
4
- data.tar.gz: 1e6540e660eca7a4d3e4b69ea0dd9266a676ea69
3
+ metadata.gz: 9161c98f377c58e982a151cdeb6c8ac7a2b5f656
4
+ data.tar.gz: 480fc65e5d85570f6eef9ae0f29cb45ca5f47e28
5
5
  SHA512:
6
- metadata.gz: 3c8c0564b65175ea0a19830eb1569a59ffca329a530bee748c66f78ea8a23fc12eeccba3da510a56dfcfc2a75e220b7660afee0e961669587eec6031a8501ac3
7
- data.tar.gz: 44ab87bbf973df9ba2f092466631bf701f90214755e23287b39b0d298eee3fe84f1ea455e7505ef33cef1326a73341103eb5a78f3fe2af559fef9186febd54e6
6
+ metadata.gz: 752f95c291e1810aa18c3973920e6e7cbdd279447de14da7a781d22962e946b41747867ee9c7c2c0c739ced9aa6f05fd357f2756d234b46228593f821f4295ee
7
+ data.tar.gz: 3c049638968609ca75f2d49b878c334e7cfa2532a9684b565d1d2c2e0382320ed72841529a6d8610b80c22ecbc2311da70c38c9085e63d07e1c1b6ae39e0f9c5
@@ -709,6 +709,23 @@ module Spree
709
709
  Spree::Money.new(total_available_store_credit - total_applicable_store_credit, { currency: currency })
710
710
  end
711
711
 
712
+ def payments_attributes=(attributes)
713
+ validate_payments_attributes(attributes)
714
+ super(attributes)
715
+ end
716
+
717
+ def validate_payments_attributes(attributes)
718
+ attributes = Array.wrap(attributes)
719
+ # Ensure the payment methods specified are allowed for this user
720
+ payment_methods = Spree::PaymentMethod.where(id: available_payment_methods)
721
+ attributes.each do |payment_attributes|
722
+ payment_method_id = payment_attributes[:payment_method_id]
723
+
724
+ # raise RecordNotFound unless it is an allowed payment method
725
+ payment_methods.find(payment_method_id) if payment_method_id
726
+ end
727
+ end
728
+
712
729
  private
713
730
 
714
731
  def link_by_email
@@ -38,6 +38,7 @@ module Spree
38
38
 
39
39
  validates :amount, numericality: true
40
40
  validates :source, presence: true, if: :source_required?
41
+ validates :payment_method, presence: true
41
42
 
42
43
  default_scope -> { order(:created_at) }
43
44
 
@@ -126,7 +126,7 @@ end
126
126
  core_gems = ["spree/core", "spree/api", "spree/backend", "spree/frontend"]
127
127
 
128
128
  if core_gems.include?(lib_name)
129
- '../../../../../Gemfile'
129
+ '../../../../Gemfile'
130
130
  else
131
131
  '../../../../Gemfile'
132
132
  end
@@ -7,7 +7,4 @@
7
7
  //= require jquery
8
8
  //= require jquery_ujs
9
9
  //= require spree/backend
10
- <% unless options[:lib_name] == 'spree' || options[:lib_name] == 'spree/backend' %>
11
- //= require spree/backend/<%= options[:lib_name].gsub("/", "_") %>
12
- <% end %>
13
10
  //= require_tree .
@@ -7,7 +7,4 @@
7
7
  //= require jquery
8
8
  //= require jquery_ujs
9
9
  //= require spree/frontend
10
- <% unless options[:lib_name] == 'spree' || options[:lib_name] == 'spree/frontend' %>
11
- //= require spree/frontend/<%= options[:lib_name].gsub("/", "_") %>
12
- <% end %>
13
10
  //= require_tree .
@@ -4,9 +4,6 @@
4
4
  * the top of the compiled file, but it's generally better to create a new file per style scope.
5
5
  *
6
6
  *= require spree/backend
7
- <% unless options[:lib_name] == 'spree' || options[:lib_name] == 'spree/backend' %>
8
- *= require spree/backend/<%= options[:lib_name].gsub("/", "_") %>
9
- <% end %>
10
7
  *= require_self
11
8
  *= require_tree .
12
9
  */
@@ -4,9 +4,6 @@
4
4
  * the top of the compiled file, but it's generally better to create a new file per style scope.
5
5
  *
6
6
  *= require spree/frontend
7
- <% unless options[:lib_name] == 'spree' || options[:lib_name] == 'spree/frontend' %>
8
- *= require spree/frontend/<%= options[:lib_name].gsub("/", "_") %>
9
- <% end %>
10
7
  *= require_self
11
8
  *= require_tree .
12
9
  */
@@ -1479,4 +1479,56 @@ describe Spree::Order, :type => :model do
1479
1479
  end
1480
1480
  end
1481
1481
  end
1482
+
1483
+ describe "#validate_payments_attributes" do
1484
+ let(:attributes) { [ActionController::Parameters.new(payment_method_id: payment_method.id)] }
1485
+ subject do
1486
+ order.validate_payments_attributes(attributes)
1487
+ end
1488
+
1489
+ context "with empty array" do
1490
+ let(:attributes) { [] }
1491
+ it "doesn't error" do
1492
+ subject
1493
+ end
1494
+ end
1495
+
1496
+ context "with no payment method specified" do
1497
+ let(:attributes) { [ActionController::Parameters.new({})] }
1498
+ it "doesn't error" do
1499
+ subject
1500
+ end
1501
+ end
1502
+
1503
+ context "with valid payment method" do
1504
+ let(:payment_method) { create(:check_payment_method) }
1505
+ it "doesn't error" do
1506
+ subject
1507
+ end
1508
+ end
1509
+
1510
+ context "with inactive payment method" do
1511
+ let(:payment_method) { create(:check_payment_method, active: false) }
1512
+
1513
+ it "raises RecordNotFound" do
1514
+ expect { subject }.to raise_error(ActiveRecord::RecordNotFound)
1515
+ end
1516
+ end
1517
+
1518
+ context "with unavailable payment method" do
1519
+ let(:payment_method) { create(:check_payment_method, display_on: "back_end") }
1520
+
1521
+ it "raises RecordNotFound" do
1522
+ expect { subject }.to raise_error(ActiveRecord::RecordNotFound)
1523
+ end
1524
+ end
1525
+
1526
+ context "with soft-deleted payment method" do
1527
+ let(:payment_method) { create(:check_payment_method, deleted_at: Time.current) }
1528
+
1529
+ it "raises RecordNotFound" do
1530
+ expect { subject }.to raise_error(ActiveRecord::RecordNotFound)
1531
+ end
1532
+ end
1533
+ end
1482
1534
  end
@@ -661,12 +661,13 @@ describe Spree::Payment, :type => :model do
661
661
  end
662
662
 
663
663
  context "completed orders" do
664
+ let(:payment_method) { create(:check_payment_method) }
664
665
  before { allow(order).to receive_messages completed?: true }
665
666
 
666
667
  it "updates payment_state and shipments" do
667
668
  expect(order.updater).to receive(:update_payment_state)
668
669
  expect(order.updater).to receive(:update_shipment_state)
669
- Spree::Payment.create(:amount => 100, :order => order)
670
+ Spree::Payment.create!(amount: 100, order: order, payment_method: payment_method)
670
671
  end
671
672
  end
672
673
 
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.1.3
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Solidus Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-23 00:00:00.000000000 Z
11
+ date: 2017-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemerchant
@@ -1305,9 +1305,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1305
1305
  version: '0'
1306
1306
  requirements: []
1307
1307
  rubyforge_project:
1308
- rubygems_version: 2.5.1
1308
+ rubygems_version: 2.6.11
1309
1309
  signing_key:
1310
1310
  specification_version: 4
1311
1311
  summary: Essential models, mailers, and classes for the Solidus e-commerce project.
1312
1312
  test_files: []
1313
- has_rdoc: