spree_core 5.3.0.rc2 → 5.3.1

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: 4241192c0b403bb14c71969625a754c8697e3f2cdc643e2095ad87a013b11b8b
4
- data.tar.gz: 2c747e6ad0a508d22442d959c8617b7bed0fd215b2606c4f889c6bba04c87507
3
+ metadata.gz: 955b622bdd29054fb4bdb3e336a4a72e36c03f20e54cec6704aed0ed00407f17
4
+ data.tar.gz: 2b0d4168fa45ce1814d16b42c54241b1b63034a586281bccd5fb6297f1634aac
5
5
  SHA512:
6
- metadata.gz: 805d79f3e0e69417cd88b7304aabf4ac9b9a3df5ff04a3738c500ed6711b0ce8f3f5b1007e0ac7a90a865ec218e9ffc52d238c0ad79884316f04eba4f967cdeb
7
- data.tar.gz: 250588209094b5acf8215c85c4616880794d38d01644c011c4bee3349df39f0a3b48826918f710715dc464dff06b03c827bd28efd687303038cee2bc4ec28e21
6
+ metadata.gz: 68f6b6296a2d489c54009a8d52586e268d01c7894785c6cf1d5d0d428a6e8fa2365b8b29296bbc4a4452004efedea81c397d73ceb3047f6e9d9e9370af41fc7e
7
+ data.tar.gz: 6ec77c2ecee5028ee57e03664dfb2fec39794867e04659fb0fcb1d7042287a8b912705f1c20674a9be68c00c0050a54d6cc3e05bc73b36f9112b1c2bfb931619
data/README.md ADDED
@@ -0,0 +1,116 @@
1
+ # Spree Core
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/spree_core.svg)](https://badge.fury.io/rb/spree_core)
4
+
5
+ Spree Core is the foundation of Spree Commerce, containing all the essential models, services, and business logic that power an e-commerce application.
6
+
7
+ ## Overview
8
+
9
+ This gem provides:
10
+
11
+ - **Domain Models** - Products, Variants, Orders, Payments, Shipments, Taxons, Stores, and more
12
+ - **Services** - Cart operations, checkout flows, order management, inventory handling
13
+ - **State Machines** - Order and payment state management
14
+ - **Events System** - Publish/subscribe architecture for loose coupling
15
+ - **Dependencies Injection** - Swappable service implementations via `Spree::Dependencies`
16
+ - **Permissions** - CanCanCan-based authorization with Permission Sets
17
+
18
+ ## Installation
19
+
20
+ This gem is included in every Spree installation. No additional steps are required.
21
+
22
+ ## Key Components
23
+
24
+ ### Models
25
+
26
+ All models are namespaced under `Spree::` and include:
27
+
28
+ - `Spree::Product` / `Spree::Variant` - Product catalog
29
+ - `Spree::Order` / `Spree::LineItem` - Order management
30
+ - `Spree::Payment` / `Spree::PaymentMethod` - Payment processing
31
+ - `Spree::Shipment` / `Spree::ShippingMethod` - Shipping and fulfillment
32
+ - `Spree::Taxon` / `Spree::Taxonomy` - Product categorization
33
+ - `Spree::Store` - Multi-store support
34
+ - `Spree::Promotion` - Promotions and discounts
35
+ - `Spree::GiftCard` - Gift card functionality
36
+
37
+ ### Services
38
+
39
+ Services follow a consistent interface pattern and are located in `app/services/spree/`:
40
+
41
+ ```ruby
42
+ # Add item to cart
43
+ Spree.cart_add_item_service.call(
44
+ order: order,
45
+ variant: variant,
46
+ quantity: 1
47
+ )
48
+ ```
49
+
50
+ ### Events System
51
+
52
+ Spree uses an event-driven architecture for decoupling components:
53
+
54
+ ```ruby
55
+ # Publishing events
56
+ order.publish_event('order.completed')
57
+
58
+ # Subscribing to events
59
+ module Spree
60
+ module MySubscriber
61
+ include Spree::Event::Subscriber
62
+
63
+ event_action :order_completed
64
+
65
+ def order_completed(event)
66
+ order = event.payload[:order]
67
+ # Handle the event
68
+ end
69
+ end
70
+ end
71
+ ```
72
+
73
+ ### Dependencies
74
+
75
+ Swap out default implementations with custom services:
76
+
77
+ ```ruby
78
+ # config/initializers/spree.rb
79
+ Spree::Dependencies.cart_add_item_service = 'MyCustom::CartAddItem'
80
+ ```
81
+
82
+ ## Configuration
83
+
84
+ Configure Spree in an initializer:
85
+
86
+ ```ruby
87
+ # config/initializers/spree.rb
88
+ Spree.config do |config|
89
+ config.currency = 'USD'
90
+ config.default_country_iso = 'US'
91
+ end
92
+ ```
93
+
94
+ ## Testing
95
+
96
+ Spree Core includes testing support utilities:
97
+
98
+ ```ruby
99
+ # spec/rails_helper.rb
100
+ require 'spree/testing_support/factories'
101
+ require 'spree/testing_support/authorization_helpers'
102
+ ```
103
+
104
+ To run the test suite:
105
+
106
+ ```bash
107
+ cd core
108
+ bundle exec rake test_app # First time only
109
+ bundle exec rspec
110
+ ```
111
+
112
+ ## Documentation
113
+
114
+ - [Official Documentation](https://docs.spreecommerce.org)
115
+ - [API Reference](https://api.spreecommerce.org)
116
+ - [Guides](https://docs.spreecommerce.org/developer)
@@ -367,6 +367,14 @@ module Spree
367
367
  variant_for_images&.primary_image
368
368
  end
369
369
 
370
+ # Backward compatibility for Spree 5.2 and earlier.
371
+ # @deprecated Use Spree::Product#default_image instead.
372
+ def featured_image
373
+ Spree::Deprecation.warn('Spree::Product#featured_image is deprecated and will be removed in Spree 5.5. Please use Spree::Product#default_image instead.')
374
+
375
+ default_image
376
+ end
377
+
370
378
  # Returns secondary Image for Product (for hover effects).
371
379
  # @return [Spree::Image, nil]
372
380
  def secondary_image
@@ -10,6 +10,7 @@ module Spree
10
10
  return failure(nil, error: 'No image link') if get_image_link(input[:variant], input[:product]).nil?
11
11
 
12
12
  information['id'] = input[:variant].id
13
+ information['item_group_id'] = input[:product].id
13
14
  information['title'] = format_title(input[:product], input[:variant])
14
15
  information['description'] = get_description(input[:product], input[:variant])
15
16
  information['link'] = "#{input[:store].url}/products/#{input[:product].slug}"
@@ -56,7 +57,7 @@ module Spree
56
57
  end
57
58
 
58
59
  def get_availability(product)
59
- return 'in stock' if product.available? && product.available_on&.past?
60
+ return 'in stock' if product.available? && (product.available_on.nil? || product.available_on.past?)
60
61
  return 'backorder' if product.backorderable? && product.backordered? && product.available_on&.future?
61
62
 
62
63
  'out of stock'
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  # Applies a gift card to an order
3
4
  # under the hood it creates a store credit payment record and updates the gift card amount used
4
5
  # @param gift_card [Spree::GiftCard] the gift card to apply
@@ -16,6 +17,14 @@ module Spree
16
17
  # we shouldn't allow a gift card to be applied to an order with a different currency
17
18
  return failure(:gift_card_mismatched_currency) if gift_card.currency != order.currency
18
19
 
20
+ # gift card requires logged user
21
+ if gift_card.user.present?
22
+ # user must be logged in
23
+ return failure(:gift_card_customer_not_logged_in) if order.user.blank?
24
+ # user must be the same as the gift card user
25
+ return failure(:gift_card_mismatched_customer) if gift_card.user != order.user
26
+ end
27
+
19
28
  amount = [gift_card.amount_remaining, order.total].min
20
29
  store = order.store
21
30
 
@@ -1190,7 +1190,10 @@ en:
1190
1190
  gift_card_already_redeemed: The Gift Card has already been redeemed.
1191
1191
  gift_card_applied: The Gift Card was successfully applied to your order!
1192
1192
  gift_card_batch: Gift Card Batch
1193
+ gift_card_customer_not_logged_in: Gift Card cannot be applied with guest user.
1193
1194
  gift_card_expired: The Gift Card has expired.
1195
+ gift_card_mismatched_currency: Gift Card cannot be applied with current currency.
1196
+ gift_card_mismatched_customer: This gift card is associated with another user.
1194
1197
  gift_card_removed: The Gift Card was successfully removed from your order
1195
1198
  gift_card_using_store_credit_error: You can't apply the Gift Card after you applied the store credit.
1196
1199
  gift_cards: Gift Cards
@@ -1,5 +1,5 @@
1
1
  module Spree
2
- VERSION = '5.3.0.rc2'.freeze
2
+ VERSION = '5.3.1'.freeze
3
3
 
4
4
  def self.version
5
5
  VERSION
@@ -20,8 +20,7 @@ namespace :common do
20
20
  javascript_enabled = args[:javascript].to_b
21
21
  css_enabled = args[:css].to_b
22
22
 
23
- # Admin and Storefront require JavaScript and CSS (Tailwind) to function properly
24
- javascript_enabled ||= install_admin || install_storefront
23
+ # Admin and Storefront require CSS (Tailwind) to function properly
25
24
  css_enabled ||= install_admin || install_storefront
26
25
 
27
26
  puts args
@@ -32,9 +31,6 @@ namespace :common do
32
31
  dummy_app_args = [
33
32
  "--lib_name=#{ENV['LIB_NAME']}"
34
33
  ]
35
- # Use API mode only if no frontend components are needed
36
- use_api_mode = !install_storefront && !install_admin && !javascript_enabled && !css_enabled
37
- dummy_app_args << '--api' if use_api_mode
38
34
  dummy_app_args << '--javascript' if javascript_enabled
39
35
  dummy_app_args << '--css=tailwind' if css_enabled
40
36
 
@@ -58,8 +54,17 @@ namespace :common do
58
54
  end
59
55
 
60
56
  # Run core Spree install generator
57
+ # The spree:install generator lives in the root spree gem. Core gems (spree_core, spree_api)
58
+ # don't have spree as a dependency, so we need to use the root Gemfile to access the generator.
59
+ # Other gems (admin, storefront, etc.) already have spree in their Gemfile.
60
+ core_gems = %w[spree/core spree/api]
61
+ root_gemfile = File.expand_path('../../../../Gemfile', __dir__)
62
+ use_root_gemfile = core_gems.include?(ENV['LIB_NAME']) &&
63
+ File.exist?(root_gemfile) &&
64
+ File.exist?(File.expand_path('../../../../spree.gemspec', __dir__))
65
+ bundle_exec = use_root_gemfile ? "bundle exec --gemfile=#{root_gemfile}" : 'bundle exec'
61
66
  puts 'Running Spree install generator...'
62
- system("bundle exec rails g spree:install --force --auto-accept --migrate=false --seed=false --sample=false --user_class=#{args[:user_class]} --admin_user_class=#{args[:admin_user_class]} --authentication=#{args[:authentication]}")
67
+ system("#{bundle_exec} rails g spree:install --force --auto-accept --migrate=false --seed=false --sample=false --user_class=#{args[:user_class]} --admin_user_class=#{args[:admin_user_class]} --authentication=#{args[:authentication]}")
63
68
 
64
69
  # Determine if we need to install admin/storefront
65
70
  # Either via explicit flag or because we're testing that gem itself
@@ -4,6 +4,6 @@ desc 'Generates a dummy app for testing an extension'
4
4
  namespace :extension do
5
5
  task :test_app, [:authentication, :user_class] do |_t, args|
6
6
  Spree::DummyGeneratorHelper.inject_extension_requirements = true
7
- Rake::Task['common:test_app'].execute(args.with_defaults(install_admin: true, install_storefront: true))
7
+ Rake::Task['common:test_app'].execute(args)
8
8
  end
9
9
  end
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.3.0.rc2
4
+ version: 5.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Schofield
@@ -107,6 +107,20 @@ dependencies:
107
107
  - - ">="
108
108
  - !ruby/object:Gem::Version
109
109
  version: 3.3.1
110
+ - !ruby/object:Gem::Dependency
111
+ name: benchmark
112
+ requirement: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ type: :runtime
118
+ prerelease: false
119
+ version_requirements: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
110
124
  - !ruby/object:Gem::Dependency
111
125
  name: carmen
112
126
  requirement: !ruby/object:Gem::Requirement
@@ -566,6 +580,7 @@ extensions: []
566
580
  extra_rdoc_files: []
567
581
  files:
568
582
  - LICENSE.md
583
+ - README.md
569
584
  - Rakefile
570
585
  - app/assets/config/spree_core_manifest.js
571
586
  - app/assets/images/google_on_white_hdpi.png
@@ -1702,9 +1717,9 @@ licenses:
1702
1717
  - BSD-3-Clause
1703
1718
  metadata:
1704
1719
  bug_tracker_uri: https://github.com/spree/spree/issues
1705
- changelog_uri: https://github.com/spree/spree/releases/tag/v5.3.0.rc2
1720
+ changelog_uri: https://github.com/spree/spree/releases/tag/v5.3.1
1706
1721
  documentation_uri: https://docs.spreecommerce.org/
1707
- source_code_uri: https://github.com/spree/spree/tree/v5.3.0.rc2
1722
+ source_code_uri: https://github.com/spree/spree/tree/v5.3.1
1708
1723
  rdoc_options: []
1709
1724
  require_paths:
1710
1725
  - lib
@@ -1719,7 +1734,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1719
1734
  - !ruby/object:Gem::Version
1720
1735
  version: 1.8.23
1721
1736
  requirements: []
1722
- rubygems_version: 4.0.2
1737
+ rubygems_version: 4.0.3
1723
1738
  specification_version: 4
1724
1739
  summary: The bare bones necessary for Spree
1725
1740
  test_files: []