|
1 | 1 | require 'spec_helper'
|
2 | 2 |
|
3 | 3 | describe S3Website::Cloudfront::Invalidator do
|
4 |
| - describe 'default behaviour' do |
5 |
| - let(:config) {{ |
6 |
| - 's3_id' => 'aws id', |
7 |
| - 's3_secret' => 'aws secret', |
8 |
| - 'cloudfront_distribution_id' => 'EFXX' |
9 |
| - }} |
| 4 | + let(:config) {{ |
| 5 | + 's3_id' => 'aws id', |
| 6 | + 's3_secret' => 'aws secret', |
| 7 | + 'cloudfront_distribution_id' => 'EFXX' |
| 8 | + }} |
10 | 9 |
|
| 10 | + describe 'default behaviour' do |
11 | 11 | it 'invalidates the root resource' do
|
12 | 12 | invalidator = create_simple_cloudfront_invalidator(config)
|
13 | 13 | invalidator.
|
|
19 | 19 | end
|
20 | 20 | end
|
21 | 21 |
|
22 |
| - describe 'option cloudfront_invalidate_root = true' do |
23 |
| - let(:config) {{ |
24 |
| - 's3_id' => 'aws id', |
25 |
| - 's3_secret' => 'aws secret', |
26 |
| - 'cloudfront_distribution_id' => 'EFXX', |
27 |
| - 'cloudfront_invalidate_root' => true |
28 |
| - }} |
| 22 | + context 'option cloudfront_invalidate_root = true' do |
| 23 | + let(:config_with_root_invalidation) { |
| 24 | + config.merge( { |
| 25 | + 'cloudfront_invalidate_root' => true |
| 26 | + }) |
| 27 | + } |
29 | 28 |
|
30 | 29 | it 'invalidates all root resources' do
|
31 |
| - invalidator = create_simple_cloudfront_invalidator(config) |
| 30 | + invalidator = create_simple_cloudfront_invalidator(config_with_root_invalidation) |
32 | 31 | invalidator.
|
33 | 32 | should_receive(:invalidate).
|
34 | 33 | with(['article/', '']).
|
35 | 34 | and_return(:text_report => 'report txt')
|
36 | 35 |
|
37 |
| - S3Website::Cloudfront::Invalidator.invalidate(config, ['article/index.html']) |
| 36 | + S3Website::Cloudfront::Invalidator.invalidate(config_with_root_invalidation, ['article/index.html']) |
| 37 | + end |
| 38 | + end |
| 39 | + |
| 40 | + context 'the file name contains special characters' do |
| 41 | + it 'encodes the file paths according to rfc1738' do |
| 42 | + invalidator = create_simple_cloudfront_invalidator config |
| 43 | + invalidator. |
| 44 | + should_receive(:invalidate). |
| 45 | + with(['article/arnold%27s%20file.html', '']). |
| 46 | + and_return(:text_report => 'report txt') |
| 47 | + |
| 48 | + S3Website::Cloudfront::Invalidator.invalidate(config, ["article/arnold's file.html"]) |
38 | 49 | end
|
39 | 50 | end
|
40 | 51 |
|
|
0 commit comments