From dc7bc7e87377ba465635b005f8cd4f84bec0d3cb Mon Sep 17 00:00:00 2001 From: Yossi Eynav Date: Fri, 30 Jun 2017 16:26:31 +0300 Subject: [PATCH] Add a method for setting an array of users --- lib/rollout.rb | 7 +++++++ spec/rollout_spec.rb | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/lib/rollout.rb b/lib/rollout.rb index afaddbf..07c3954 100644 --- a/lib/rollout.rb +++ b/lib/rollout.rb @@ -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 diff --git a/spec/rollout_spec.rb b/spec/rollout_spec.rb index f4b803b..8226c30 100644 --- a/spec/rollout_spec.rb +++ b/spec/rollout_spec.rb @@ -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)