Sha256: ce3bf3cc3b006c089dff7829219a16dd9655684caf69a694e53d74a8d909ae3d

Contents?: true

Size: 1.85 KB

Versions: 26

Compression:

Stored size: 1.85 KB

Contents

require 'spec_helper'

describe S3Website::Cloudfront::Invalidator do
  let(:config) {{
    's3_id' => 'aws id',
    's3_secret' => 'aws secret',
    'cloudfront_distribution_id' => 'EFXX'
  }}

  describe 'default behaviour' do
    it 'invalidates the root resource' do
      invalidator = create_simple_cloudfront_invalidator(config)
      invalidator.
        should_receive(:invalidate).
        with(['index.html', '']).
        and_return(:text_report => 'report txt')

      S3Website::Cloudfront::Invalidator.invalidate(config, ['index.html'])
    end
  end

  context 'option cloudfront_invalidate_root = true' do
    let(:config_with_root_invalidation) {
      config.merge( {
        'cloudfront_invalidate_root' => true
      })
    }

    it 'invalidates all root resources' do
      invalidator = create_simple_cloudfront_invalidator(config_with_root_invalidation)
      invalidator.
        should_receive(:invalidate).
        with(['article/', '']).
        and_return(:text_report => 'report txt')

      S3Website::Cloudfront::Invalidator.invalidate(config_with_root_invalidation, ['article/index.html'])
    end
  end

  context 'the file name contains special characters' do
    it 'encodes the file paths according to rfc1738' do
      invalidator = create_simple_cloudfront_invalidator config
      invalidator.
        should_receive(:invalidate).
        with(['article/arnold%27s%20file.html', '']).
        and_return(:text_report => 'report txt')

      S3Website::Cloudfront::Invalidator.invalidate(config, ["article/arnold's file.html"])
    end
  end

  def create_simple_cloudfront_invalidator(config)
    invalidator = double('invalidator')
    SimpleCloudfrontInvalidator::CloudfrontClient.
      should_receive(:new).
      with(config['s3_id'], config['s3_secret'], config['cloudfront_distribution_id']).
      and_return(invalidator)
    invalidator
  end
end

Version data entries

26 entries across 26 versions & 2 rubygems

Version Path
s3_website-1.8.2 spec/lib/cloudfront/invalidator_spec.rb
s3_website-1.8.1 spec/lib/cloudfront/invalidator_spec.rb
s3_website-1.8.0 spec/lib/cloudfront/invalidator_spec.rb
s3_website_monadic-0.0.15 spec/lib/cloudfront/invalidator_spec.rb
s3_website_monadic-0.0.14 spec/lib/cloudfront/invalidator_spec.rb
s3_website_monadic-0.0.13 spec/lib/cloudfront/invalidator_spec.rb
s3_website_monadic-0.0.12 spec/lib/cloudfront/invalidator_spec.rb
s3_website_monadic-0.0.11 spec/lib/cloudfront/invalidator_spec.rb
s3_website_monadic-0.0.9 spec/lib/cloudfront/invalidator_spec.rb
s3_website_monadic-0.0.8 spec/lib/cloudfront/invalidator_spec.rb
s3_website_monadic-0.0.7 spec/lib/cloudfront/invalidator_spec.rb
s3_website_monadic-0.0.6 spec/lib/cloudfront/invalidator_spec.rb
s3_website_monadic-0.0.5 spec/lib/cloudfront/invalidator_spec.rb
s3_website-1.7.6 spec/lib/cloudfront/invalidator_spec.rb
s3_website_monadic-0.0.4 spec/lib/cloudfront/invalidator_spec.rb
s3_website_monadic-0.0.3 spec/lib/cloudfront/invalidator_spec.rb
s3_website-1.7.5 spec/lib/cloudfront/invalidator_spec.rb
s3_website_monadic-0.0.2 spec/lib/cloudfront/invalidator_spec.rb
s3_website_monadic-0.0.1 spec/lib/cloudfront/invalidator_spec.rb
s3_website-1.7.4 spec/lib/cloudfront/invalidator_spec.rb