Sha256: b14bc5c2faf21869d4cca604c67691b97efe8574781b40d9230e6d585dfef1a0

Contents?: true

Size: 1020 Bytes

Versions: 26

Compression:

Stored size: 1020 Bytes

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 { @product.write_metafields(
      namespace1: {
        key1: 'value1',
        key2: 2
      }
    ) }
  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 { @product.write_metafields(
      namespace1: {
        n1key1: 'value1',
        n1key2: 2
      },
      namespace2: {
        n2key3: 'value3',
        n2key4: 2
      },
    ) }
  end

end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
disco_app-0.14.3 test/models/disco_app/has_metafields_test.rb
disco_app-0.16.1 test/models/disco_app/has_metafields_test.rb
disco_app-0.15.2 test/models/disco_app/has_metafields_test.rb
disco_app-0.12.7.pre.puma.pre.3 test/models/disco_app/has_metafields_test.rb
disco_app-0.14.0 test/models/disco_app/has_metafields_test.rb
disco_app-0.13.6.pre.puma.pre.3 test/models/disco_app/has_metafields_test.rb