spree_core 5.2.0.rc1 → 5.2.0.rc2

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: 20e9c99845e0d1dd7461034a9ec11d3e6d9130126a3ac517e0f7f387ebe43030
4
- data.tar.gz: ae4d3a101a3e95d7360747fea07426118191f84e8f12d2b180824f179d1d6b24
3
+ metadata.gz: dab40885bc7e0251d44dd6a304b6481ecfd0769bb010ac31d52934545e2c6757
4
+ data.tar.gz: 4997a5779b19f924e737192f1b0539cc84da5ae357110af959ebf0720cfd079f
5
5
  SHA512:
6
- metadata.gz: 32fd04918e07f12a433c2f0d2628dae894fcc022646deee37629f9626571e6b1e69c12fd608d3397a974c89ee40f4d071a11420eda7dd3a42f5205a3f4e6cdf4
7
- data.tar.gz: 339e7572e1e91a7d02ba5b31daddec4388dfa607fb39b23b8d84b63d68eb9baca5b212f5935e9a4d3855ac5799466be542d30cc8fba337269597fd8dbb237194
6
+ metadata.gz: c54c706398a2f808628857c04ff03fad05107f9649acd18ff5ec879e273d93575b05e009a2a1915d7109f7d62b38582d6c314d536b4448b942872f092528950f
7
+ data.tar.gz: 50bdfa531705e422848a0207caf2dc52c36bae0464cc9a867df66b4b8723b869a3eeb33cc610ff875d7b5efecbe3bc2fc33f3978833a585a33ca138be596052d
@@ -82,13 +82,19 @@ module Spree
82
82
  end
83
83
 
84
84
  extend DisplayMoney
85
- money_methods :amount, :subtotal, :discounted_amount, :final_amount, :total, :price,
85
+ money_methods :amount, :subtotal, :discounted_amount, :final_amount, :total, :price, :discounted_price,
86
86
  :adjustment_total, :additional_tax_total, :promo_total, :included_tax_total,
87
87
  :pre_tax_amount, :shipping_cost, :tax_total, :compare_at_amount
88
88
 
89
89
  alias single_money display_price
90
90
  alias single_display_amount display_price
91
91
 
92
+ def discounted_price
93
+ return price if quantity.zero?
94
+
95
+ price - (promo_total.abs / quantity)
96
+ end
97
+
92
98
  def amount
93
99
  price * quantity
94
100
  end
@@ -403,11 +403,10 @@ module Spree
403
403
 
404
404
  def set_stock(count_on_hand, backorderable = nil, stock_location = nil)
405
405
  stock_location ||= Spree::Store.current.default_stock_location
406
- stock_items.find_or_initialize_by(stock_location: stock_location) do |stock_item|
407
- stock_item.count_on_hand = count_on_hand
408
- stock_item.backorderable = backorderable if backorderable.present?
409
- stock_item.save!
410
- end
406
+ stock_item = stock_items.find_or_initialize_by(stock_location: stock_location)
407
+ stock_item.count_on_hand = count_on_hand
408
+ stock_item.backorderable = backorderable if backorderable.present?
409
+ stock_item.save!
411
410
  end
412
411
 
413
412
  def price_modifier_amount_in(currency, options = {})
@@ -52,16 +52,26 @@ module Spree
52
52
  private
53
53
 
54
54
  def ensure_product_exists
55
- product = Spree::Product.new
56
- if attributes['slug'].present?
57
- existing_product = product_scope.find_by(slug: attributes['slug'].strip.downcase)
58
- product = existing_product if existing_product.present?
59
- end
55
+ if options.empty?
56
+ # For master variants, create or update the product
57
+ product = Spree::Product.new
58
+ if attributes['slug'].present?
59
+ existing_product = product_scope.find_by(slug: attributes['slug'].strip.downcase)
60
+ product = existing_product if existing_product.present?
61
+ end
60
62
 
61
- product = assign_attributes_to_product(product)
62
- product.save!
63
- handle_metafields(product)
64
- product
63
+ product = assign_attributes_to_product(product)
64
+ product.save!
65
+ handle_metafields(product)
66
+ product
67
+ else
68
+ # For non-master variants, only look up the product
69
+ if attributes['slug'].present?
70
+ product_scope.find_by!(slug: attributes['slug'].strip.downcase)
71
+ else
72
+ raise ActiveRecord::RecordNotFound, 'Product slug is required for variant rows'
73
+ end
74
+ end
65
75
  end
66
76
 
67
77
  def product_scope
@@ -6,11 +6,11 @@ module Spree
6
6
  def call
7
7
  if Spree.admin_user_class.present? && Spree.admin_user_class.count.zero?
8
8
  user = Spree.admin_user_class.create!(
9
- email: 'spree@example.com',
10
- password: 'spree123',
11
- password_confirmation: 'spree123',
12
- first_name: 'Spree',
13
- last_name: 'Admin'
9
+ email: ENV.fetch('ADMIN_EMAIL', 'spree@example.com'),
10
+ password: ENV.fetch('ADMIN_PASSWORD', 'spree123'),
11
+ password_confirmation: ENV.fetch('ADMIN_PASSWORD', 'spree123'),
12
+ first_name: ENV.fetch('ADMIN_FIRST_NAME', 'Spree'),
13
+ last_name: ENV.fetch('ADMIN_LAST_NAME', 'Admin')
14
14
  )
