Skip to content

Commit

Permalink
Merge pull request #123 from yossi-eynav/add_method_to_set_users
Browse files Browse the repository at this point in the history
Add a method for setting an array of users
  • Loading branch information
reneklacan authored Jun 30, 2017
2 parents cd08f47 + dc7bc7e commit 5775215
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/rollout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,13 @@ def deactivate_users(feature, users)
end
end

def set_users(feature, users)
with_feature(feature) do |f|
f.users = []
users.each{|user| f.add_user(user)}
end
end

def define_group(group, &block)
@groups[group.to_sym] = block
end
Expand Down
10 changes: 10 additions & 0 deletions spec/rollout_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,16 @@
end
end


describe 'set a group of users' do
it 'should replace the users with the given array' do
users = %w(1 2 3 4)
@rollout.activate_users(:chat, %w(10 20 30))
@rollout.set_users(:chat, users)
expect(@rollout.get(:chat).users).to eq(users)
end
end

describe "activating a feature globally" do
before do
@rollout.activate(:chat)
Expand Down

0 comments on commit 5775215

Please sign in to comment.