toggles 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 021ee95f3fb8265217d9601170a5217b47660cf6
4
- data.tar.gz: c91a3c28066e419b87776e39819dea4e1cc96f6f
3
+ metadata.gz: 161f954b81d64d3d1942e3f6b189bd7a1de45da8
4
+ data.tar.gz: 6df537de28770b0a791b442afb3a7ac05439e0d0
5
5
  SHA512:
6
- metadata.gz: 49bfb5d18dfbfdf227129a6503d338b2d919851798975674e097d44c2ff42e4ba06680c559f75a2bade07f5567844aeb04fafcffb59e4b0611a571f36e275987
7
- data.tar.gz: e0653c4394f6bf883b43894e23df308bf8af04061387db2663a1982ae793a1b98e231b4f3a2bb65ff9fbb1233f66317471d90d40b51dd5c2cfd4b227fa06b1ac
6
+ metadata.gz: 3605a942f1e9a914174d9d2f0683bbad7a8243ed2a0a2a39f8da0471c5a1e3710328255491ad3ece29c2356f776f342c72327dad9699dc50604f24be8e37fcc6
7
+ data.tar.gz: a43cf2b9a274517d8f5ae269b4ccce0fb7868182706c51144584069af7a936301a9862fcfe6bddc1b03f1a7213fc833cfd76ce9ec5e9df630eccf05243bc324c
@@ -1,4 +1,5 @@
1
1
  require "ostruct"
2
+ require "forwardable"
2
3
 
3
4
  module Feature
4
5
  class Permissions
@@ -24,6 +25,10 @@ module Feature
24
25
  rules.all? do |name, rule|
25
26
  entity = entities[name.to_sym]
26
27
 
28
+ if entity.nil?
29
+ return false
30
+ end
31
+
27
32
  if entity.class.ancestors.find { |ancestor| ancestor == Comparable }
28
33
  entity = OpenStruct.new(name => entity)
29
34
  rule = {name => rule}
@@ -5,5 +5,6 @@ describe Feature::Collection do
5
5
  expect(Feature::Collection.enabled_for?(user: double(id: 10))).to eq true
6
6
  expect(Feature::Collection.enabled_for?(user: double(id: 49))).to eq false
7
7
  expect(Feature::Collection.enabled_for?(user: double(id: 51))).to eq true
8
+ expect(Feature::Collection.enabled_for?(user: nil)).to eq false
8
9
  end
9
10
  end
@@ -2,5 +2,6 @@ describe Feature::Type do
2
2
  specify do
3
3
  expect(Feature::Type.enabled_for?(user_id: 1)).to eq true
4
4
  expect(Feature::Type.enabled_for?(user_id: 25)).to eq false
5
+ expect(Feature::Type.enabled_for?(user_id: nil)).to eq false
5
6
  end
6
7
  end
@@ -2,5 +2,6 @@ describe Feature::Operation::In do
2
2
  specify do
3
3
  expect(described_class.call(double(id: 50), :id, {"range" => [40, 60]})).to eq true
4
4
  expect(described_class.call(double(id: 50), :id, [1])).to eq false
5
+ expect(described_class.call(double(id: nil), :id, [1])).to eq false
5
6
  end
6
7
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "toggles"
3
- s.version = "0.0.7"
3
+ s.version = "0.0.8"
4
4
  s.authors = ["Andrew Tribone"]
5
5
  s.summary = "YAML backed feature toggles"
6
6
  s.email = "tribone@easypost.com"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: toggles
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Tribone
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-24 00:00:00.000000000 Z
11
+ date: 2015-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler