Skip to content

Commit dd484bb

Browse files
authored
fix: Make TestData value_for_all return its value when targeting is off (#490)
1 parent 9a2f5b9 commit dd484bb

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

‎lib/ldclient-rb/integrations/test_data/flag_builder.rb‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def variation_for_all(variation)
181181
# @return [FlagBuilder] the builder
182182
#
183183
def value_for_all(value)
184-
variations(value).variation_for_all(0)
184+
variations(value).variation_for_all(0).off_variation(0)
185185
end
186186

187187
#

‎spec/integrations/test_data_spec.rb‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,16 @@ module Integrations
178178
expect(f[:fallthrough][:variation]).to be(0)
179179
end
180180

181+
it 'returns the value_for_all value whether targeting is on or off' do
182+
f = TestData::FlagBuilder.new('flag').value_for_all('x').build(1)
183+
expect(f[:variations]).to eq(['x'])
184+
expect(f[:fallthrough]).to eq({ variation: 0 })
185+
expect(f[:offVariation]).to eq(0)
186+
187+
off_flag = TestData::FlagBuilder.new('flag').value_for_all('x').on(false).build(1)
188+
expect(off_flag[:offVariation]).to eq(0)
189+
end
190+
181191
it 'clears existing rules when setting variation for all users' do
182192
f = TestData::FlagBuilder.new('flag')
183193
.if_match('name', 'ben')

0 commit comments

Comments
 (0)