fastly-rails 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@
2
2
 
3
3
  FactoryGirl.define do
4
4
  factory :book do
5
- name { Faker::Movie.title }
5
+ name 'some book name'
6
6
  service_id 'asdf'
7
7
  end
8
8
  end
@@ -65,6 +65,22 @@ describe FastlyRails::Configuration do
65
65
  end
66
66
  end
67
67
 
68
+ describe 'purging_enabled?' do
69
+ it 'is enabled by default' do
70
+ assert_equal true, configuration.purging_enabled?
71
+ end
72
+
73
+ it 'is enabled when set to true' do
74
+ configuration.purging_enabled = true
75
+ assert_equal true, configuration.purging_enabled?
76
+ end
77
+
78
+ it 'is disabled when set to false' do
79
+ configuration.purging_enabled = false
80
+ assert_equal false, configuration.purging_enabled?
81
+ end
82
+ end
83
+
68
84
  it 'should have a default value for max_age since none was provided' do
69
85
  assert_equal FastlyRails::Configuration.max_age_default, configuration.max_age
70
86
  end
@@ -5,19 +5,19 @@ describe FastlyRails do
5
5
  let(:user) { nil }
6
6
  let(:password) { nil }
7
7
  let(:max_age) { 100000 }
8
- let(:configuration) { FastlyRails.configuration }
8
+ let(:configuration) { FastlyRails::Configuration.new }
9
9
  let(:service_id) { 'someserviceid' }
10
10
  let(:client) { FastlyRails.client }
11
11
 
12
+ before do
13
+ FastlyRails.instance_variable_set('@configuration', configuration)
14
+ end
15
+
12
16
  it 'should be a module' do
13
17
  assert_kind_of Module, FastlyRails
14
18
  end
15
19
 
16
20
  describe 'credentials not provided' do
17
- before do
18
- FastlyRails.instance_variable_set('@configuration', FastlyRails::Configuration.new)
19
- end
20
-
21
21
  it 'should raise an error if configuration is not authenticatable' do
22
22
  assert_equal false, configuration.authenticatable?
23
23
  assert_equal true, configuration.invalid_service_id?
@@ -47,10 +47,33 @@ describe FastlyRails do
47
47
  assert_equal password, configuration.password
48
48
  assert_equal max_age, configuration.max_age
49
49
  assert_equal service_id, configuration.service_id
50
+ assert_equal true, configuration.purging_enabled?
50
51
  end
51
52
 
52
53
  it 'should return a valid client' do
53
54
  assert_instance_of FastlyRails::Client, client
54
55
  end
55
56
  end
57
+
58
+ describe 'purge_by_key' do
59
+ let(:client) { MiniTest::Mock.new }
60
+ let(:key) { "key" }
61
+
62
+ it 'delegates to the client when purging is enabled' do
63
+ FastlyRails.stub(:client, client) do
64
+ FastlyRails.stub(:purging_enabled?, true) do
65
+ client.expect(:purge_by_key, nil, [key])
66
+ FastlyRails.purge_by_key(key)
67
+ client.verify
68
+ end
69
+ end
70
+ end
71
+
72
+ it 'does nothing when purging is disabled' do
73
+ configuration.purging_enabled = false
74
+ FastlyRails.stub(:client, client) do
75
+ FastlyRails.purge_by_key(key)
76
+ end
77
+ end
78
+ end
56
79
  end
data/test/test_helper.rb CHANGED
@@ -64,5 +64,3 @@ class ActionDispatch::IntegrationTest
64
64
  end
65
65
 
66
66
  end
67
-
68
-
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastly-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael May
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2015-03-13 00:00:00.000000000 Z
14
+ date: 2015-05-21 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rails
@@ -195,6 +195,7 @@ files:
195
195
  - test/dummy/config/initializers/wrap_parameters.rb
196
196
  - test/dummy/config/locales/en.yml
197
197
  - test/dummy/config/routes.rb
198
+ - test/dummy/db/development.sqlite3
198
199
  - test/dummy/db/migrate/20140407202136_create_books.rb
199
200
  - test/dummy/db/migrate/20150312044151_add_service_id_to_books.rb
200
201
  - test/dummy/db/schema.rb
@@ -217,6 +218,7 @@ files:
217
218
  - test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994
218
219
  - test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6
219
220
  - test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655
221
+ - test/fastly-rails/active_record/surrogate_key_test.rb
220
222
  - test/fastly-rails/cache_control_headers_test.rb
221
223
  - test/fastly-rails/client_test.rb
222
224
  - test/fastly-rails/configuration_test.rb
@@ -241,7 +243,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
241
243
  version: '0'
242
244
  requirements: []
243
245
  rubyforge_project:
244
- rubygems_version: 2.4.4
246
+ rubygems_version: 2.2.2
245
247
  signing_key:
246
248
  specification_version: 4
247
249
  summary: Fastly instant purging integration for Rails
@@ -276,6 +278,7 @@ test_files:
276
278
  - test/dummy/config/locales/en.yml
277
279
  - test/dummy/config/routes.rb
278
280
  - test/dummy/config.ru
281
+ - test/dummy/db/development.sqlite3
279
282
  - test/dummy/db/migrate/20140407202136_create_books.rb
280
283
  - test/dummy/db/migrate/20150312044151_add_service_id_to_books.rb
281
284
  - test/dummy/db/schema.rb
@@ -300,6 +303,7 @@ test_files:
300
303
  - test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994
301
304
  - test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6
302
305
  - test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655
306
+ - test/fastly-rails/active_record/surrogate_key_test.rb
303
307
  - test/fastly-rails/cache_control_headers_test.rb
304
308
  - test/fastly-rails/client_test.rb
305
309
  - test/fastly-rails/configuration_test.rb