Sha256: daa0ee9a46bd9745740d2feb3ffabe59f9dce215e3d4a786432543527390c231

Contents?: true

Size: 1.49 KB

Versions: 2

Compression:

Stored size: 1.49 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.to_json},
            "display_price" : "#{variant.display_price}",
            "height" : #{variant.height.to_json},
            "is_master" : #{variant.is_master},
            "name" : "#{variant.name}",
            "position" : #{variant.position},
            "price" : "#{variant.price}",
            "sku" : "#{variant.sku}",
            "weight" : "#{variant.weight}",
            "width" : #{variant.width.to_json}
          },
          "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

2 entries across 2 versions & 1 rubygems

Version Path
solidus_json_api-0.3.1 spec/serializers/spree/variant_serializer_spec.rb
solidus_json_api-0.3.0 spec/serializers/spree/variant_serializer_spec.rb