Sha256: 89c21c5b5c5a6f97fb0d339b8328121cb40c6abf2062b4f172f235d73bc65181

Contents?: true

Size: 1.16 KB

Versions: 3

Compression:

Stored size: 1.16 KB

Contents

require 'test_helper'

class DiscoApp::HasMetafieldsTest < ActiveSupport::TestCase

  include DiscoApp::Test::ShopifyAPI

  def setup
    @product = products(:ipod)
    @shop = @product.shop
  end

  def teardown
    @product = nil
    @shop = nil
  end

  test 'can write metafields with a single namespace' do
    stub_api_request(
      :put,
      "#{@shop.admin_url}/products/#{@product.id}.json",
      'widget_store/products/write_metafields_single_namespace'
    )

    assert(
      @shop.with_api_context do
        @product.write_metafields(
          namespace1: {
            key1: 'value1',
            key2: 2
          }
        )
      end
    )
  end

  test 'can write metafields with multiple namespaces' do
    stub_api_request(
      :put,
      "#{@shop.admin_url}/products/#{@product.id}.json",
      'widget_store/products/write_metafields_multiple_namespaces'
    )

    assert(
      @shop.with_api_context do
        @product.write_metafields(
          namespace1: {
            n1key1: 'value1',
            n1key2: 2
          },
          namespace2: {
            n2key3: 'value3',
            n2key4: 2
          }
        )
      end
    )
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
disco_app-0.17.0 test/models/disco_app/has_metafields_test.rb
disco_app-0.18.0 test/models/disco_app/has_metafields_test.rb
disco_app-0.18.1 test/models/disco_app/has_metafields_test.rb