Sha256: a01f30b72a9a2484455df50535d21582a58e69de212bbe14a6c138c62b041c36

Contents?: true

Size: 1.45 KB

Versions: 20

Compression:

Stored size: 1.45 KB

Contents

require 'test_helper'

class ShopTest < Test::Unit::TestCase
  def setup
    super
    fake "shop"
    @shop = ShopifyAPI::Shop.current
  end

  def test_current_should_return_current_shop
    assert @shop.is_a?(ShopifyAPI::Shop)
    assert_equal "Apple Computers", @shop.name
    assert_equal "apple.myshopify.com", @shop.myshopify_domain
    assert_equal 690933842, @shop.id
    assert_equal "2007-12-31T19:00:00-05:00", @shop.created_at
    assert_nil @shop.tax_shipping
  end

  def test_get_metafields_for_shop
    fake "metafields"

    metafields = @shop.metafields

    assert_equal 2, metafields.length
    assert metafields.all?{|m| m.is_a?(ShopifyAPI::Metafield)}
  end

  def test_add_metafield
    fake "metafields", :method => :post, :status => 201, :body =>load_fixture('metafield')

    field = @shop.add_metafield(ShopifyAPI::Metafield.new(:namespace => "contact", :key => "email", :value => "123@example.com", :value_type => "string"))
    assert_equal ActiveSupport::JSON.decode('{"metafield":{"namespace":"contact","key":"email","value":"123@example.com","value_type":"string"}}'), ActiveSupport::JSON.decode(FakeWeb.last_request.body)
    assert !field.new_record?
    assert_equal "contact", field.namespace
    assert_equal "email", field.key
    assert_equal "123@example.com", field.value
  end

  def test_events
    fake "events"

    events = @shop.events

    assert_equal 3, events.length
    assert events.all?{|m| m.is_a?(ShopifyAPI::Event)}
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
shopify_api-4.0.0 test/shop_test.rb
shopify_api-3.2.7 test/shop_test.rb
shopify_api-3.2.6 test/shop_test.rb
shopify_api-3.2.5 test/shop_test.rb
shopify_api-3.2.4 test/shop_test.rb
shopify_api-3.2.3 test/shop_test.rb
shopify_api-3.2.2 test/shop_test.rb
shopify_api-3.2.1 test/shop_test.rb
shopify_api-3.2.0 test/shop_test.rb
shopify_api-3.1.8 test/shop_test.rb
shopify_api-3.1.7 test/shop_test.rb
shopify_api-3.1.6 test/shop_test.rb
shopify_api-3.1.5 test/shop_test.rb
shopify_api-3.1.3 test/shop_test.rb
shopify_api-3.1.2 test/shop_test.rb
shopify_api-3.0.3 test/shop_test.rb
shopify_api-3.0.2 test/shop_test.rb
shopify_api-3.0.1 test/shop_test.rb
shopify_api-3.0.0 test/shop_test.rb
shopify_api-2.3.0 test/shop_test.rb