solidus_core 3.1.6 → 3.1.8

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 765367a8eed914a5abca0f078c5ffd7d3e341c504e10311e952d466e10027c32
4
- data.tar.gz: '08f36210b6b9bbf66d82c5e4bf6fa161c9f1552c003c693d5afd732065c16abc'
3
+ metadata.gz: 8f45a560814372c86415b5d4e8db66ca2f207ebc57bff2ca356f621a2655eee2
4
+ data.tar.gz: af28ac79880c299ef7fa0b3df30e6618b82726ba88ca03aecc1fd3742235d6b1
5
5
  SHA512:
6
- metadata.gz: 9b1189c36bd365b71dd7fe4e8ed68402db4c32d1e87ea2571b9c8ae0669ce68a1ffb8a06ec195ccdd06791d942847a10db93248bd71b324d853e724f0b0b7e16
7
- data.tar.gz: f82f01282ead4f27433e352fb2f7d793187e7efa573fdf9627c37412e944afb312e4d4ef28d4dd550111aa215c0baa47632d9152f09baa1505c2a31186e13e4a
6
+ metadata.gz: a94d1ad899fa99e5955999ec9a024299a1f64ded2054b0dcadd9a0a6bb298b2954f722ff0d93b983c354fedbf7e93b2b78cd818ad2937bb7aef32a1d8efae428
7
+ data.tar.gz: c8636e3c2f9874ac946c0eb8234772f1bc5f07e44533f10002d881e84175ee604e64fc02f72da9c7317e175deb8ea05a20b3f011ca5f1aec621265b377c84e51
@@ -18,7 +18,7 @@ module Spree
18
18
  has_many :stock_locations, through: :user_stock_locations
19
19
 
20
20
  has_many :spree_orders, foreign_key: "user_id", class_name: "Spree::Order"
21
- has_many :orders, foreign_key: "user_id", class_name: "Spree::Order", dependent: :restrict_with_exception
21
+ has_many :orders, foreign_key: "user_id", class_name: "Spree::Order"
22
22
 
23
23
  has_many :store_credits, -> { includes(:credit_type) }, foreign_key: "user_id", class_name: "Spree::StoreCredit"
24
24
  has_many :store_credit_events, through: :store_credits
@@ -27,6 +27,7 @@ module Spree
27
27
  has_many :wallet_payment_sources, foreign_key: 'user_id', class_name: 'Spree::WalletPaymentSource', inverse_of: :user
28
28
 
29
29
  after_create :auto_generate_spree_api_key
30
+ before_destroy :check_for_deletion
30
31
 
31
32
  include Spree::RansackableAttributes unless included_modules.include?(Spree::RansackableAttributes)
32
33
 
@@ -76,5 +77,23 @@ module Spree
76
77
  currency: currency,
77
78
  )
78
79
  end
80
+
81
+ # Restrict to delete users with existing orders
82
+ #
83
+ # Override this in your user model class to add another logic.
84
+ #
85
+ # Ie. to allow to delete users with incomplete orders add:
86
+ #
87
+ # orders.complete.none?
88
+ #
89
+ def can_be_deleted?
90
+ orders.none?
91
+ end
92
+
93
+ private
94
+
95
+ def check_for_deletion
96
+ raise ActiveRecord::DeleteRestrictionError unless can_be_deleted?
97
+ end
79
98
  end
80
99
  end
@@ -2,10 +2,83 @@
2
2
 
3
3
  module Spree
4
4
  class LogEntry < Spree::Base
