solidus_core 1.2.2 → 1.2.3
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 +4 -4
- data/app/models/spree/order.rb +17 -0
- data/app/models/spree/order_update_attributes.rb +2 -0
- data/app/models/spree/payment.rb +1 -0
- data/app/models/spree/preferences/statically_configurable.rb +2 -2
- data/db/default/spree/zones.rb +1 -1
- data/db/migrate/20140410141842_add_many_missing_indexes.rb +15 -13
- data/db/migrate/20140410150358_correct_some_polymorphic_index_and_add_more_missing.rb +40 -38
- data/db/migrate/20141217215630_update_product_slug_index.rb +4 -2
- data/db/migrate/20150723224133_remove_unnecessary_indexes.rb +2 -10
- data/lib/generators/spree/dummy/dummy_generator.rb +1 -1
- data/lib/generators/spree/install/templates/vendor/assets/javascripts/spree/backend/all.js +0 -3
- data/lib/generators/spree/install/templates/vendor/assets/javascripts/spree/frontend/all.js +0 -3
- data/lib/generators/spree/install/templates/vendor/assets/stylesheets/spree/backend/all.css +0 -3
- data/lib/generators/spree/install/templates/vendor/assets/stylesheets/spree/frontend/all.css +0 -3
- data/lib/spree/core.rb +1 -0
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/migration_helpers.rb +19 -0
- data/spec/models/spree/order_spec.rb +52 -0
- data/spec/models/spree/order_update_attributes_spec.rb +5 -1
- data/spec/models/spree/payment_spec.rb +2 -1
- data/spec/models/spree/preferences/statically_configurable_spec.rb +4 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c0fea50cb0031d9a121c7abfb25c015c86542f5
|
4
|
+
data.tar.gz: 9294f4effa7875921c5deef2e05c69c52d6abddf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e213a7266228cd8167cf8e1dab29442079d1bbb5a9eb885a9d30058b9110e95662b4984c4bb54248f1d9c98c7550e78b2483374b2895474b2ca38c2fbba94e9
|
7
|
+
data.tar.gz: 84b512524dc615c1803c2f4cd35039076f7e27b76bbe2a1ef8950a3a17d9423a21c64f0da75a4c177deff0db762cbbcc32bbdceb2b34c06e0ef09581ca98ea6f
|
data/app/models/spree/order.rb
CHANGED
@@ -681,6 +681,23 @@ module Spree
|
|
681
681
|
Spree::Money.new(total_available_store_credit - total_applicable_store_credit, { currency: currency })
|
682
682
|
end
|
683
683
|
|
684
|
+
def payments_attributes=(attributes)
|
685
|
+
validate_payments_attributes(attributes)
|
686
|
+
super(attributes)
|
687
|
+
end
|
688
|
+
|
689
|
+
def validate_payments_attributes(attributes)
|
690
|
+
attributes = Array.wrap(attributes)
|
691
|
+
# Ensure the payment methods specified are allowed for this user
|
692
|
+
payment_methods = Spree::PaymentMethod.where(id: available_payment_methods)
|
693
|
+
attributes.each do |payment_attributes|
|
694
|
+
payment_method_id = payment_attributes[:payment_method_id]
|
695
|
+
|
696
|
+
# raise RecordNotFound unless it is an allowed payment method
|
697
|
+
payment_methods.find(payment_method_id) if payment_method_id
|
698
|
+
end
|
699
|
+
end
|
700
|
+
|
684
701
|
private
|
685
702
|
|
686
703
|
def link_by_email
|
@@ -14,6 +14,8 @@ module Spree
|
|
14
14
|
# Assign the attributes to the order and save the order
|
15
15
|
# @return true if saved, otherwise false and errors will be set on the order
|
16
16
|
def apply
|
17
|
+
order.validate_payments_attributes(@payments_attributes)
|
18
|
+
|
17
19
|
assign_order_attributes
|
18
20
|
assign_payments_attributes
|
19
21
|
|
data/app/models/spree/payment.rb
CHANGED
@@ -22,14 +22,14 @@ module Spree
|
|
22
22
|
if respond_to?(:preference_source) && preference_source
|
23
23
|
self.class.preference_sources[preference_source] || {}
|
24
24
|
else
|
25
|
-
|
25
|
+
self[:preferences]
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
29
|
def preferences=(val)
|
30
30
|
if respond_to?(:preference_source) && preference_source
|
31
31
|
else
|
32
|
-
|
32
|
+
self[:preferences] = val
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
data/db/default/spree/zones.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
eu_vat = Spree::Zone.find_or_create_by!(name: "EU_VAT", description: "Countries that make up the EU VAT zone.")
|
2
2
|
north_america = Spree::Zone.find_or_create_by!(name: "North America", description: "USA + Canada")
|
3
3
|
|
4
|
-
%w(PL FI PT RO DE FR SK HU SI IE AT ES IT BE SE LV BG GB LT CY LU MT DK NL EE).
|
4
|
+
%w(PL FI PT RO DE FR SK HU SI IE AT ES IT BE SE LV BG GB LT CY LU MT DK NL EE HR CZ GR).
|
5
5
|
each do |symbol|
|
6
6
|
eu_vat.zone_members.create!(zoneable: Spree::Country.find_by!(iso: symbol))
|
7
7
|
end
|
@@ -1,17 +1,19 @@
|
|
1
1
|
class AddManyMissingIndexes < ActiveRecord::Migration
|
2
|
+
include Spree::MigrationHelpers
|
3
|
+
|
2
4
|
def change
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
5
|
+
safe_add_index :spree_adjustments, [:adjustable_id, :adjustable_type]
|
6
|
+
safe_add_index :spree_adjustments, :eligible
|
7
|
+
safe_add_index :spree_adjustments, :order_id
|
8
|
+
safe_add_index :spree_promotions, :code
|
9
|
+
safe_add_index :spree_promotions, :expires_at
|
10
|
+
safe_add_index :spree_states, :country_id
|
11
|
+
safe_add_index :spree_stock_items, :deleted_at
|
12
|
+
safe_add_index :spree_option_types, :position
|
13
|
+
safe_add_index :spree_option_values, :position
|
14
|
+
safe_add_index :spree_product_option_types, :option_type_id
|
15
|
+
safe_add_index :spree_product_option_types, :product_id
|
16
|
+
safe_add_index :spree_products_taxons, :position
|
17
|
+
safe_add_index :spree_promotions, :starts_at
|
16
18
|
end
|
17
19
|
end
|
@@ -1,63 +1,65 @@
|
|
1
1
|
class CorrectSomePolymorphicIndexAndAddMoreMissing < ActiveRecord::Migration
|
2
|
+
include Spree::MigrationHelpers
|
3
|
+
|
2
4
|
def change
|
3
|
-
|
4
|
-
|
5
|
+
safe_add_index :spree_addresses, :country_id
|
6
|
+
safe_add_index :spree_addresses, :state_id
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
+
safe_remove_index :spree_adjustments, [:source_type, :source_id]
|
9
|
+
safe_add_index :spree_adjustments, [:source_id, :source_type]
|
8
10
|
|
9
|
-
|
11
|
+
safe_add_index :spree_inventory_units, :return_authorization_id
|
10
12
|
|
11
|
-
|
13
|
+
safe_add_index :spree_log_entries, [:source_id, :source_type]
|
12
14
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
safe_add_index :spree_orders, :approver_id
|
16
|
+
safe_add_index :spree_orders, :created_by_id
|
17
|
+
safe_add_index :spree_orders, :ship_address_id
|
18
|
+
safe_add_index :spree_orders, :bill_address_id
|
19
|
+
safe_add_index :spree_orders, :considered_risky
|
18
20
|
|
19
|
-
|
21
|
+
safe_add_index :spree_orders_promotions, [:order_id, :promotion_id]
|
20
22
|
|
21
|
-
|
23
|
+
safe_add_index :spree_payments, [:source_id, :source_type]
|
22
24
|
|
23
|
-
|
25
|
+
safe_add_index :spree_product_option_types, :position
|
24
26
|
|
25
|
-
|
26
|
-
|
27
|
+
safe_add_index :spree_product_properties, :position
|
28
|
+
safe_add_index :spree_product_properties, :property_id
|
27
29
|
|
28
|
-
|
29
|
-
|
30
|
+
safe_add_index :spree_promotion_action_line_items, :promotion_action_id
|
31
|
+
safe_add_index :spree_promotion_action_line_items, :variant_id
|
30
32
|
|
31
|
-
|
33
|
+
safe_add_index :spree_promotion_rules, :promotion_id
|
32
34
|
|
33
|
-
|
35
|
+
safe_add_index :spree_promotions, :advertise
|
34
36
|
|
35
|
-
|
36
|
-
|
37
|
-
|
37
|
+
safe_add_index :spree_return_authorizations, :number
|
38
|
+
safe_add_index :spree_return_authorizations, :order_id
|
39
|
+
safe_add_index :spree_return_authorizations, :stock_location_id
|
38
40
|
|
39
|
-
|
41
|
+
safe_add_index :spree_shipments, :address_id
|
40
42
|
|
41
|
-
|
43
|
+
safe_add_index :spree_shipping_methods, :tax_category_id
|
42
44
|
|
43
|
-
|
44
|
-
|
45
|
+
safe_add_index :spree_state_changes, [:stateful_id, :stateful_type]
|
46
|
+
safe_add_index :spree_state_changes, :user_id
|
45
47
|
|
46
|
-
|
47
|
-
|
48
|
+
safe_add_index :spree_stock_locations, :country_id
|
49
|
+
safe_add_index :spree_stock_locations, :state_id
|
48
50
|
|
49
|
-
|
50
|
-
|
51
|
-
|
51
|
+
safe_add_index :spree_tax_rates, :deleted_at
|
52
|
+
safe_add_index :spree_tax_rates, :tax_category_id
|
53
|
+
safe_add_index :spree_tax_rates, :zone_id
|
52
54
|
|
53
|
-
|
55
|
+
safe_add_index :spree_taxonomies, :position
|
54
56
|
|
55
|
-
|
57
|
+
safe_add_index :spree_taxons, :position
|
56
58
|
|
57
|
-
|
58
|
-
|
59
|
+
safe_add_index :spree_variants, :position
|
60
|
+
safe_add_index :spree_variants, :track_inventory
|
59
61
|
|
60
|
-
|
61
|
-
|
62
|
+
safe_add_index :spree_zone_members, :zone_id
|
63
|
+
safe_add_index :spree_zone_members, [:zoneable_id, :zoneable_type]
|
62
64
|
end
|
63
65
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
class UpdateProductSlugIndex < ActiveRecord::Migration
|
2
|
+
include Spree::MigrationHelpers
|
3
|
+
|
2
4
|
def change
|
3
|
-
|
4
|
-
|
5
|
+
safe_remove_index :spree_products, :slug
|
6
|
+
safe_add_index :spree_products, :slug, unique: true
|
5
7
|
end
|
6
8
|
end
|
@@ -4,6 +4,8 @@
|
|
4
4
|
# migration deletes any of the indexes left around in stores using the
|
5
5
|
# out-dated version of that migration
|
6
6
|
class RemoveUnnecessaryIndexes < ActiveRecord::Migration
|
7
|
+
include Spree::MigrationHelpers
|
8
|
+
|
7
9
|
def up
|
8
10
|
safe_remove_index :spree_credit_cards, :address_id
|
9
11
|
safe_remove_index :spree_gateways, :active
|
@@ -59,14 +61,4 @@ class RemoveUnnecessaryIndexes < ActiveRecord::Migration
|
|
59
61
|
safe_add_index :spree_variants, :deleted_at
|
60
62
|
safe_add_index :spree_zones, :default_tax
|
61
63
|
end
|
62
|
-
|
63
|
-
private
|
64
|
-
|
65
|
-
def safe_remove_index(table, column)
|
66
|
-
remove_index(table, column) if index_exists?(table, column)
|
67
|
-
end
|
68
|
-
|
69
|
-
def safe_add_index(table, column)
|
70
|
-
add_index(table, column) if column_exists?(table, column)
|
71
|
-
end
|
72
64
|
end
|
@@ -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
|
*/
|
data/lib/generators/spree/install/templates/vendor/assets/stylesheets/spree/frontend/all.css
CHANGED
@@ -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
|
*/
|
data/lib/spree/core.rb
CHANGED
data/lib/spree/core/version.rb
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
module Spree
|
2
|
+
module MigrationHelpers
|
3
|
+
def safe_remove_index(table, column)
|
4
|
+
remove_index(table, column) if index_exists?(table, column)
|
5
|
+
end
|
6
|
+
|
7
|
+
def safe_add_index(table, column, options = {})
|
8
|
+
if columns_exist?(table, column) && !index_exists?(table, column, options)
|
9
|
+
add_index(table, column, options)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def columns_exist?(table, columns)
|
16
|
+
Array.wrap(columns).all? { |column| column_exists?(table, column) }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -1411,4 +1411,56 @@ describe Spree::Order, :type => :model do
|
|
1411
1411
|
end
|
1412
1412
|
end
|
1413
1413
|
end
|
1414
|
+
|
1415
|
+
describe "#validate_payments_attributes" do
|
1416
|
+
let(:attributes) { [ActionController::Parameters.new(payment_method_id: payment_method.id)] }
|
1417
|
+
subject do
|
1418
|
+
order.validate_payments_attributes(attributes)
|
1419
|
+
end
|
1420
|
+
|
1421
|
+
context "with empty array" do
|
1422
|
+
let(:attributes) { [] }
|
1423
|
+
it "doesn't error" do
|
1424
|
+
subject
|
1425
|
+
end
|
1426
|
+
end
|
1427
|
+
|
1428
|
+
context "with no payment method specified" do
|
1429
|
+
let(:attributes) { [ActionController::Parameters.new({})] }
|
1430
|
+
it "doesn't error" do
|
1431
|
+
subject
|
1432
|
+
end
|
1433
|
+
end
|
1434
|
+
|
1435
|
+
context "with valid payment method" do
|
1436
|
+
let(:payment_method) { create(:check_payment_method) }
|
1437
|
+
it "doesn't error" do
|
1438
|
+
subject
|
1439
|
+
end
|
1440
|
+
end
|
1441
|
+
|
1442
|
+
context "with inactive payment method" do
|
1443
|
+
let(:payment_method) { create(:check_payment_method, active: false) }
|
1444
|
+
|
1445
|
+
it "raises RecordNotFound" do
|
1446
|
+
expect { subject }.to raise_error(ActiveRecord::RecordNotFound)
|
1447
|
+
end
|
1448
|
+
end
|
1449
|
+
|
1450
|
+
context "with unavailable payment method" do
|
1451
|
+
let(:payment_method) { create(:check_payment_method, display_on: "back_end") }
|
1452
|
+
|
1453
|
+
it "raises RecordNotFound" do
|
1454
|
+
expect { subject }.to raise_error(ActiveRecord::RecordNotFound)
|
1455
|
+
end
|
1456
|
+
end
|
1457
|
+
|
1458
|
+
context "with soft-deleted payment method" do
|
1459
|
+
let(:payment_method) { create(:check_payment_method, deleted_at: Time.current) }
|
1460
|
+
|
1461
|
+
it "raises RecordNotFound" do
|
1462
|
+
expect { subject }.to raise_error(ActiveRecord::RecordNotFound)
|
1463
|
+
end
|
1464
|
+
end
|
1465
|
+
end
|
1414
1466
|
end
|
@@ -3,6 +3,7 @@ require 'spec_helper'
|
|
3
3
|
module Spree
|
4
4
|
RSpec.describe OrderUpdateAttributes do
|
5
5
|
let(:order) { create(:order) }
|
6
|
+
let(:payment_method) { create(:payment_method) }
|
6
7
|
let(:request_env) { nil }
|
7
8
|
let(:update) { described_class.new(order, attributes, request_env: request_env) }
|
8
9
|
|
@@ -25,7 +26,10 @@ module Spree
|
|
25
26
|
let(:attributes) do
|
26
27
|
{
|
27
28
|
payments_attributes: [
|
28
|
-
{
|
29
|
+
{
|
30
|
+
payment_method_id: payment_method.id,
|
31
|
+
source_attributes: attributes_for(:credit_card)
|
32
|
+
}
|
29
33
|
]
|
30
34
|
}
|
31
35
|
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(:
|
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.2.
|
4
|
+
version: 1.2.3
|
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
|
@@ -936,6 +936,7 @@ files:
|
|
936
936
|
- lib/spree/localized_number.rb
|
937
937
|
- lib/spree/mailer_previews/carton_preview.rb
|
938
938
|
- lib/spree/mailer_previews/order_preview.rb
|
939
|
+
- lib/spree/migration_helpers.rb
|
939
940
|
- lib/spree/migrations.rb
|
940
941
|
- lib/spree/money.rb
|
941
942
|
- lib/spree/permission_sets.rb
|
@@ -1367,7 +1368,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1367
1368
|
version: '0'
|
1368
1369
|
requirements: []
|
1369
1370
|
rubyforge_project:
|
1370
|
-
rubygems_version: 2.
|
1371
|
+
rubygems_version: 2.6.11
|
1371
1372
|
signing_key:
|
1372
1373
|
specification_version: 4
|
1373
1374
|
summary: Essential models, mailers, and classes for the Solidus e-commerce project.
|