Sha256: 60119ec62f2900effcdd17e4114fec8fabae2c113637a819674a1ebb2fc14c1c

Contents?: true

Size: 1.09 KB

Versions: 24

Compression:

Stored size: 1.09 KB

Contents

require 'test_helper'

class LimitsTest < Test::Unit::TestCase
  def setup
    super
    @header_hash = {'http_x_shopify_shop_api_call_limit' => '100/300'}
    ShopifyAPI::Base.connection.expects(:response).at_least(0).returns(@header_hash)
  end

  context "Limits" do
    should "fetch limit total" do
      assert_equal(299, ShopifyAPI.credit_limit(:shop))
    end

    should "fetch used calls" do
      assert_equal(100, ShopifyAPI.credit_used(:shop))
    end

    should "calculate remaining calls" do
      assert_equal(199, ShopifyAPI.credit_left)
    end

    should "flag maxed out credits" do
      assert !ShopifyAPI.maxed?
      @header_hash = {'http_x_shopify_shop_api_call_limit' => '299/300'}
      ShopifyAPI::Base.connection.expects(:response).at_least(1).returns(@header_hash)
      assert ShopifyAPI.maxed?
    end

    should "raise error when header doesn't exist" do
      @header_hash = {}
      ShopifyAPI::Base.connection.expects(:response).at_least(1).returns(@header_hash)
      assert_raises ShopifyAPI::Limits::LimitUnavailable do
        ShopifyAPI.credit_left
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
shopify_api-6.0.0 test/limits_test.rb
shopify_api-5.2.4 test/limits_test.rb
shopify_api-5.2.3 test/limits_test.rb
shopify_api-5.2.2 test/limits_test.rb
shopify_api-5.2.1 test/limits_test.rb
shopify_api-5.2.0 test/limits_test.rb
shopify_api-5.1.0 test/limits_test.rb
shopify_api-5.0.0 test/limits_test.rb
shopify_api-4.13.0 test/limits_test.rb
shopify_api-4.12.0 test/limits_test.rb
shopify_api-4.11.0 test/limits_test.rb
shopify_api-4.10.0 test/limits_test.rb
shopify_api-4.9.1 test/limits_test.rb
shopify_api-4.9.0 test/limits_test.rb
shopify_api-4.8.0 test/limits_test.rb
shopify_api-4.7.1 test/limits_test.rb
shopify_api-4.7.0 test/limits_test.rb
shopify_api-4.6.0 test/limits_test.rb
shopify_api-4.5.0 test/limits_test.rb
shopify_api-4.4.0 test/limits_test.rb