5
+ # Classes used in core that can be present in serialized details
6
+ #
7
+ # Users can add their own classes in
8
+ # `Spree::Config#log_entry_permitted_classes`.
9
+ #
10
+ # @see Spree::AppConfiguration#log_entry_permitted_classes
11
+ CORE_PERMITTED_CLASSES = [
12
+ ActiveMerchant::Billing::Response,
13
+ ActiveSupport::TimeWithZone,
14
+ Time,
15
+ ActiveSupport::TimeZone
16
+ ].freeze
17
+
18
+ # Raised when a disallowed class is tried to be loaded
19
+ class DisallowedClass < RuntimeError
20
+ attr_reader :psych_exception
21
+
22
+ def initialize(psych_exception:)
23
+ @psych_exception = psych_exception
24
+ super(default_message)
25
+ end
26
+
27
+ private
28
+
29
+ def default_message
30
+ <<~MSG
31
+ #{psych_exception.message}
32
+
33
+ You can specify custom classes to be loaded in config/initializers/spree.rb. E.g:
34
+
35
+ Spree.config do |config|
36
+ config.log_entry_permitted_classes = ['MyClass']
37
+ end
38
+ MSG
39
+ end
40
+ end
41
+
42
+ # Raised when YAML contains aliases and they're not enabled
43
+ class BadAlias < RuntimeError
44
+ attr_reader :psych_exception
45
+
46
+ def initialize(psych_exception:)
47
+ @psych_exception = psych_exception
48
+ super(default_message)
49
+ end
50
+
51
+ private
52
+
53
+ def default_message
54
+ <<~MSG
55
+ #{psych_exception.message}
56
+
57
+ You can explicitly enable aliases in config/initializers/spree.rb. E.g:
58
+
59
+ Spree.config do |config|
60
+ config.log_entry_allow_aliases = true
61
+ end
62
+ MSG
63
+ end
64
+ end
65
+
66
+ def self.permitted_classes
67
+ CORE_PERMITTED_CLASSES + Spree::Config.log_entry_permitted_classes.map(&:constantize)
68
+ end
69
+
5
70
  belongs_to :source, polymorphic: true, optional: true
6
71
 
7
72
  def parsed_details
8
- @details ||= YAML.load(details)
73
+ @details ||= YAML.safe_load(
74
+ details,
75
+ permitted_classes: self.class.permitted_classes,
76
+ aliases: Spree::Config.log_entry_allow_aliases
77
+ )
78
+ rescue Psych::DisallowedClass => e
79
+ raise DisallowedClass.new(psych_exception: e)
80
+ rescue Psych::BadAlias => e
81
+ raise BadAlias.new(psych_exception: e)
9
82
  end
10
83
  end
11
84
  end
@@ -55,7 +55,7 @@ module Spree
55
55
 
56
56
  def display_country
57
57
  if country_iso
58
- "#{country_iso} (#{country.name})"
58
+ "#{country_iso} (#{I18n.t(country_iso, scope: [:spree, :country_names])})"
59
59
  else
60
60
  I18n.t(:any_country, scope: [:spree, :admin, :prices])
61
61
  end
@@ -1004,6 +1004,8 @@ en:
1004
1004
  use_product_tax_category: Use Product Tax Category
1005
1005
  new:
1006
1006
  new_variant: New Variant
1007
+ table:
1008
+ no_variants_found: No variants found for '%{term}'
1007
1009
  table_filter:
1008
1010
  show_deleted: Show Deleted Variants
1009
1011
  administration: Administration
@@ -1170,10 +1172,257 @@ en:
1170
1172
  country_based: Country Based
1171
1173
  country_name: Name
1172
1174
  country_names:
1175
+ AD: Andorra
1176
+ AE: United Arab Emirates
1177
+ AF: Afghanistan
1178
+ AG: Antigua and Barbuda
1179
+ AI: Anguilla
1180
+ AL: Albania
1181
+ AM: Armenia
1182
+ AO: Angola
1183
+ AQ: Antarctica
1184
+ AR: Argentina
1185
+ AS: American Samoa
1186
+ AT: Austria
1187
+ AU: Australia
1188
+ AW: Aruba
1189
+ AX: Åland Islands
1190
+ AZ: Azerbaijan
1191
+ BA: Bosnia and Herzegovina
1192
+ BB: Barbados
1193
+ BD: Bangladesh
1194
+ BE: Belgium
1195
+ BF: Burkina Faso
1196
+ BG: Bulgaria
1197
+ BH: Bahrain
1198
+ BI: Burundi
1199
+ BJ: Benin
1200
+ BL: Saint Barthélemy
1201
+ BM: Bermuda
1202
+ BN: Brunei Darussalam
1203
+ BO: Bolivia, Plurinational State of
1204
+ BQ: Bonaire, Sint Eustatius and Saba
1205
+ BR: Brazil
1206
+ BS: Bahamas
1207
+ BT: Bhutan
1208
+ BV: Bouvet Island
1209
+ BW: Botswana
1210
+ BY: Belarus
1211
+ BZ: Belize
1173
1212
  CA: Canada
