detour 0.0.13 → 0.0.14
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56b427edb8fe39d2b124dde7956617717f7a31d2
|
4
|
+
data.tar.gz: 1de6769e6f69d524232fa2a2f6d60e9c0214ed9b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8dac7e6ee1f0d717b735530382354b080eba36cbcae8b6d66191a6d6e6f6bf468a8ce2a105670db292cea968b027627fecd2c1dc35cecd88b1dc8463238360f3
|
7
|
+
data.tar.gz: dcff87181b0126f6c6276b4a01549f8af074ff8064fd69b09ca16065722dbc0f093c8c52f8f41b50e648f0cb4b62f5267eae6029c442246d9df908a05bb90ab2
|
data/lib/detour/flaggable.rb
CHANGED
@@ -4,11 +4,11 @@ module Detour::Flaggable
|
|
4
4
|
# Returns an array of all features rolled out to the given record.
|
5
5
|
#
|
6
6
|
# @example
|
7
|
-
# user.
|
7
|
+
# user.detour_features
|
8
8
|
#
|
9
9
|
# @return [Array] An array of {Detour::Feature}s.
|
10
|
-
def
|
11
|
-
@
|
10
|
+
def detour_features
|
11
|
+
@detour_features ||= begin
|
12
12
|
features = unfiltered_features
|
13
13
|
defined_group_flags = Detour::DefinedGroupFlag.without_opt_outs(self).where("feature_id IN (?)", features.map(&:id) << -1) # Prevents NOT IN (NULL)
|
14
14
|
|
@@ -37,11 +37,7 @@ module Detour::Flaggable
|
|
37
37
|
# @param [Proc] &block A block to be called if the user is flagged in to the
|
38
38
|
# feature.
|
39
39
|
def has_feature?(feature_name, &block)
|
40
|
-
|
41
|
-
end
|
42
|
-
|
43
|
-
def detour_features
|
44
|
-
@detour_features ||= []
|
40
|
+
detour_features.map(&:name).include? feature_name.to_s
|
45
41
|
end
|
46
42
|
|
47
43
|
private
|
data/lib/detour/version.rb
CHANGED
@@ -7,7 +7,7 @@ describe "percentage rollouts" do
|
|
7
7
|
|
8
8
|
describe "creating a percentage rollout" do
|
9
9
|
it "makes the feature available to the given percentage of instances" do
|
10
|
-
users.select { |user| user.
|
10
|
+
users.select { |user| user.detour_features.include?(feature) }.length.should eq users.length / 5
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
@@ -3,7 +3,7 @@ require "spec_helper"
|
|
3
3
|
describe Detour::Flaggable do
|
4
4
|
subject { create :user }
|
5
5
|
|
6
|
-
describe "#
|
6
|
+
describe "#detour_features" do
|
7
7
|
let(:feature1) { create :feature }
|
8
8
|
let(:feature2) { create :feature }
|
9
9
|
let(:feature3) { create :feature }
|
@@ -25,13 +25,13 @@ describe Detour::Flaggable do
|
|
25
25
|
end
|
26
26
|
|
27
27
|
it "finds every feature for a record" do
|
28
|
-
subject.
|
28
|
+
subject.detour_features.sort.should eq [feature1, feature2, feature3, feature5].sort
|
29
29
|
end
|
30
30
|
|
31
31
|
it "is memoized" do
|
32
|
-
subject.
|
32
|
+
subject.detour_features
|
33
33
|
Detour::Feature.stub(:joins) { raise "I was called" }
|
34
|
-
subject.
|
34
|
+
subject.detour_features
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|