Skip to content

Commit

Permalink
Merge pull request fetlife#144 from Seitk/fix/empty-features-crash-on…
Browse files Browse the repository at this point in the history
…-multi-get

Fix crash on multi_get when calling with empty features
  • Loading branch information
reneklacan authored Nov 7, 2019
2 parents 99e5a81 + bc76bb4 commit bc7bd30
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/rollout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ def clear_feature_data(feature)
end

def multi_get(*features)
return [] if features.empty?

feature_keys = features.map { |feature| key(feature) }
@storage.mget(*feature_keys).map.with_index { |string, index| Feature.new(features[index], string, @options) }
end
Expand Down
6 changes: 6 additions & 0 deletions spec/rollout_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,12 @@
expect(features[2].percentage).to eq 100
expect(features.size).to eq 3
end

describe 'when given feature keys is empty' do
it 'returns empty array' do
expect(@rollout.multi_get(*[])).to match_array([])
end
end
end

describe "#set_feature_data" do
Expand Down

0 comments on commit bc7bd30

Please sign in to comment.