spree_api 4.10.1 → 5.0.0.rc1
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 +4 -4
- data/app/controllers/spree/api/v2/base_controller.rb +12 -12
- data/app/controllers/spree/api/v2/storefront/checkout_controller.rb +24 -1
- data/app/helpers/spree/api/v2/store_media_serializer_images_concern.rb +3 -7
- data/app/jobs/spree/products/queue_status_changed_webhook_job.rb +12 -0
- data/app/models/spree/oauth_access_grant.rb +1 -1
- data/app/models/spree/oauth_access_token.rb +1 -1
- data/app/models/spree/oauth_application.rb +1 -1
- data/app/models/spree/order/webhooks.rb +1 -1
- data/app/models/spree/payment/webhooks.rb +1 -1
- data/app/models/spree/product/webhooks.rb +1 -1
- data/app/models/spree/shipment/webhooks.rb +1 -1
- data/app/models/spree/stock_item/webhooks.rb +1 -1
- data/app/models/spree/stock_movement/webhooks.rb +1 -1
- data/app/models/spree/variant/webhooks.rb +1 -1
- data/app/models/spree/webhooks/base.rb +1 -1
- data/app/serializers/concerns/spree/api/v2/resource_serializer_concern.rb +1 -0
- data/app/serializers/spree/api/v2/platform/payment_source_serializer.rb +12 -0
- data/app/serializers/spree/api/v2/platform/reimbursement_serializer.rb +1 -0
- data/app/serializers/spree/api/v2/platform/store_serializer.rb +0 -1
- data/app/serializers/spree/api/v2/platform/taxon_serializer.rb +8 -0
- data/app/serializers/spree/v2/storefront/cart_serializer.rb +29 -1
- data/app/serializers/spree/v2/storefront/estimated_shipping_rate_serializer.rb +7 -1
- data/app/serializers/spree/v2/storefront/payment_serializer.rb +5 -2
- data/app/serializers/spree/v2/storefront/payment_source_serializer.rb +10 -0
- data/app/serializers/spree/v2/storefront/product_serializer.rb +3 -0
- data/app/serializers/spree/v2/storefront/shipping_rate_serializer.rb +11 -1
- data/app/serializers/spree/v2/storefront/store_serializer.rb +0 -3
- data/app/serializers/spree/v2/storefront/taxon_serializer.rb +13 -1
- data/app/serializers/spree/v2/storefront/user_serializer.rb +10 -8
- data/app/services/spree/products/queue_status_changed_webhook.rb +17 -0
- data/config/routes.rb +1 -8
- data/lib/spree/api/dependencies.rb +2 -4
- data/lib/spree/api/testing_support/v2/current_order.rb +10 -5
- metadata +10 -55
- data/.gitignore +0 -17
- data/Gemfile +0 -5
- data/app/controllers/spree/api/v2/platform/cms_pages_controller.rb +0 -19
- data/app/controllers/spree/api/v2/platform/cms_sections_controller.rb +0 -29
- data/app/controllers/spree/api/v2/platform/menu_items_controller.rb +0 -21
- data/app/controllers/spree/api/v2/platform/menus_controller.rb +0 -19
- data/app/controllers/spree/api/v2/storefront/cms_pages_controller.rb +0 -41
- data/app/controllers/spree/api/v2/storefront/menus_controller.rb +0 -35
- data/app/serializers/spree/api/v2/platform/cms_page_serializer.rb +0 -13
- data/app/serializers/spree/api/v2/platform/cms_section_image_one_serializer.rb +0 -9
- data/app/serializers/spree/api/v2/platform/cms_section_image_three_serializer.rb +0 -9
- data/app/serializers/spree/api/v2/platform/cms_section_image_two_serializer.rb +0 -9
- data/app/serializers/spree/api/v2/platform/cms_section_serializer.rb +0 -18
- data/app/serializers/spree/api/v2/platform/feature_page_serializer.rb +0 -11
- data/app/serializers/spree/api/v2/platform/hero_image_serializer.rb +0 -10
- data/app/serializers/spree/api/v2/platform/homepage_serializer.rb +0 -11
- data/app/serializers/spree/api/v2/platform/icon_serializer.rb +0 -16
- data/app/serializers/spree/api/v2/platform/image_gallery_serializer.rb +0 -10
- data/app/serializers/spree/api/v2/platform/menu_item_serializer.rb +0 -45
- data/app/serializers/spree/api/v2/platform/menu_serializer.rb +0 -13
- data/app/serializers/spree/api/v2/platform/side_by_side_image_serializer.rb +0 -10
- data/app/serializers/spree/api/v2/platform/standard_page_serializer.rb +0 -11
- data/app/serializers/spree/v2/storefront/cms_page_serializer.rb +0 -14
- data/app/serializers/spree/v2/storefront/cms_section_serializer.rb +0 -32
- data/app/serializers/spree/v2/storefront/icon_serializer.rb +0 -14
- data/app/serializers/spree/v2/storefront/menu_item_serializer.rb +0 -43
- data/app/serializers/spree/v2/storefront/menu_serializer.rb +0 -13
- data/app/services/spree/api/error_handler.rb +0 -41
- data/brakeman.ignore +0 -7
- data/lib/spree/api/testing_support/caching.rb +0 -10
- data/lib/spree/api/testing_support/jobs.rb +0 -18
- data/script/rails +0 -9
- data/spec/fixtures/files/icon_256x256.jpg +0 -0
- data/spec/fixtures/thinking-cat.jpg +0 -0
- data/spree_api.gemspec +0 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb6f360d4eea998196537701255d202fa7c4fa42f581cd35d649090d144deec2
|
4
|
+
data.tar.gz: 406e748adfadf95edfca1d9864f54d8cedbb7579c902450fcd1027d732e6dd52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c331886acf8f43404f39c3ed38a707db2b3a0c6bc944c49e27ebdf071197c1a65cce0264f94c91cad650887111a4375bdf5df06c2cd53385ed186ee39eacd01
|
7
|
+
data.tar.gz: 3b02f537b9f0ee46c85c4d100736cc0bad2902030cc5d8029cadde05412e320c005fb4e9ec0890ecec8b00ccf6ec03195fc79da53d51cfea119538f62206d73f
|
@@ -2,6 +2,7 @@ module Spree
|
|
2
2
|
module Api
|
3
3
|
module V2
|
4
4
|
class BaseController < ActionController::API
|
5
|
+
include ActiveStorage::SetCurrent
|
5
6
|
include CanCan::ControllerAdditions
|
6
7
|
include Spree::Core::ControllerHelpers::StrongParameters
|
7
8
|
include Spree::Core::ControllerHelpers::Store
|
@@ -75,11 +76,12 @@ module Spree
|
|
75
76
|
|
76
77
|
def spree_current_user
|
77
78
|
return nil unless doorkeeper_token
|
78
|
-
return @spree_current_user if @spree_current_user
|
79
|
+
return @spree_current_user if defined?(@spree_current_user)
|
79
80
|
|
80
|
-
|
81
|
-
|
82
|
-
|
81
|
+
@spree_current_user ||= ActiveRecord::Base.connected_to(role: :writing) do
|
82
|
+
doorkeeper_authorize!
|
83
|
+
doorkeeper_token.resource_owner
|
84
|
+
end
|
83
85
|
end
|
84
86
|
|
85
87
|
alias try_spree_current_user spree_current_user # for compatibility with spree_legacy_frontend
|
@@ -143,13 +145,13 @@ module Spree
|
|
143
145
|
end
|
144
146
|
|
145
147
|
def record_not_found(exception)
|
146
|
-
|
148
|
+
Rails.error.report(exception, context: { user_id: spree_current_user&.id }, source: 'spree.api')
|
147
149
|
|
148
150
|
render_error_payload(I18n.t(:resource_not_found, scope: 'spree.api'), 404)
|
149
151
|
end
|
150
152
|
|
151
153
|
def access_denied(exception)
|
152
|
-
|
154
|
+
Rails.error.report(exception, context: { user_id: spree_current_user&.id }, source: 'spree.api')
|
153
155
|
|
154
156
|
render_error_payload(exception.message, 403)
|
155
157
|
end
|
@@ -159,19 +161,17 @@ module Spree
|
|
159
161
|
end
|
160
162
|
|
161
163
|
def gateway_error(exception)
|
162
|
-
|
164
|
+
Rails.error.report(exception, context: { user_id: spree_current_user&.id }, source: 'spree.api')
|
163
165
|
|
164
166
|
render_error_payload(exception.message)
|
165
167
|
end
|
166
168
|
|
167
169
|
def error_during_processing(exception)
|
168
|
-
|
170
|
+
Rails.error.report(exception, context: { user_id: spree_current_user&.id }, source: 'spree.api')
|
169
171
|
|
170
|
-
|
171
|
-
end
|
172
|
+
message = exception.respond_to?(:original_message) ? exception.original_message : exception.message
|
172
173
|
|
173
|
-
|
174
|
-
Spree::Api::Dependencies.error_handler.constantize
|
174
|
+
render_error_payload(message, 400)
|
175
175
|
end
|
176
176
|
end
|
177
177
|
end
|
@@ -17,7 +17,9 @@ module Spree
|
|
17
17
|
def advance
|
18
18
|
spree_authorize! :update, spree_current_order, order_token
|
19
19
|
|
20
|
-
|
20
|
+
check_if_quick_checkout
|
21
|
+
|
22
|
+
result = advance_service.call(order: spree_current_order, state: params[:state], shipping_method_id: params[:shipping_method_id])
|
21
23
|
|
22
24
|
render_order(result)
|
23
25
|
end
|
@@ -92,6 +94,23 @@ module Spree
|
|
92
94
|
render_serialized_payload { serialize_payment_methods(spree_current_order.available_payment_methods) }
|
93
95
|
end
|
94
96
|
|
97
|
+
def validate_order_for_payment
|
98
|
+
messages = []
|
99
|
+
|
100
|
+
if spree_current_order.present?
|
101
|
+
validated_order, messages = Spree::Cart::RemoveOutOfStockItems.call(order: spree_current_order).value
|
102
|
+
messages << Spree.t(:cart_state_changed) if !validated_order.payment? && params[:skip_state].blank?
|
103
|
+
end
|
104
|
+
|
105
|
+
if messages.any?
|
106
|
+
render_serialized_payload(422) do
|
107
|
+
serialized_current_order.deep_merge({ meta: { messages: messages } })
|
108
|
+
end
|
109
|
+
else
|
110
|
+
render_serialized_payload { serialized_current_order }
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
95
114
|
private
|
96
115
|
|
97
116
|
def resource_serializer
|
@@ -153,6 +172,10 @@ module Spree
|
|
153
172
|
include: [:shipping_rates, :stock_location, :line_items]
|
154
173
|
).serializable_hash
|
155
174
|
end
|
175
|
+
|
176
|
+
def check_if_quick_checkout
|
177
|
+
spree_current_order.ship_address&.quick_checkout = params[:quick_checkout] if params[:quick_checkout]
|
178
|
+
end
|
156
179
|
end
|
157
180
|
end
|
158
181
|
end
|
@@ -6,15 +6,11 @@ module Spree
|
|
6
6
|
|
7
7
|
included do
|
8
8
|
def self.store_image_url_for(store, attribute_name)
|
9
|
-
attachment = store.send(attribute_name)
|
10
|
-
return unless attachment
|
9
|
+
attachment = store.send(attribute_name)
|
10
|
+
return unless attachment.attached?
|
11
11
|
|
12
12
|
url_helpers = Rails.application.routes.url_helpers
|
13
|
-
|
14
|
-
url_helpers.cdn_image_url(attachment)
|
15
|
-
else
|
16
|
-
url_helpers.rails_blob_path(attachment)
|
17
|
-
end
|
13
|
+
url_helpers.cdn_image_url(attachment)
|
18
14
|
end
|
19
15
|
|
20
16
|
attribute :logo do |store|
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Spree
|
2
|
+
module Products
|
3
|
+
class QueueStatusChangedWebhookJob < Spree::BaseJob
|
4
|
+
queue_as Spree.queues.webhooks
|
5
|
+
|
6
|
+
def perform(product_id, event)
|
7
|
+
product = Spree::Product.find(product_id)
|
8
|
+
product.queue_webhooks_requests!("product.#{event}")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -21,6 +21,7 @@ module Spree
|
|
21
21
|
|
22
22
|
def self.display_getter_methods(model_klazz)
|
23
23
|
model_klazz.new.methods.find_all do |method_name|
|
24
|
+
next if method_name.to_s.start_with?('display_on')
|
24
25
|
next unless method_name.to_s.start_with?('display_')
|
25
26
|
next if method_name.to_s.end_with?('=')
|
26
27
|
next if [Spree::Product, Spree::Variant].include?(model_klazz) && method_name == :display_amount
|
@@ -7,6 +7,7 @@ module Spree
|
|
7
7
|
|
8
8
|
belongs_to :order
|
9
9
|
belongs_to :customer_return
|
10
|
+
belongs_to :performed_by, serializer: Spree::Api::V2::Platform::AdminUserSerializer
|
10
11
|
|
11
12
|
has_many :refunds
|
12
13
|
has_many :reimbursement_credits, object_method_name: :credits, id_method_name: :credit_ids
|
@@ -7,6 +7,14 @@ module Spree
|
|
7
7
|
|
8
8
|
attributes :pretty_name, :seo_title
|
9
9
|
|
10
|
+
attribute :description do |taxon|
|
11
|
+
taxon.description.to_plain_text
|
12
|
+
end
|
13
|
+
|
14
|
+
attribute :header_url do |taxon|
|
15
|
+
taxon.image.attachment&.url
|
16
|
+
end
|
17
|
+
|
10
18
|
attribute :is_root do |taxon|
|
11
19
|
taxon.root?
|
12
20
|
end
|
@@ -10,7 +10,35 @@ module Spree
|
|
10
10
|
:display_item_total, :display_ship_total, :display_adjustment_total, :display_tax_total,
|
11
11
|
:promo_total, :display_promo_total, :item_count, :special_instructions, :display_total,
|
12
12
|
:pre_tax_item_amount, :display_pre_tax_item_amount, :pre_tax_total, :display_pre_tax_total,
|
13
|
-
:shipment_state, :payment_state, :public_metadata
|
13
|
+
:shipment_state, :payment_state, :public_metadata, :total_minus_store_credits, :display_total_minus_store_credits
|
14
|
+
|
15
|
+
attribute :subtotal_cents do |cart|
|
16
|
+
cart.display_item_total.amount_in_cents
|
17
|
+
end
|
18
|
+
|
19
|
+
attribute :ship_total_cents do |cart|
|
20
|
+
cart.display_ship_total.amount_in_cents
|
21
|
+
end
|
22
|
+
|
23
|
+
attribute :store_credit_total_cents do |cart|
|
24
|
+
cart.display_total_applied_store_credit.abs.amount_in_cents
|
25
|
+
end
|
26
|
+
|
27
|
+
attribute :promo_total_cents do |cart|
|
28
|
+
cart.display_promo_total.abs.amount_in_cents
|
29
|
+
end
|
30
|
+
|
31
|
+
attribute :tax_total_cents do |cart|
|
32
|
+
cart.display_tax_total.amount_in_cents
|
33
|
+
end
|
34
|
+
|
35
|
+
attribute :total_cents do |cart|
|
36
|
+
cart.display_total.amount_in_cents
|
37
|
+
end
|
38
|
+
|
39
|
+
attribute :total_minus_store_credits_cents do |cart|
|
40
|
+
cart.display_total_minus_store_credits.amount_in_cents
|
41
|
+
end
|
14
42
|
|
15
43
|
has_many :line_items
|
16
44
|
has_many :variants
|
@@ -6,7 +6,13 @@ module Spree
|
|
6
6
|
|
7
7
|
cache_options store: nil
|
8
8
|
|
9
|
-
attributes :name, :selected, :cost, :tax_amount
|
9
|
+
attributes :name, :selected, :cost, :tax_amount
|
10
|
+
|
11
|
+
attribute :shipping_method_id do |shipping_rate|
|
12
|
+
shipping_rate.shipping_method_id.to_s
|
13
|
+
end
|
14
|
+
|
15
|
+
belongs_to :shipping_method
|
10
16
|
|
11
17
|
attribute :final_price do |shipping_rate|
|
12
18
|
shipping_rate.cost
|
@@ -7,8 +7,11 @@ module Spree
|
|
7
7
|
has_one :source, polymorphic: true
|
8
8
|
has_one :payment_method
|
9
9
|
|
10
|
-
attributes :amount, :response_code, :number, :cvv_response_code, :cvv_response_message,
|
11
|
-
|
10
|
+
attributes :amount, :response_code, :number, :cvv_response_code, :cvv_response_message, :payment_method_name, :state, :public_metadata
|
11
|
+
|
12
|
+
attribute :payment_method_id do |payment|
|
13
|
+
payment.payment_method_id.to_s
|
14
|
+
end
|
12
15
|
end
|
13
16
|
end
|
14
17
|
end
|
@@ -5,11 +5,21 @@ module Spree
|
|
5
5
|
set_type :shipping_rate
|
6
6
|
|
7
7
|
attributes :name, :selected, :final_price, :display_final_price, :cost,
|
8
|
-
:display_cost, :tax_amount, :display_tax_amount
|
8
|
+
:display_cost, :tax_amount, :display_tax_amount
|
9
|
+
|
10
|
+
attribute :shipping_method_id do |shipping_rate|
|
11
|
+
shipping_rate.shipping_method_id.to_s
|
12
|
+
end
|
13
|
+
|
14
|
+
belongs_to :shipping_method
|
9
15
|
|
10
16
|
attribute :free do |shipping_rate|
|
11
17
|
shipping_rate.free?
|
12
18
|
end
|
19
|
+
|
20
|
+
attribute :final_price_cents do |shipping_rate|
|
21
|
+
shipping_rate.display_final_price.cents
|
22
|
+
end
|
13
23
|
end
|
14
24
|
end
|
15
25
|
end
|
@@ -10,9 +10,6 @@ module Spree
|
|
10
10
|
:default, :supported_currencies, :facebook, :twitter, :instagram, :default_locale,
|
11
11
|
:customer_support_email, :description, :address, :contact_phone, :supported_locales
|
12
12
|
|
13
|
-
has_many :menus
|
14
|
-
has_many :cms_pages
|
15
|
-
|
16
13
|
has_one :default_country, serializer: :country, record_type: :country, id_method_name: :default_country_id
|
17
14
|
end
|
18
15
|
end
|
@@ -4,9 +4,21 @@ module Spree
|
|
4
4
|
class TaxonSerializer < BaseSerializer
|
5
5
|
set_type :taxon
|
6
6
|
|
7
|
-
attributes :name, :pretty_name, :permalink, :seo_title, :
|
7
|
+
attributes :name, :pretty_name, :permalink, :seo_title, :meta_title, :meta_description,
|
8
8
|
:meta_keywords, :left, :right, :position, :depth, :updated_at, :public_metadata
|
9
9
|
|
10
|
+
attribute :description do |taxon|
|
11
|
+
taxon.description.to_plain_text
|
12
|
+
end
|
13
|
+
|
14
|
+
attribute :has_products do |taxon|
|
15
|
+
taxon.active_products_with_descendants.exists?
|
16
|
+
end
|
17
|
+
|
18
|
+
attribute :header_url do |taxon|
|
19
|
+
taxon.image.attachment&.url
|
20
|
+
end
|
21
|
+
|
10
22
|
attribute :is_root do |taxon|
|
11
23
|
taxon.root?
|
12
24
|
end
|
@@ -6,6 +6,8 @@ module Spree
|
|
6
6
|
|
7
7
|
attributes :email, :first_name, :selected_locale, :last_name, :public_metadata
|
8
8
|
|
9
|
+
attribute :tags, &:tag_list
|
10
|
+
|
9
11
|
attribute :store_credits do |user|
|
10
12
|
user.total_available_store_credit
|
11
13
|
end
|
@@ -15,16 +17,16 @@ module Spree
|
|
15
17
|
end
|
16
18
|
|
17
19
|
has_one :default_billing_address,
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
id_method_name: :bill_address_id,
|
21
|
+
object_method_name: :bill_address,
|
22
|
+
record_type: :address,
|
23
|
+
serializer: :address
|
22
24
|
|
23
25
|
has_one :default_shipping_address,
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
id_method_name: :ship_address_id,
|
27
|
+
object_method_name: :ship_address,
|
28
|
+
record_type: :address,
|
29
|
+
serializer: :address
|
28
30
|
end
|
29
31
|
end
|
30
32
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Spree
|
2
|
+
module Products
|
3
|
+
class QueueStatusChangedWebhook
|
4
|
+
def self.call(ids:, event:)
|
5
|
+
return false if ids.blank? || event.blank?
|
6
|
+
|
7
|
+
# for ActiveJob 7.1+
|
8
|
+
if ActiveJob.respond_to?(:perform_all_later)
|
9
|
+
jobs = ids.map { |id| Spree::Products::QueueStatusChangedWebhookJob.new(id, event) }
|
10
|
+
ActiveJob.perform_all_later(jobs)
|
11
|
+
else
|
12
|
+
ids.each { |id| Spree::Products::QueueStatusChangedWebhookJob.perform_later(id, event) }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/config/routes.rb
CHANGED
@@ -31,6 +31,7 @@ Spree::Core::Engine.add_routes do
|
|
31
31
|
get :payment_methods
|
32
32
|
get :shipping_rates
|
33
33
|
patch :select_shipping_method
|
34
|
+
post :validate_order_for_payment
|
34
35
|
end
|
35
36
|
|
36
37
|
resource :account, controller: :account, only: %i[show create update]
|
@@ -172,14 +173,6 @@ Spree::Core::Engine.add_routes do
|
|
172
173
|
|
173
174
|
resources :roles
|
174
175
|
|
175
|
-
# Menu API
|
176
|
-
resources :menus
|
177
|
-
resources :menu_items do
|
178
|
-
member do
|
179
|
-
patch :reposition
|
180
|
-
end
|
181
|
-
end
|
182
|
-
|
183
176
|
# CMS
|
184
177
|
resources :cms_pages
|
185
178
|
resources :cms_sections
|
@@ -49,10 +49,10 @@ module Spree
|
|
49
49
|
# serializers
|
50
50
|
storefront_address_serializer: 'Spree::V2::Storefront::AddressSerializer',
|
51
51
|
storefront_cart_serializer: 'Spree::V2::Storefront::CartSerializer',
|
52
|
-
storefront_cms_page_serializer: 'Spree::V2::Storefront::CmsPageSerializer',
|
52
|
+
storefront_cms_page_serializer: 'Spree::V2::Storefront::CmsPageSerializer', # LEGACY
|
53
53
|
storefront_credit_card_serializer: 'Spree::V2::Storefront::CreditCardSerializer',
|
54
54
|
storefront_country_serializer: 'Spree::V2::Storefront::CountrySerializer',
|
55
|
-
storefront_menu_serializer: 'Spree::V2::Storefront::MenuSerializer',
|
55
|
+
storefront_menu_serializer: 'Spree::V2::Storefront::MenuSerializer', # LEGACY
|
56
56
|
storefront_user_serializer: 'Spree::V2::Storefront::UserSerializer',
|
57
57
|
storefront_shipment_serializer: 'Spree::V2::Storefront::ShipmentSerializer',
|
58
58
|
storefront_taxon_serializer: 'Spree::V2::Storefront::TaxonSerializer',
|
@@ -86,8 +86,6 @@ module Spree
|
|
86
86
|
storefront_taxon_finder: -> { Spree::Dependencies.taxon_finder },
|
87
87
|
storefront_variant_finder: -> { Spree::Dependencies.variant_finder },
|
88
88
|
|
89
|
-
error_handler: 'Spree::Api::ErrorHandler',
|
90
|
-
|
91
89
|
# serializers
|
92
90
|
platform_admin_user_serializer: 'Spree::Api::V2::Platform::AdminUserSerializer',
|
93
91
|
|
@@ -18,8 +18,10 @@ shared_context 'order with a physical line item' do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
shared_context 'order with a digital line item' do
|
21
|
-
let
|
22
|
-
let
|
21
|
+
let(:digital_shipping_method) { create(:digital_shipping_method) }
|
22
|
+
let(:digital_product) { create(:product, shipping_category: digital_shipping_method.shipping_categories.first) }
|
23
|
+
let(:variant_digital) { create(:variant, product: digital_product) }
|
24
|
+
let!(:digital) { create(:digital, variant: variant_digital) }
|
23
25
|
let!(:line_item) { create(:line_item, variant: variant_digital, order: order, currency: currency) }
|
24
26
|
let!(:headers) { headers_bearer }
|
25
27
|
|
@@ -30,8 +32,10 @@ shared_context 'order with a digital line item' do
|
|
30
32
|
end
|
31
33
|
|
32
34
|
shared_context 'order with a physical and digital line item' do
|
33
|
-
let
|
34
|
-
let
|
35
|
+
let(:digital_shipping_method) { create(:digital_shipping_method) }
|
36
|
+
let(:product_digital) { create(:product, shipping_category: digital_shipping_method.shipping_categories.first) }
|
37
|
+
let(:variant_digital) { create(:variant, product: product_digital) }
|
38
|
+
let!(:digital) { create(:digital, variant: variant_digital) }
|
35
39
|
let!(:digital_line_item) { create(:line_item, variant: variant_digital, order: order, currency: currency) }
|
36
40
|
let!(:physical_line_item) { create(:line_item, order: order, currency: currency) }
|
37
41
|
|
@@ -87,7 +91,8 @@ shared_examples 'returns valid cart JSON' do
|
|
87
91
|
expect(json_response['data']).to have_attribute(:display_pre_tax_item_amount).with_value(order.display_pre_tax_item_amount.to_s)
|
88
92
|
expect(json_response['data']).to have_attribute(:pre_tax_total).with_value(order.pre_tax_total.to_s)
|
89
93
|
expect(json_response['data']).to have_attribute(:display_pre_tax_total).with_value(order.display_pre_tax_total.to_s)
|
90
|
-
expect(json_response['data']).to have_relationships(:user, :line_items, :variants, :billing_address, :shipping_address, :payments, :shipments,
|
94
|
+
expect(json_response['data']).to have_relationships(:user, :line_items, :variants, :billing_address, :shipping_address, :payments, :shipments,
|
95
|
+
:promotions)
|
91
96
|
end
|
92
97
|
end
|
93
98
|
|