Sha256: 89bb06e97c091d4d7ff691e9d2dc6a408f6d139ff1d0d454e0904611a07dec02

Contents?: true

Size: 914 Bytes

Versions: 8

Compression:

Stored size: 914 Bytes

Contents

require 'test_helper'
require 'mocha'

class LimitsTest < Test::Unit::TestCase
  def setup
    ShopifyAPI::Base.site = "test.myshopify.com"
    @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
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
shopify_api-3.1.2 test/limits_test.rb
shopify_api-3.0.3 test/limits_test.rb
shopify_api-3.0.2 test/limits_test.rb
shopify_api-3.0.1 test/limits_test.rb
shopify_api-3.0.0 test/limits_test.rb
shopify_api-2.3.0 test/limits_test.rb
shopify_api-2.2.0 test/limits_test.rb
shopify_api-2.1.0 test/limits_test.rb