Skip to content

Commit 2ccc941

Browse files
authored
Merge pull request #34 from optimizely/devel
Release v1.1.1
2 parents 6b295d1 + 176e1b2 commit 2ccc941

File tree

5 files changed

+30
-11
lines changed

5 files changed

+30
-11
lines changed

CHANGELOG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
-------------------------------------------------------------------------------
2+
1.1.1
3+
* Gracefully handle empty traffic allocation ranges.
4+
-------------------------------------------------------------------------------
5+
16
-------------------------------------------------------------------------------
27
1.1.0
38
* Introduce support for event tags.

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
1-
#Optimizely Ruby SDK
1+
# Optimizely Ruby SDK
22
[![Build Status](https://travis-ci.org/optimizely/ruby-sdk.svg?branch=master)](https://travis-ci.org/optimizely/ruby-sdk)
33
[![Coverage Status](https://coveralls.io/repos/github/optimizely/ruby-sdk/badge.svg)](https://coveralls.io/github/optimizely/ruby-sdk)
44
[![Apache 2.0](https://img.shields.io/github/license/nebula-plugins/gradle-extra-configurations-plugin.svg)](http://www.apache.org/licenses/LICENSE-2.0)
55

66
This repository houses the Ruby SDK for Optimizely's Full Stack product.
77

8-
##Getting Started
8+
## Getting Started
99

10-
###Installing the SDK
10+
### Installing the SDK
1111

1212
The SDK is available through [RubyGems](https://rubygems.org/gems/optimizely-sdk). To install:
1313

1414
```
1515
gem install optimizely-sdk
1616
```
1717

18-
###Using the SDK
18+
### Using the SDK
1919
See the Optimizely Full Stack [developer documentation](http://developers.optimizely.com/server/reference/index.html) to learn how to set up your first Full Stack project and use the SDK.
2020

21-
##Development
21+
## Development
2222

23-
###Building the SDK
23+
### Building the SDK
2424

2525
To build a local copy of the gem which will be output to `/pkg`:
2626

2727
```
2828
rake build
2929
```
3030

31-
###Unit tests
31+
### Unit tests
3232

33-
#####Running all tests
33+
##### Running all tests
3434
You can run all unit tests with:
3535

3636
```
3737
rake spec
3838
```
3939

40-
###Contributing
40+
### Contributing
4141

4242
Please see [CONTRIBUTING](CONTRIBUTING.md).

lib/optimizely/bucketer.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def bucket(experiment_key, user_id)
100100
@config.logger.log(Logger::DEBUG, "Assigned variation bucket #{bucket_value} to user '#{user_id}'.")
101101
traffic_allocations = @config.get_traffic_allocation(experiment_key)
102102
variation_id = find_bucket(bucket_value, traffic_allocations)
103-
if variation_id
103+
if variation_id && variation_id != ''
104104
variation_key = @config.get_variation_key_from_id(experiment_key, variation_id)
105105
@config.logger.log(
106106
Logger::INFO,
@@ -109,6 +109,11 @@ def bucket(experiment_key, user_id)
109109
return variation_id
110110
end
111111

112+
# Handle the case when the traffic range is empty due to sticky bucketing
113+
if variation_id == ''
114+
@config.logger.log(Logger::DEBUG, 'Bucketed into an empty traffic range. Returning nil.')
115+
end
116+
112117
@config.logger.log(Logger::INFO, "User '#{user_id}' is in no variation.")
113118
nil
114119
end

lib/optimizely/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@
1414
# limitations under the License.
1515
#
1616
module Optimizely
17-
VERSION = '1.1.0'.freeze
17+
VERSION = '1.1.1'.freeze
1818
end

spec/bucketing_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,15 @@ def get_bucketing_id(user_id, entity_id=nil)
133133
bucketer.bucket('group1_exp1', 'test_user')
134134
end
135135

136+
it 'should return nil when user is in an empty traffic allocation range due to sticky bucketing' do
137+
expect(bucketer).to receive(:find_bucket).once.and_return('')
138+
expect(bucketer.bucket('test_experiment', 'test_user')).to be_nil
139+
expect(spy_logger).to have_received(:log)
140+
.with(Logger::INFO, "User 'test_user' is in no variation.")
141+
expect(spy_logger).to have_received(:log)
142+
.with(Logger::DEBUG, "Bucketed into an empty traffic range. Returning nil.")
143+
end
144+
136145
describe 'logging' do
137146
it 'should log the results of bucketing a user into variation 1' do
138147
expect(bucketer).to receive(:generate_bucket_value).and_return(50)

0 commit comments

Comments
 (0)