1213
+ CC: Cocos (Keeling) Islands
1214
+ CD: Congo, The Democratic Republic of the
1215
+ CF: Central African Republic
1216
+ CG: Congo
1217
+ CH: Switzerland
1218
+ CI: Côte d'Ivoire
1219
+ CK: Cook Islands
1220
+ CL: Chile
1221
+ CM: Cameroon
1222
+ CN: China
1223
+ CO: Colombia
1224
+ CR: Costa Rica
1225
+ CU: Cuba
1226
+ CV: Cabo Verde
1227
+ CW: Curaçao
1228
+ CX: Christmas Island
1229
+ CY: Cyprus
1230
+ CZ: Czechia
1231
+ DE: Germany
1232
+ DJ: Djibouti
1233
+ DK: Denmark
1234
+ DM: Dominica
1235
+ DO: Dominican Republic
1236
+ DZ: Algeria
1237
+ EC: Ecuador
1238
+ EE: Estonia
1239
+ EG: Egypt
1240
+ EH: Western Sahara
1241
+ ER: Eritrea
1242
+ ES: Spain
1243
+ ET: Ethiopia
1244
+ FI: Finland
1245
+ FJ: Fiji
1246
+ FK: Falkland Islands (Malvinas)
1247
+ FM: Micronesia, Federated States of
1248
+ FO: Faroe Islands
1249
+ FR: France
1174
1250
  FRA: France
1251
+ GA: Gabon
1252
+ GB: United Kingdom
1253
+ GD: Grenada
1254
+ GE: Georgia
1255
+ GF: French Guiana
1256
+ GG: Guernsey
1257
+ GH: Ghana
1258
+ GI: Gibraltar
1259
+ GL: Greenland
1260
+ GM: Gambia
1261
+ GN: Guinea
1262
+ GP: Guadeloupe
1263
+ GQ: Equatorial Guinea
1264
+ GR: Greece
1265
+ GS: South Georgia and the South Sandwich Islands
1266
+ GT: Guatemala
1267
+ GU: Guam
1268
+ GW: Guinea-Bissau
1269
+ GY: Guyana
1270
+ HK: Hong Kong
1271
+ HM: Heard Island and McDonald Islands
1272
+ HN: Honduras
1273
+ HR: Croatia
1274
+ HT: Haiti
1275
+ HU: Hungary
1276
+ ID: Indonesia
1277
+ IE: Ireland
1278
+ IL: Israel
1279
+ IM: Isle of Man
1280
+ IN: India
1281
+ IO: British Indian Ocean Territory
1282
+ IQ: Iraq
1283
+ IR: Iran, Islamic Republic of
1284
+ IS: Iceland
1285
+ IT: Italy
1175
1286
  ITA: Italy
