Skip to content

Commit 0693b4c

Browse files
committed
✏️ Ensure that bucketing is indeed using the bucketing id and not the user id
1 parent a1715f7 commit 0693b4c

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

spec/bucketing_spec.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,15 @@ def get_bucketing_key(bucketing_id, entity_id=nil)
147147

148148
describe 'Bucketing with Bucketing Id' do
149149
# Bucketing with bucketing ID
150+
# Make sure that the bucketing ID is used for the bucketing and not the user ID
150151
it 'should bucket to a variation different than the one expected with the userId' do
151152
experiment = config.get_experiment_from_key('test_experiment')
152153

153-
# Bucketing with user id as bucketing id - 'test_user111127' produces bucket value < 5000
154+
# Bucketing with user id as bucketing id - 'test_user111127' produces bucket value < 5000 thus buckets to control
154155
expected_variation = config.get_variation_from_id('test_experiment','111128')
155156
expect(bucketer.bucket(experiment,'test_user', 'test_user')).to be(expected_variation)
156157

157-
# Bucketing with bucketing id - 'any_string789111127' produces bucket value btw 5000 to 10,000
158+
# Bucketing with bucketing id - 'any_string789111127' produces bucket value btw 5000 to 10,000 thus buckets to variation
158159
expected_variation = config.get_variation_from_id('test_experiment','111129')
159160
expect(bucketer.bucket(experiment,'any_string789', 'test_user')).to be(expected_variation)
160161
end
@@ -165,11 +166,12 @@ def get_bucketing_key(bucketing_id, entity_id=nil)
165166
end
166167

167168
# Bucketing with grouped experiments and bucketing ID
168-
it 'should bucket expectedly when bucketing id in grouped experiments' do
169+
# Make sure that the bucketing ID is used for the bucketing and not the user ID
170+
it 'should bucket to a variation different than the one expected with the userId in grouped experiments' do
169171
experiment = config.get_experiment_from_key('group1_exp1')
170172

171-
expected_variation = config.get_variation_from_id('group1_exp1','130001')
172-
expect(bucketer.bucket(experiment,'pid', 'test_user')).to be(expected_variation)
173+
expected_variation = nil
174+
expect(bucketer.bucket(experiment,'test_user', 'test_user')).to be(expected_variation)
173175

174176
expected_variation = config.get_variation_from_id('group1_exp1','130002')
175177
expect(bucketer.bucket(experiment,'123456789', 'test_user')).to be(expected_variation)

0 commit comments

Comments
 (0)