Sha256: ece1f2cacc9792905a7ea504df652ee7a9949a40302fb94812edad74030d878c

Contents?: true

Size: 996 Bytes

Versions: 10

Compression:

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

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
disco_app-0.9.10 test/models/disco_app/has_metafields_test.rb
disco_app-0.9.11 test/models/disco_app/has_metafields_test.rb
disco_app-0.10.0 test/models/disco_app/has_metafields_test.rb
disco_app-0.10.1 test/models/disco_app/has_metafields_test.rb
disco_app-0.10.2 test/models/disco_app/has_metafields_test.rb
disco_app-0.10.3 test/models/disco_app/has_metafields_test.rb
disco_app-0.10.4 test/models/disco_app/has_metafields_test.rb
disco_app-0.10.5 test/models/disco_app/has_metafields_test.rb
disco_app-0.11.0 test/models/disco_app/has_metafields_test.rb
disco_app-0.11.1 test/models/disco_app/has_metafields_test.rb