Sha256: cdf2999d1ffe845d2d20fe505caf5010129d7333e110ac7687d0dca7d1b4eec9

Contents?: true

Size: 976 Bytes

Versions: 12

Compression:

Stored size: 976 Bytes

Contents

require 'test_helper'

class PurgeTest < Imgix::Test
  def test_runtime_error_without_api_key
    assert_raises(RuntimeError) {
      Imgix::Client.new(host: 'demo.imgix.net', include_library_param: false)
      .purge('https://demo.imgix.net/images/demo.png')
    }
  end
  
  def test_successful_purge
    stub_request(:post, "https://api.imgix.com/v2/image/purger").
      with(
        body: {"url"=>"https://demo.imgix.net/images/demo.png"}).
      to_return(status: 200)

    Imgix::Client.new(host: 'demo.imgix.net', api_key: '10adc394')
    .purge('/images/demo.png')
    
    assert_requested :post, 'https://api.imgix.com/v2/image/purger',
      body:  'url=https%3A%2F%2Fdemo.imgix.net%2Fimages%2Fdemo.png',
      headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Basic MTBhZGMzOTQ6', 'Content-Type'=>'application/x-www-form-urlencoded', 'User-Agent'=>"imgix rb-#{ Imgix::VERSION}"},
      times: 1
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
imgix-3.3.1 test/units/purge_test.rb
imgix-3.3.0 test/units/purge_test.rb
imgix-3.2.1 test/units/purge_test.rb
imgix-3.2.0 test/units/purge_test.rb
imgix-3.1.1 test/units/purge_test.rb
imgix-3.1.0 test/units/purge_test.rb
imgix-3.0.0 test/units/purge_test.rb
imgix-2.1.0 test/units/purge_test.rb
imgix-2.0.0 test/units/purge_test.rb
imgix-1.2.2 test/units/purge_test.rb
imgix-1.2.1 test/units/purge_test.rb
imgix-1.2.0 test/units/purge_test.rb