1287
+ JE: Jersey
1288
+ JM: Jamaica
1289
+ JO: Jordan
1290
+ JP: Japan
1291
+ KE: Kenya
1292
+ KG: Kyrgyzstan
1293
+ KH: Cambodia
1294
+ KI: Kiribati
1295
+ KM: Comoros
1296
+ KN: Saint Kitts and Nevis
1297
+ KP: Korea, Democratic People's Republic of
1298
+ KR: Korea, Republic of
1299
+ KW: Kuwait
1300
+ KY: Cayman Islands
1301
+ KZ: Kazakhstan
1302
+ LA: Lao People's Democratic Republic
1303
+ LB: Lebanon
1304
+ LC: Saint Lucia
1305
+ LI: Liechtenstein
1306
+ LK: Sri Lanka
1307
+ LR: Liberia
1308
+ LS: Lesotho
1309
+ LT: Lithuania
1310
+ LU: Luxembourg
1311
+ LV: Latvia
1312
+ LY: Libya
1313
+ MA: Morocco
1314
+ MC: Monaco
1315
+ MD: Moldova, Republic of
1316
+ ME: Montenegro
1317
+ MF: Saint Martin (French part)
1318
+ MG: Madagascar
1319
+ MH: Marshall Islands
1320
+ MK: North Macedonia
1321
+ ML: Mali
1322
+ MM: Myanmar
1323
+ MN: Mongolia
1324
+ MO: Macao
1325
+ MP: Northern Mariana Islands
1326
+ MQ: Martinique
1327
+ MR: Mauritania
1328
+ MS: Montserrat
1329
+ MT: Malta
1330
+ MU: Mauritius
1331
+ MV: Maldives
1332
+ MW: Malawi
1333
+ MX: Mexico
1334
+ MY: Malaysia
1335
+ MZ: Mozambique
1336
+ NA: Namibia
1337
+ NC: New Caledonia
1338
+ NE: Niger
1339
+ NF: Norfolk Island
1340
+ NG: Nigeria
1341
+ NI: Nicaragua
1342
+ NL: Netherlands
1343
+ 'NO': Norway
1344
+ NP: Nepal
1345
+ NR: Nauru
1346
+ NU: Niue
1347
+ NZ: New Zealand
1348
+ OM: Oman
1349
+ PA: Panama
1350
+ PE: Peru
1351
+ PF: French Polynesia
1352
+ PG: Papua New Guinea
1353
+ PH: Philippines
1354
+ PK: Pakistan
1355
+ PL: Poland
1356
+ PM: Saint Pierre and Miquelon
1357
+ PN: Pitcairn
1358
+ PR: Puerto Rico
1359
+ PS: Palestine, State of
1360
+ PT: Portugal
1361
+ PW: Palau
1362
+ PY: Paraguay
1363
+ QA: Qatar
1364
+ RE: Réunion
1365
+ RO: Romania
1366
+ RS: Serbia
1367
+ RU: Russia
1368
+ RW: Rwanda
1369
+ SA: Saudi Arabia
1370
+ SB: Solomon Islands
1371
+ SC: Seychelles
1372
+ SD: Sudan
1373
+ SE: Sweden
1374
+ SG: Singapore
1375
+ SH: Saint Helena, Ascension and Tristan da Cunha
1376
+ SI: Slovenia
1377
+ SJ: Svalbard and Jan Mayen
1378
+ SK: Slovakia
1379
+ SL: Sierra Leone
1380
+ SM: San Marino
1381
+ SN: Senegal
1382
+ SO: Somalia
1383
+ SR: Suriname
1384
+ SS: South Sudan
1385
+ ST: Sao Tome and Principe
1386
+ SV: El Salvador
1387
+ SX: Sint Maarten (Dutch part)
1388
+ SY: Syrian Arab Republic
1389
+ SZ: Eswatini
1390
+ TC: Turks and Caicos Islands
1391
+ TD: Chad
1392
+ TF: French Southern Territories
1393
+ TG: Togo
1394
+ TH: Thailand
1395
+ TJ: Tajikistan
1396
+ TK: Tokelau
1397
+ TL: Timor-Leste
1398
+ TM: Turkmenistan
1399
+ TN: Tunisia
1400
+ TO: Tonga
1401
+ TR: Turkey
1402
+ TT: Trinidad and Tobago
1403
+ TV: Tuvalu
1404
+ TW: Taiwan
1405
+ TZ: Tanzania, United Republic of
1406
+ UA: Ukraine
1407
+ UG: Uganda
1408
+ UM: United States Minor Outlying Islands
1176
1409
  US: United States of America
