spree_api 5.0.3 → 5.1.0.beta

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: db9cbd0c57ebd6dffbc58bcdefbf769a8451acee8d5976ebc0ce9dd3ff7f85ee
4
- data.tar.gz: 924a6bcbe8042b81d1ba059378817da825d1c09360716b36dc215f1294c997ee
3
+ metadata.gz: 135a1dc5140d807b83dd4a366141eede834c6d7e3c03979c881c3a5551f750b8
4
+ data.tar.gz: fe206c574f166d016107b1d9c1c32000d5b6ff825ee35fd65233adfe9284a87d
5
5
  SHA512:
6
- metadata.gz: 2f8476d2e0808e21cbac5e549278c592073e775992fe885131e7fa7672b83d4548c9afe5d2cadb870a5b3618e52f8c1f8cc25091abd9a49d909a9d9d84e69df0
7
- data.tar.gz: 388801696f457cd843ed27b49a7b5683cb45ba7c5bbd1b312cbd619607e71401a99c177bdc39f0738f1d2b80d7a6a07626704b1283e348557b8ee5f204b38344
6
+ metadata.gz: 5d77511e3dae8752352fd0124339a8f7737ecb834266bbc136c499c8e55004c93161a0f452a81641db5fb93e684eb3c0820d31a8ede262c2c26a79e4af6fcb1e
7
+ data.tar.gz: 24c4f966a8c57d89fc29e5c757a5f831bfc89b8f8d32f054f301027fb3f0fec3bd875d6a3f00681f08d0fdddf313370c0a9a7000e64b5e7b83e688e2233fa31e
@@ -3,22 +3,28 @@ module Spree
3
3
  module V2
4
4
  module ProductListIncludes
5
5
  def product_list_includes
6
- {
7
- product_properties: [],
8
- option_types: [],
9
- variant_images: [],
10
- master: product_variant_includes,
11
- variants: product_variant_includes,
12
- translations: []
6
+ @product_list_includes ||= {
7
+ taggings: [:tag],
8
+ variants: [],
9
+ master: [:prices]
13
10
  }
11
+
12
+ @product_list_includes[:variant_images] = [] if params[:include]&.match('images')
13
+ @product_list_includes[:option_types] = [] if params[:include]&.match('option_types')
14
+ @product_list_includes[:product_properties] = [:property] if params[:include]&.match('product_properties')
15
+ @product_list_includes[:master] = variant_includes if params[:include]&.match(/master|default_variant/)
16
+ @product_list_includes[:variants] = variant_includes if params[:include]&.match(/variants|default_variant/)
17
+ @product_list_includes[:taxons] = [:taxonomy, :icon, :store, :rich_text_translations, image_attachment: :blob] if params[:include]&.match('taxons')
18
+ @product_list_includes
14
19
  end
15
20
 
16
- def product_variant_includes
17
- {
21
+ def variant_includes
22
+ variant_includes = {
18
23
  prices: [],
19
24
  option_values: :option_type,
20
- images: []
21
25
  }
26
+ variant_includes[:images] = [] if params[:include]&.match(/images/)
27
+ variant_includes
22
28
  end
23
29
  end
24
30
  end
@@ -96,7 +96,12 @@ module Spree
96
96
 
97
97
  # Needs to be overridden so that we use Spree's Ability rather than anyone else's.
98
98
  def current_ability
99
- @current_ability ||= Spree::Dependencies.ability_class.constantize.new(spree_current_user)
99
+ @current_ability ||= Spree::Dependencies.ability_class.constantize.new(spree_current_user, ability_options)
100
+ end
101
+
102
+ # this method can be extended in extensions or developer applications
103
+ def ability_options
104
+ { store: current_store }
100
105
  end
101
106
 
102
107
  def request_includes
@@ -28,7 +28,7 @@ module Spree
28
28
  def latest_event_at
29
29
  events.order(:created_at).last&.created_at
30
30
  end
31
-
31
+
32
32
  def self.with_urls_for(event)
33
33
  where(
34
34
  case ActiveRecord::Base.connection.adapter_name
@@ -43,11 +43,15 @@ module Spree
43
43
  end
44
44
 
45
45
  def self.supported_events
46
- Spree::Base.descendants.
47
- select { |model| model.included_modules.include? Spree::Webhooks::HasWebhooks }.
48
- to_h do |model|
49
- model_name = model.name.demodulize.underscore.to_sym
50
- [model_name, model.supported_webhook_events]
46
+ @supported_events ||= begin
47
+ Rails.application.eager_load! if Rails.env.development?
48
+ Spree::Base.descendants.
49
+ select { |model| model.included_modules.include? Spree::Webhooks::HasWebhooks }.
50
+ sort_by { |model| model.name.demodulize.underscore }.
51
+ to_h do |model|
52
+ model_name = model.name.demodulize.underscore.to_sym
53
+ [model_name, model.supported_webhook_events]
54
+ end
51
55
  end
52
56
  end
53
57
 
@@ -25,7 +25,7 @@ Doorkeeper.configure do
25
25
  end
26
26
 
27
27
  admin_authenticator do |routes|
28
- current_spree_user&.spree_admin? || redirect_to(routes.root_url)
28
+ current_spree_user&.spree_admin?(Spree::Store.current) || redirect_to(routes.root_url)
29
29
  end
30
30
 
31
31
  grant_flows %w[password client_credentials]
@@ -1,5 +1,5 @@
1
1
  FactoryBot.define do
2
- factory :webhook_subscriber, aliases: [:subscriber], class: Spree::Webhooks::Subscriber do
2
+ factory :webhook_subscriber, aliases: [:subscriber, :webhooks_subscriber], class: Spree::Webhooks::Subscriber do
3
3
  sequence(:url) { |n| "https://www.url#{n}.com/" }
4
4
 
5
5
  trait :active do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.3
4
+ version: 5.1.0.beta
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Bigg
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2025-05-06 00:00:00.000000000 Z
13
+ date: 2025-05-20 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: jsonapi-rspec
@@ -102,14 +102,14 @@ dependencies:
102
102
  requirements:
103
103
  - - '='
104
104
  - !ruby/object:Gem::Version
105
- version: 5.0.3
105
+ version: 5.1.0.beta
106
106
  type: :runtime
107
107
  prerelease: false
108
108
  version_requirements: !ruby/object:Gem::Requirement
109
109
  requirements:
110
110
  - - '='
111
111
  - !ruby/object:Gem::Version
112
- version: 5.0.3
112
+ version: 5.1.0.beta
113
113
  description: Spree's API
114
114
  email:
115
115
  - hello@spreecommerce.org
@@ -364,9 +364,9 @@ licenses:
364
364
  - BSD-3-Clause
365
365
  metadata:
366
366
  bug_tracker_uri: https://github.com/spree/spree/issues
367
- changelog_uri: https://github.com/spree/spree/releases/tag/v5.0.3
367
+ changelog_uri: https://github.com/spree/spree/releases/tag/v5.1.0.beta
368
368
  documentation_uri: https://docs.spreecommerce.org/
369
- source_code_uri: https://github.com/spree/spree/tree/v5.0.3
369
+ source_code_uri: https://github.com/spree/spree/tree/v5.1.0.beta
370
370
  post_install_message:
371
371
  rdoc_options: []
372
372
  require_paths: