From 77411c60da63de32936556a6309b26e9587cdf22 Mon Sep 17 00:00:00 2001 From: Matthew Keeler Date: Thu, 5 Nov 2026 18:40:15 +0000 Subject: [PATCH] fix: Make TestData value_for_all return its value when targeting is off Generated-by: termag --- lib/ldclient-rb/integrations/test_data/flag_builder.rb | 2 +- spec/integrations/test_data_spec.rb | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/ldclient-rb/integrations/test_data/flag_builder.rb b/lib/ldclient-rb/integrations/test_data/flag_builder.rb index f8666641..9c4ffca9 100644 --- a/lib/ldclient-rb/integrations/test_data/flag_builder.rb +++ b/lib/ldclient-rb/integrations/test_data/flag_builder.rb @@ -181,7 +181,7 @@ def variation_for_all(variation) # @return [FlagBuilder] the builder # def value_for_all(value) - variations(value).variation_for_all(0) + variations(value).variation_for_all(0).off_variation(0) end # diff --git a/spec/integrations/test_data_spec.rb b/spec/integrations/test_data_spec.rb index 3c28fd4e..2f93e19c 100644 --- a/spec/integrations/test_data_spec.rb +++ b/spec/integrations/test_data_spec.rb @@ -178,6 +178,16 @@ module Integrations expect(f[:fallthrough][:variation]).to be(0) end + it 'returns the value_for_all value whether targeting is on or off' do + f = TestData::FlagBuilder.new('flag').value_for_all('x').build(1) + expect(f[:variations]).to eq(['x']) + expect(f[:fallthrough]).to eq({ variation: 0 }) + expect(f[:offVariation]).to eq(0) + + off_flag = TestData::FlagBuilder.new('flag').value_for_all('x').on(false).build(1) + expect(off_flag[:offVariation]).to eq(0) + end + it 'clears existing rules when setting variation for all users' do f = TestData::FlagBuilder.new('flag') .if_match('name', 'ben')