Sha256: 7e72ca97ad01c357488221d9067322bcdf869796bbcdd673e42c9a5ae537c846

Contents?: true

Size: 1.47 KB

Versions: 6

Compression:

Stored size: 1.47 KB

Contents

describe Spree::VariantSerializer do
  let(:image) { create :image }
  let(:variant) { create :variant, images: [image] }
  subject { ActiveModel::Serializer::Adapter::JsonApi.new(described_class.new variant) }

  its(:to_json) do
    is_expected.to be_json_eql <<-JSON
      {
        "data" : {
          "attributes" : {
            "depth" : "#{variant.depth}",
            "display_price" : "#{variant.display_price}",
            "height" : "#{variant.height}",
            "is_master" : #{variant.is_master},
            "name" : "#{variant.name}",
            "position" : #{variant.position},
            "price" : "#{variant.price}",
            "sku" : "#{variant.sku}",
            "weight" : "#{variant.weight}",
            "width" : "#{variant.width}"
          },
          "relationships" : {
            "images" : {
              "data" : [
                {
                  "type" : "spree_images"
                }
              ]
            },
            "option_values" : {
              "data" : [
                {
                  "type" : "spree_option_values"
                }
              ]
            },
            "prices" : {
              "data" : [
                {
                  "type" : "spree_prices"
                }
              ]
            },
            "product" : {
              "data" : {
                "type" : "spree_products"
              }
            }
          },
          "type" : "spree_variants"
        }
      }
    JSON
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
spree_api_v2-0.2.2 spec/serializers/spree/variant_serializer_spec.rb
solidus_api_v2-0.2.2 spec/serializers/spree/variant_serializer_spec.rb
solidus_api_v2-0.2.1 spec/serializers/spree/variant_serializer_spec.rb
spree_api_v2-0.2.1 spec/serializers/spree/variant_serializer_spec.rb
spree_api_v2-0.2.0 spec/serializers/spree/variant_serializer_spec.rb
solidus_api_v2-0.2.0 spec/serializers/spree/variant_serializer_spec.rb