1410
+ UY: Uruguay
1411
+ UZ: Uzbekistan
1412
+ VA: Holy See (Vatican City State)
1413
+ VC: Saint Vincent and the Grenadines
1414
+ VE: Venezuela, Bolivarian Republic of
1415
+ VG: Virgin Islands, British
1416
+ VI: Virgin Islands, U.S.
1417
+ VN: Vietnam
1418
+ VU: Vanuatu
1419
+ WF: Wallis and Futuna
1420
+ WS: Samoa
1421
+ YE: Yemen
1422
+ YT: Mayotte
1423
+ ZA: South Africa
1424
+ ZM: Zambia
1425
+ ZW: Zimbabwe
1177
1426
  coupon: Coupon
1178
1427
  coupon_code: Coupon code
1179
1428
  coupon_code_already_applied: The coupon code has already been applied to this
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'rails/generators'
4
+ require 'rails/version'
4
5
 
5
6
  module Solidus
6
7
  # @private
@@ -15,7 +16,7 @@ module Solidus
15
16
  class_option :migrate, type: :boolean, default: true, banner: 'Run Solidus migrations'
16
17
  class_option :seed, type: :boolean, default: true, banner: 'Load seed data (migrations must be run)'
17
18
  class_option :sample, type: :boolean, default: true, banner: 'Load sample data (migrations must be run)'
18
- class_option :active_storage, type: :boolean, default: true, banner: 'Install ActiveStorage as image attachments handler for products and taxons'
19
+ class_option :active_storage, type: :boolean, default: Rails.gem_version >= Gem::Version.new("6.1.0"), banner: 'Install ActiveStorage as image attachments handler for products and taxons'
19
20
  class_option :auto_accept, type: :boolean
20
21
  class_option :user_class, type: :string
21
22
  class_option :admin_email, type: :string
@@ -21,6 +21,7 @@ require "spree/core/search/base"
21
21
  require "spree/core/search/variant"
22
22
  require 'spree/preferences/configuration'
23
23
  require 'spree/core/environment'
24
+ require 'rails/gem_version'
24
25
 
25
26
  module Spree
26
27
  class AppConfiguration < Preferences::Configuration
@@ -165,6 +166,22 @@ module Spree
165
166
  # @return [String] URL of logo used on frontend (default: +'logo/solidus.svg'+)
166
167
  preference :logo, :string, default: 'logo/solidus.svg'
167
168
 
169
+ # @!attribute [rw] log_entry_permitted_classes
170
+ # @return [Array<String>] An array of extra classes that are allowed to be
171
+ # loaded from a serialized YAML as details in {Spree::LogEntry}
172
+ # (defaults to a non-frozen empty array, so that extensions can add
173
+ # their own classes).
174
+ # @example
175
+ # config.log_entry_permitted_classes = ['Date']
176
+ preference :log_entry_permitted_classes, :array, default: []
177
+
178
+ # @!attribute [rw] log_entry_allow_aliases
179
+ # @return [Boolean] Whether YAML aliases are allowed when loading
180
+ # serialized data in {Spree::LogEntry}. It defaults to true. Depending
181
+ # on the source of your data, you may consider disabling it to prevent
182
+ # entity expansion attacks.
183
+ preference :log_entry_allow_aliases, :boolean, default: true
184
+
168
185
  # @!attribute [rw] mails_from
169
186
  # @return [String] Email address used as +From:+ field in transactional emails.
170
187
  preference :mails_from, :string, default: 'solidus@example.com'
@@ -465,7 +482,7 @@ module Spree
465
482
  # @!attribute [rw] image_attachment_module
466
483
  # @return [Module] a module that can be included into Spree::Image to allow attachments
467
484
  # Enumerable of images adhering to the present_image_class interface
468
- class_name_attribute :image_attachment_module, default: 'Spree::Image::ActiveStorageAttachment'
485
+ class_name_attribute :image_attachment_module, default: Rails.gem_version >= Gem::Version.new("6.1.0") ? "Spree::Image::ActiveStorageAttachment" : "Spree::Image::PaperclipAttachment"
469
486
 
470
487
  # @!attribute [rw] allowed_image_mime_types
471
488
  #
@@ -523,7 +540,7 @@ module Spree
523
540
  # @!attribute [rw] taxon_attachment_module
524
541
  # @return [Module] a module that can be included into Spree::Taxon to allow attachments
