Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/ldclient-rb/integrations/test_data_v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def initialize
# @return [FlagBuilderV2] a flag configuration builder
#
def flag(key)
key = key.to_s
existing_builder = @lock.with_read_lock do
if @flag_builders.key?(key) && !@flag_builders[key].nil?
@flag_builders[key]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class FlagBuilderV2

# @api private
def initialize(key)
@_key = key
@_key = key.to_s
@_on = true
@_variations = []
@_off_variation = nil
Expand Down
19 changes: 19 additions & 0 deletions spec/integrations/test_data_v2_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,25 @@ module Integrations
expect(td.flag('myflag').build(1)[:variations]).to eq([true, false])
end

it 'starts a new flag builder after a preconfigured flag replaces a flag built with a symbol key' do
td = TestDataV2.data_source
td.update(td.flag(:myflag).variations('x', 'y'))
td.use_preconfigured_flag({ key: 'myflag', variations: ['a'] })
expect(td.flag(:myflag).build(1)[:variations]).to eq([true, false])
end

it 'gives a symbol key and a string key the same flag builder' do
td = TestDataV2.data_source
td.update(td.flag(:myflag).variations('x', 'y'))
expect(td.flag('myflag').build(1)[:variations]).to eq(['x', 'y'])
end

it 'stores a flag built with a symbol key with a string key' do
td = TestDataV2.data_source
td.update(td.flag(:myflag).variation_for_all(true))
expect(td.make_init_data[:flags][:myflag][:key]).to eq('myflag')
end

it 'sends a preconfigured flag to a running data source' do
td = TestDataV2.data_source
source = LaunchDarkly::Impl::Integrations::TestData::TestDataSourceV2.new(td)
Expand Down
Loading