feature_gate 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5acf4b8ccc7c52181ba7d59a41ed67c21b8c1123
4
- data.tar.gz: 1c1273f7c50647fa35c95702ddc56ac2bf4b8359
3
+ metadata.gz: 715612c103f17635e52891cbf81f7514d21e9c3f
4
+ data.tar.gz: 25dcc5c8bc92d866ef9f9b2cdcacfdd32f8fbf8a
5
5
  SHA512:
6
- metadata.gz: f230f201f92df9305beb7aa35ddb60ad67ad3f31987b6e032efcd344b7db98c4972fbcf7522ea113d5d779c032aba09f50b8bac19c698e3ab70f627946e0ce86
7
- data.tar.gz: 14706e4d0a5b3dae0eb425f5acc09ea5630bd510589e88fe49dc15dfaa5271eafe6f16115d12b34741c2b62c14b4741d0ee1f6c52d1eb85148baf9734116628e
6
+ metadata.gz: aebdd3dd94eee36f00cfc5df08a0410e728fea4428934c31ae20134a6f58f04ddf3e99b8c38b32d4ce435886a3ee4fea1aa451b586a0ac9fce26a2c63ba95895
7
+ data.tar.gz: 6f3451d1209a5750f4e75300563fd8e2799f553ff4cce647dd0e84e9fcde1ecc20ec3f7ef0b2d2c39621618a69d78d94da59e8dfb391d9be04b5792a5b5c3d33
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- feature_gate (0.1.8)
4
+ feature_gate (0.2.2)
5
5
  rails (~> 4.0)
6
6
 
7
7
  GEM
@@ -1,3 +1,3 @@
1
1
  module FeatureGate
2
- VERSION = '0.2.2'.freeze
2
+ VERSION = '0.2.3'.freeze
3
3
  end
data/lib/feature_gate.rb CHANGED
@@ -1,8 +1,6 @@
1
1
  module FeatureGate
2
- class << self
3
- mattr_accessor :time_to_stale
4
- self.time_to_stale = 1.month
5
- end
2
+ mattr_accessor :time_to_stale
3
+ self.time_to_stale = 1.month
6
4
 
7
5
  def self.setup
8
6
  yield self
@@ -16,4 +16,26 @@ describe FeatureGate::GatedFeaturesController do
16
16
  expect(gate.reload).not_to be_gated
17
17
  end
18
18
  end
19
+
20
+ describe '#destroy' do
21
+ let!(:gate){ create(:gated_feature) }
22
+
23
+ before do
24
+ allow(FeatureGate::GatedFeature).to receive(:find).and_return(gate)
25
+ end
26
+
27
+ it 'destroys the gate if it is destroyable' do
28
+ allow(gate).to receive(:destroyable?).and_return true
29
+ expect do
30
+ delete :destroy, id: gate.id
31
+ end.to change{ FeatureGate::GatedFeature.count }.by(-1)
32
+ end
33
+
34
+ it 'does not destory the gate if it is not destroyable' do
35
+ allow(gate).to receive(:destroyable?).and_return false
36
+ expect do
37
+ delete :destroy, id: gate.id
38
+ end.not_to change{ FeatureGate::GatedFeature.count }
39
+ end
40
+ end
19
41
  end
@@ -0,0 +1,61 @@
1
+ require 'spec_helper'
2
+
3
+ describe FeatureGate::GatedFeature do
4
+ let!(:gate) { create(:gated_feature) }
5
+
6
+ describe '#destroyable?' do
7
+ it 'returns true if files do not contain any feature gate references' do
8
+ text = <<-TEXT
9
+ <div>
10
+ <% FeatureGate::Manager.gate('test') do %>
11
+ foo
12
+ <% end %>
13
+ </div>
14
+
15
+ def index
16
+ FeatureGate::Manager.gate_page('test')
17
+ end
18
+ TEXT
19
+
20
+ fake_file = double(read: text)
21
+ allow(File).to receive(:new).and_return(fake_file)
22
+ expect(gate).to be_destroyable
23
+ end
24
+
25
+ it 'returns false if files contain feature gate gating a page' do
26
+ text = <<-TEXT
27
+ <div>
28
+ <% FeatureGate::Manager.gate('#{gate.name}') do %>
29
+ foo
30
+ <% end %>
31
+ </div>
32
+
33
+ def index
34
+ FeatureGate::Manager.gate_page('test')
35
+ end
36
+ TEXT
37
+
38
+ fake_file = double(read: text)
39
+ allow(File).to receive(:new).and_return(fake_file)
40
+ expect(gate).not_to be_destroyable
41
+ end
42
+
43
+ it 'return false if files contain feature gate gating part of a page' do
44
+ text = <<-TEXT
45
+ <div>
46
+ <% FeatureGate::Manager.gate('test') do %>
47
+ foo
48
+ <% end %>
49
+ </div>
50
+
51
+ def index
52
+ FeatureGate::Manager.gate_page('#{gate.name}')
53
+ end
54
+ TEXT
55
+
56
+ fake_file = double(read: text)
57
+ allow(File).to receive(:new).and_return(fake_file)
58
+ expect(gate).not_to be_destroyable
59
+ end
60
+ end
61
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feature_gate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tiffany Huang
@@ -97,6 +97,7 @@ files:
97
97
  - spec/controllers/feature_gate/gated_features_controller_spec.rb
98
98
  - spec/factories.rb
99
99
  - spec/fake_app.rb
100
+ - spec/models/feature_gate/gated_feature_spec.rb
100
101
  - spec/models/feature_gate/manager_spec.rb
101
102
  - spec/spec_helper.rb
102
103
  - spec/support/database.yml