525
542
  # Enumerable of taxons adhering to the present_taxon_class interface
526
- class_name_attribute :taxon_attachment_module, default: 'Spree::Taxon::ActiveStorageAttachment'
543
+ class_name_attribute :taxon_attachment_module, default: Rails.gem_version >= Gem::Version.new("6.1.0") ? "Spree::Taxon::ActiveStorageAttachment" : "Spree::Taxon::PaperclipAttachment"
527
544
 
528
545
  # Allows providing your own class instance for generating order numbers.
529
546
  #
@@ -15,6 +15,12 @@ module Spree
15
15
  generator.test_framework :rspec
16
16
  end
17
17
 
18
+ if ActiveRecord.respond_to?(:yaml_column_permitted_classes) || ActiveRecord::Base.respond_to?(:yaml_column_permitted_classes)
19
+ config.active_record.yaml_column_permitted_classes ||= []
20
+ config.active_record.yaml_column_permitted_classes |=
21
+ [Symbol, BigDecimal, ActiveSupport::HashWithIndifferentAccess]
22
+ end
23
+
18
24
  initializer "spree.environment", before: :load_config_initializers do |app|
19
25
  app.config.spree = Spree::Config.environment
20
26
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Spree
4
- VERSION = "3.1.6"
4
+ VERSION = "3.1.8"
5
5
 
6
6
  def self.solidus_version
7
7
  VERSION
@@ -21,6 +21,12 @@ FactoryBot.define do
21
21
  end
22
22
  end
23
23
 
24
+ trait :with_orders do
25
+ after(:create) do |user, _|
26
+ create(:order, user: user)
27
+ end
28
+ end
29
+
24
30
  factory :admin_user do
25
31
  after(:create) do |user, _|
26
32
  admin_role = Spree::Role.find_by(name: 'admin') || create(:role, name: 'admin')
data/solidus_core.gemspec CHANGED
@@ -40,6 +40,7 @@ Gem::Specification.new do |s|
40
40
  s.add_dependency 'mini_magick', '~> 4.10'
41
41
  s.add_dependency 'monetize', '~> 1.8'
42
42
  s.add_dependency 'kt-paperclip', '~> 6.3'
43
+ s.add_dependency 'psych', ['>= 3.1.0', '< 5.0']
43
44
  s.add_dependency 'ransack', '~> 2.0'
44
45
  s.add_dependency 'state_machines-activerecord', '~> 0.6'
45
46
 
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: 3.1.6
4
+ version: 3.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Solidus Team
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-01 00:00:00.000000000 Z
11
+ date: 2022-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionmailer
@@ -344,6 +344,26 @@ dependencies:
344
344
  - - "~>"
345
345
  - !ruby/object:Gem::Version
346
346
  version: '6.3'
347
+ - !ruby/object:Gem::Dependency
348
+ name: psych
349
+ requirement: !ruby/object:Gem::Requirement
350
+ requirements:
351
+ - - ">="
352
+ - !ruby/object:Gem::Version
353
+ version: 3.1.0
354
+ - - "<"
355
+ - !ruby/object:Gem::Version
356
+ version: '5.0'
357
+ type: :runtime
358
+ prerelease: false
359
+ version_requirements: !ruby/object:Gem::Requirement
360
+ requirements:
361
+ - - ">="
362
+ - !ruby/object:Gem::Version
363
+ version: 3.1.0
364
+ - - "<"
365
+ - !ruby/object:Gem::Version
366
+ version: '5.0'
347
367
  - !ruby/object:Gem::Dependency
348
368
  name: ransack
349
369
  requirement: !ruby/object:Gem::Requirement
@@ -954,8 +974,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
954
974
  - !ruby/object:Gem::Version
955
975
  version: 1.8.23
956
976
  requirements: []
957
- rubygems_version: 3.2.31
958
- signing_key:
977
+ rubygems_version: 3.3.7
978
+ signing_key:
959
979
  specification_version: 4
960
980
  summary: Essential models, mailers, and classes for the Solidus e-commerce project.
961
981
  test_files: []