step_by_step 0.0.1.5 → 0.0.1.6

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: 914546dc63e40d0896c7b86b82b42671ae777299
4
- data.tar.gz: 95cf8bf3d06b7c14d629669f214a23e4fae5c76a
3
+ metadata.gz: 6b64d9c4cfa6b4c77891f18ea104026433d41053
4
+ data.tar.gz: 9f983742023547cf519014cde73a7b904598bbcd
5
5
  SHA512:
6
- metadata.gz: 1d06e4a64e8249df4fa010ab93952490c8fb1aecabaa01c0d17ff1ac7cc64a3bc926a2bb18f091805f18994a7b5b6fc2927b7883acc5eb18624db7208fbd1fdb
7
- data.tar.gz: 5ce8f9b3a8b4a796242ea15e6b0d8722de1c1c80a0e0250b5c7fe20468029509631cacfd89547843b7a25a4a10fa13e28f0f3f9ba61ddfc259353acbbc8887b1
6
+ metadata.gz: 578b543150c9db5cb5f83c7e7cf28d6c0aa7a5b19c9f87156624989058e1995a3fbbae5da8645cba37fdf1dd294b3ec44802bb8ed2c70e78ee42f553d1cd73ba
7
+ data.tar.gz: 755afe31c41c9d7a9fcf972d85cfa4b99847ea149701957a69bc75b450284b9081e755e4944d76595464c231acd520b83ba9d253a072860edbe61b8ddc6f5e3d
data/README.md CHANGED
@@ -77,7 +77,7 @@ Now your first user can see the comments feature.
77
77
  StepByStep::Rollout.activate(:comments)
78
78
  ```
79
79
 
80
- Now everyone can see the comments feature. This is theoretically the same as activating a percentage with value 100 or defining a group with a block that always returns true.
80
+ Now everyone can see the comments feature. This also includes users who are not authenticated. If you want to roll out a feature to all authenticated users, but not to the public, roll it out to a percentage of 100 instead.
81
81
 
82
82
  Activating a feature for everyone is common after you have determined that your rollout phase was successful.
83
83
 
@@ -1,7 +1,11 @@
1
1
  module StepByStep
2
2
  class Rollout < ActiveRecord::Base
3
3
  def match?(user)
4
- user && enabled? && (match_group?(user) || match_user?(user) || match_percentage?(user))
4
+ public? || user && enabled? && (match_group?(user) || match_user?(user) || match_percentage?(user))
5
+ end
6
+
7
+ def public?
8
+ group == 'all'
5
9
  end
6
10
 
7
11
  # Activates a feature for everyone
@@ -64,14 +68,16 @@ module StepByStep
64
68
  # Find the group whose block should be evaluated based on its name
65
69
  g = @@groups.select { |i| i.first.to_sym == group.to_sym }
66
70
 
67
- # There could theoretically be multiple groups with the same name;
68
- # only take the last one
69
- g = g.last
71
+ if g.present?
72
+ # There could theoretically be multiple groups with the same name;
73
+ # only take the last one
74
+ g = g.last
70
75
 
71
- # g is now an array that looks like this:
72
- # [:group_name, code_block]
73
- # Call the code block here with the user
74
- g.last.call(user)
76
+ # g is now an array that looks like this:
77
+ # [:group_name, code_block]
78
+ # Call the code block here with the user
79
+ g.last.call(user)
80
+ end
75
81
  end
76
82
  end
77
83
 
@@ -1,3 +1,3 @@
1
1
  module StepByStep
2
- VERSION = "0.0.1.5"
2
+ VERSION = "0.0.1.6"
3
3
  end
@@ -22,6 +22,11 @@ module StepByStep
22
22
  end
23
23
  end
24
24
 
25
+ it 'rolls out to the public' do
26
+ rollout = Rollout.activate(:feature)
27
+ expect(rollout.match?(user_3)).to be_truthy
28
+ end
29
+
25
30
  it 'rolls out to all' do
26
31
  rollout = Rollout.activate(:feature)
27
32
  expect(rollout.match?(user_1)).to be_truthy
@@ -40,6 +45,12 @@ module StepByStep
40
45
  expect(rollout.match?(user_2)).to be_falsey
41
46
  end
42
47
 
48
+ it 'rolls out to a user while group is empty string instead of `nil`' do
49
+ rollout = Rollout.create(user_id: user_1.id, group: '')
50
+ expect(rollout.match?(user_1)).to be_truthy
51
+ expect(rollout.match?(user_2)).to be_falsey
52
+ end
53
+
43
54
  it 'rolls out to a percentage' do
44
55
  rollout = Rollout.activate_percentage(:feature, 50)
45
56
 
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["dennis.hackethal@gmail.com"]
11
11
  spec.summary = %q{Active Record alternative to https://github.com/FetLife/rollout.}
12
12
  spec.description = %q{Alternative to https://github.com/FetLife/rollout, with an Active Record backend and additional helpers, partially based on Ryan Bates's custom solution in http://railscasts.com/episodes/315-rollout-and-degrade.}
13
- spec.homepage = ""
13
+ spec.homepage = "https://github.com/cobalthq/step_by_step"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: step_by_step
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.5
4
+ version: 0.0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dennis Charles Hackethal
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-01 00:00:00.000000000 Z
11
+ date: 2015-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -118,7 +118,7 @@ files:
118
118
  - spec/step_by_step.sqlite3
119
119
  - spec/support/schema.rb
120
120
  - step_by_step.gemspec
121
- homepage: ''
121
+ homepage: https://github.com/cobalthq/step_by_step
122
122
  licenses:
123
123
  - MIT
124
124
  metadata: {}
@@ -138,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
138
  version: '0'
139
139
  requirements: []
140
140
  rubyforge_project:
141
- rubygems_version: 2.2.2
141
+ rubygems_version: 2.4.6
142
142
  signing_key:
143
143
  specification_version: 4
144
144
  summary: Active Record alternative to https://github.com/FetLife/rollout.