Sha256: 24991d9ade6ec1dc6593ca28131559a333d581c5699d14bb17ca914cc81bf456

Contents?: true

Size: 1.64 KB

Versions: 3

Compression:

Stored size: 1.64 KB

Contents

require 'test_helper'

class DomainsTest < Imgix::Test

  def test_deterministically_choosing_a_path
    client = Imgix::Client.new(:hosts => [
        "demos-1.imgix.net",
        "demos-2.imgix.net",
        "demos-3.imgix.net",
      ],
      :token => '10adc394')

    path = client.path('/bridge.png')
    assert_equal 'http://demos-1.imgix.net/bridge.png?&s=13e68f249172e5f790344e85e7cdb14b', path.to_url

    path = client.path('/flower.png')
    assert_equal 'http://demos-2.imgix.net/flower.png?&s=7793669cc41d31fd21c26ede9709ef03', path.to_url
  end

  def test_cycling_choosing_domain_in_order
    client = Imgix::Client.new(:hosts => [
        "demos-1.imgix.net",
        "demos-2.imgix.net",
        "demos-3.imgix.net",
      ],
      :token => '10adc394',
      :shard_strategy => :cycle)

    path = client.path('/bridge.png')
    assert_equal 'http://demos-1.imgix.net/bridge.png?&s=13e68f249172e5f790344e85e7cdb14b', path.to_url

    path = client.path('/bridge.png')
    assert_equal 'http://demos-2.imgix.net/bridge.png?&s=13e68f249172e5f790344e85e7cdb14b', path.to_url

    path = client.path('/bridge.png')
    assert_equal 'http://demos-3.imgix.net/bridge.png?&s=13e68f249172e5f790344e85e7cdb14b', path.to_url

    path = client.path('/bridge.png')
    assert_equal 'http://demos-1.imgix.net/bridge.png?&s=13e68f249172e5f790344e85e7cdb14b', path.to_url

  end

  def test_strips_out_protocol
    client = Imgix::Client.new(:host =>
        "http://demos-1.imgix.net",
        :token => '10adc394')

    path = client.path('/bridge.png')
    assert_equal 'http://demos-1.imgix.net/bridge.png?&s=13e68f249172e5f790344e85e7cdb14b', path.to_url

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
imgix-0.3.2 test/units/domains_test.rb
imgix-0.3.1 test/units/domains_test.rb
imgix-0.3.0 test/units/domains_test.rb