Skip to content
This repository has been archived by the owner on May 19, 2021. It is now read-only.

Commit

Permalink
Merge pull request #3 from msx2/master
Browse files Browse the repository at this point in the history
Fixed bug with undefined group
  • Loading branch information
msx2 committed Jul 29, 2015
2 parents 55c64cc + 80aa45f commit 2848935
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
18 changes: 10 additions & 8 deletions lib/step_by_step/rollout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,16 @@ def match_group?(user)
# Find the group whose block should be evaluated based on its name
g = @@groups.select { |i| i.first.to_sym == group.to_sym }

# There could theoretically be multiple groups with the same name;
# only take the last one
g = g.last

# g is now an array that looks like this:
# [:group_name, code_block]
# Call the code block here with the user
g.last.call(user)
if g.present?
# There could theoretically be multiple groups with the same name;
# only take the last one
g = g.last

# g is now an array that looks like this:
# [:group_name, code_block]
# Call the code block here with the user
g.last.call(user)
end
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/step_by_step/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module StepByStep
VERSION = "0.0.1.5"
VERSION = "0.0.1.6"
end
6 changes: 6 additions & 0 deletions spec/rollout_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ module StepByStep
expect(rollout.match?(user_2)).to be_falsey
end

it 'rolls out to a user while group is empty string instead of `nil`' do
rollout = Rollout.create(user_id: user_1.id, group: '')
expect(rollout.match?(user_1)).to be_truthy
expect(rollout.match?(user_2)).to be_falsey
end

it 'rolls out to a percentage' do
rollout = Rollout.activate_percentage(:feature, 50)

Expand Down
2 changes: 1 addition & 1 deletion step_by_step.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
spec.email = ["[email protected]"]
spec.summary = %q{Active Record alternative to https://github.com/FetLife/rollout.}
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.}
spec.homepage = ""
spec.homepage = "https://github.com/cobalthq/step_by_step"
spec.license = "MIT"

spec.files = `git ls-files -z`.split("\x0")
Expand Down

0 comments on commit 2848935

Please sign in to comment.