15
15
  user.save!
16
16
 
@@ -48,6 +48,30 @@ module Spree
48
48
  say "Please replace < ApplicationRecord with < Spree.base_class in #{user_class_file}"
49
49
  end
50
50
 
51
+ if Spree.admin_user_class != Spree.user_class
52
+ admin_user_class_file = Rails.root.join('app', 'models', "#{Spree.admin_user_class.name.underscore}.rb")
53
+
54
+ if File.exist?(admin_user_class_file)
55
+ inject_into_file admin_user_class_file, after: "class #{Spree.admin_user_class.name} < ApplicationRecord\n" do
56
+ <<-RUBY
57
+ # Spree modules
58
+ include Spree::UserMethods
59
+ RUBY
60
+ end
61
+ gsub_file admin_user_class_file, "< ApplicationRecord", "< Spree.base_class"
62
+
63
+ say "Successfully added Spree admin user modules into #{admin_user_class_file}"
64
+ else
65
+ say "Could not locate admin user model file at #{admin_user_class_file}. Please add these lines manually:", :red
66
+ say <<~RUBY
67
+ # Spree modules
68
+ include Spree::UserMethods
69
+ RUBY
70
+
71
+ say "Please replace < ApplicationRecord with < Spree.base_class in #{admin_user_class_file}"
72
+ end
73
+ end
74
+
51
75
  append_file 'config/initializers/spree.rb' do
52
76
  %Q{
53
77
  if defined?(Devise) && Devise.respond_to?(:parent_controller)
@@ -14,6 +14,7 @@ module Spree
14
14
  class_option :install_admin, type: :boolean, default: false, banner: 'installs default rails admin'
15
15
  class_option :auto_accept, type: :boolean
16
16
  class_option :user_class, type: :string
17
+ class_option :admin_user_class, type: :string
17
18
  class_option :admin_email, type: :string
18
19
  class_option :admin_password, type: :string
19
20
  class_option :lib_name, type: :string, default: 'spree'
@@ -69,6 +70,11 @@ module Spree
69
70
  def install_admin
70
71
  if @install_admin && Spree::Core::Engine.admin_available?
71
72
  generate 'spree:admin:install'
73
+
74
+ # generate devise controllers if authentication is devise
75
+ if @authentication == 'devise'
76
+ generate 'spree:admin:devise'
77
+ end
72
78
  end
73
79
  end
74
80
 
@@ -95,7 +101,6 @@ module Spree
95
101
  append_file 'db/seeds.rb', <<-SEEDS.strip_heredoc
96
102
 
97
103
  Spree::Core::Engine.load_seed if defined?(Spree::Core)
98
- Spree::Auth::Engine.load_seed if defined?(Spree::Auth)
99
104
  SEEDS
100
105
  end
101
106
 
@@ -133,7 +138,7 @@ module Spree
133
138
  cmd.call
134
139
  end
135
140
  else
136
- say_status :skipping, 'seed data (you can always run rake db:seed)'
141
+ say_status :skipping, 'seed data (you can always run bin/rails db:seed)'
137
142
  end
138
143
  end
139
144
 
@@ -91,5 +91,4 @@ Rails.application.config.after_initialize do
91
91
  end
92
92
 
93
93
  Spree.user_class = <%= (options[:user_class].blank? ? 'Spree::LegacyUser' : options[:user_class]).inspect %>
94
- # Use a different class for admin users
95
- # Spree.admin_user_class = 'AdminUser'
94
+ Spree.admin_user_class = <%= (options[:admin_user_class].blank? ? (options[:user_class].blank? ? 'Spree::LegacyUser' : options[:user_class]) : options[:admin_user_class]).inspect %>
@@ -1,5 +1,5 @@
1
1
  module Spree
2
- VERSION = '5.2.0.rc1'.freeze
2
+ VERSION = '5.2.0.rc2'.freeze
3
3
 
4
4
  def self.version
5
5
  VERSION
@@ -30,6 +30,7 @@ namespace :common do
30
30
  Spree::DummyGenerator.start dummy_app_args
31
31
 
32
32
  unless skip_javascript
33
+ system('bundle add sprockets-rails') # we need this until we will remove bootstrap/popper_js gems
33
34
  system('bundle exec rails importmap:install turbo:install stimulus:install')
34
35
  end
35
36
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.0.rc1
4
+ version: 5.2.0.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Schofield
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2025-11-04 00:00:00.000000000 Z
13
+ date: 2025-11-09 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: i18n-tasks
@@ -1656,9 +1656,9 @@ licenses:
1656
1656
  - BSD-3-Clause
1657
1657
  metadata:
1658
1658
  bug_tracker_uri: https://github.com/spree/spree/issues
1659
- changelog_uri: https://github.com/spree/spree/releases/tag/v5.2.0.rc1
1659
+ changelog_uri: https://github.com/spree/spree/releases/tag/v5.2.0.rc2
1660
1660
  documentation_uri: https://docs.spreecommerce.org/
1661
- source_code_uri: https://github.com/spree/spree/tree/v5.2.0.rc1
1661
+ source_code_uri: https://github.com/spree/spree/tree/v5.2.0.rc2
1662
1662
  post_install_message:
1663
1663
  rdoc_options: []
1664
1664
  require_paths: