Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Add ProductSerializer example when no store in params.
Sebastian Palma91521a7d553e
diff --git a/api/app/models/spree/webhooks/endpoint.rb b/api/app/models/spree/webhooks/endpoint.rbindex c4db46a9c9..36070e1fc4 100644--- a/api/app/models/spree/webhooks/endpoint.rb+++ b/api/app/models/spree/webhooks/endpoint.rb@@ -1,7 +1,7 @@module Spreemodule Webhooksclass Endpoint < Spree::Webhooks::Base- validates :url, 'spree/url': true+ validates :url, 'spree/url': true, presence: trueendendenddiff --git a/api/spec/serializers/spree/api/v2/platform/product_serializer_spec.rb b/api/spec/serializers/spree/api/v2/platform/product_serializer_spec.rbindex dd723e14d1..6c5e451e45 100644--- a/api/spec/serializers/spree/api/v2/platform/product_serializer_spec.rb+++ b/api/spec/serializers/spree/api/v2/platform/product_serializer_spec.rb@@ -17,120 +17,129 @@ describe Spree::Api::V2::Platform::ProductSerializer dotaxons: create_list(:taxon, 2),tax_category: create(:tax_category))end-- it { expect(subject.serializable_hash).to be_kind_of(Hash) }-- it do- expect(subject.serializable_hash).to eq(- {- data: {- id: product.id.to_s,- type: :product,- attributes: {- name: product.name,- description: product.description,- available_on: product.available_on,- deleted_at: product.deleted_at,- slug: product.slug,- meta_description: product.meta_description,- meta_keywords: product.meta_keywords,- created_at: product.created_at,- updated_at: product.updated_at,- promotionable: product.promotionable,- meta_title: product.meta_title,- discontinue_on: product.discontinue_on,- purchasable: product.purchasable?,- in_stock: product.in_stock?,- backorderable: product.backorderable?,- available: product.available?,- currency: currency,- price: BigDecimal(10),- display_price: '$10.00',- compare_at_price: BigDecimal(15),- display_compare_at_price: '$15.00'+ let(:serializable_hash) do+ {+ data: {+ id: product.id.to_s,+ type: :product,+ attributes: {+ name: product.name,+ description: product.description,+ available_on: product.available_on,+ deleted_at: product.deleted_at,+ slug: product.slug,+ meta_description: product.meta_description,+ meta_keywords: product.meta_keywords,+ created_at: product.created_at,+ updated_at: product.updated_at,+ promotionable: product.promotionable,+ meta_title: product.meta_title,+ discontinue_on: product.discontinue_on,+ purchasable: product.purchasable?,+ in_stock: product.in_stock?,+ backorderable: product.backorderable?,+ available: product.available?,+ currency: currency,+ price: BigDecimal(10),+ display_price: '$10.00',+ compare_at_price: BigDecimal(15),+ display_compare_at_price: '$15.00'+ },+ relationships: {+ tax_category: {+ data: {+ id: product.tax_category.id.to_s,+ type: :tax_category+ }},- relationships: {- tax_category: {- data: {- id: product.tax_category.id.to_s,- type: :tax_category- }- },- primary_variant: {- data: {- id: product.master.id.to_s,+ primary_variant: {+ data: {+ id: product.master.id.to_s,+ type: :variant+ }+ },+ default_variant: {+ data: {+ id: product.default_variant.id.to_s,+ type: :variant+ }+ },+ variants: {+ data: [+ {+ id: product.variants.first.id.to_s,type: :variant- }- },- default_variant: {- data: {- id: product.default_variant.id.to_s,+ },+ {+ id: product.variants.second.id.to_s,type: :variant}- },- variants: {- data: [- {- id: product.variants.first.id.to_s,- type: :variant- },- {- id: product.variants.second.id.to_s,- type: :variant- }- ]- },- option_types: {- data: [- {- id: product.option_types.first.id.to_s,- type: :option_type- },- {- id: product.option_types.second.id.to_s,- type: :option_type- }- ]- },- product_properties: {- data: [- {- id: product.product_properties.first.id.to_s,- type: :product_property- },- {- id: product.product_properties.second.id.to_s,- type: :product_property- }- ]- },- taxons: {- data: [- {- id: product.taxons.first.id.to_s,- type: :taxon- },- {- id: product.taxons.second.id.to_s,- type: :taxon- }- ]- },- images: {- data: [- {- id: product.variant_images.first.id.to_s,- type: :image- },- {- id: product.variant_images.second.id.to_s,- type: :image- }- ]- },- }+ ]+ },+ option_types: {+ data: [+ {+ id: product.option_types.first.id.to_s,+ type: :option_type+ },+ {+ id: product.option_types.second.id.to_s,+ type: :option_type+ }+ ]+ },+ product_properties: {+ data: [+ {+ id: product.product_properties.first.id.to_s,+ type: :product_property+ },+ {+ id: product.product_properties.second.id.to_s,+ type: :product_property+ }+ ]+ },+ taxons: {+ data: [+ {+ id: product.taxons.first.id.to_s,+ type: :taxon+ },+ {+ id: product.taxons.second.id.to_s,+ type: :taxon+ }+ ]+ },+ images: {+ data: [+ {+ id: product.variant_images.first.id.to_s,+ type: :image+ },+ {+ id: product.variant_images.second.id.to_s,+ type: :image+ }+ ]+ },}}- )+ }+ end++ context 'without a store in the params' do+ subject { described_class.new(product, params: serializer_params.merge(store: nil)) }++ it 'returns all the product taxons' do+ expect(subject.serializable_hash).to eq(serializable_hash)+ end+ end++ it { expect(subject.serializable_hash).to be_kind_of(Hash) }++ it do+ expect(subject.serializable_hash).to eq(serializable_hash)endend