Skip to content

Commit 7d0f159

Browse files
committed
Changes
1 parent 6e4fa4e commit 7d0f159

File tree

3 files changed

+20
-15
lines changed

3 files changed

+20
-15
lines changed

lib/optimizely/project_config.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ def get_attribute_id(attribute_key)
383383
end
384384
return attribute['id']
385385
end
386-
return attribute_key if has_reserved_prefix && attribute_key != Helpers::Constants::CONTROL_ATTRIBUTES['BOT_FILTERING']
386+
return attribute_key if has_reserved_prefix
387387
@logger.log Logger::ERROR, "Attribute key '#{attribute_key}' is not in datafile."
388388
@error_handler.handle_error InvalidAttributeError
389389
nil

spec/event_builder_spec.rb

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -357,15 +357,18 @@
357357

358358
# Create impression event with bucketing ID
359359
it 'should create valid Event when create_impression_event is called with Bucketing ID attribute' do
360-
@expected_impression_params[:visitors][0][:attributes].unshift({
361-
entity_id: '111094',
362-
key: 'browser_type',
363-
type: 'custom',
364-
value: 'firefox'
365-
}, entity_id: Optimizely::Helpers::Constants::CONTROL_ATTRIBUTES['BUCKETING_ID'],
366-
key: Optimizely::Helpers::Constants::CONTROL_ATTRIBUTES['BUCKETING_ID'],
367-
type: 'custom',
368-
value: 'variation')
360+
@expected_impression_params[:visitors][0][:attributes].unshift(
361+
{
362+
entity_id: '111094',
363+
key: 'browser_type',
364+
type: 'custom',
365+
value: 'firefox'
366+
},
367+
entity_id: Optimizely::Helpers::Constants::CONTROL_ATTRIBUTES['BUCKETING_ID'],
368+
key: Optimizely::Helpers::Constants::CONTROL_ATTRIBUTES['BUCKETING_ID'],
369+
type: 'custom',
370+
value: 'variation'
371+
)
369372

370373
user_attributes = {
371374
'browser_type' => 'firefox',

spec/project_config_spec.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,18 +1031,20 @@
10311031
describe 'get_attribute_id_valid_key' do
10321032
let(:spy_logger) { spy('logger') }
10331033
let(:config) { Optimizely::ProjectConfig.new(config_body_JSON, spy_logger, error_handler) }
1034+
10341035
it 'should return attribute ID when provided valid attribute key has reserved prefix' do
10351036
config.attribute_key_map['$opt_bot'] = {'key' => '$opt_bot', 'id' => '111'}
10361037
expect(config.get_attribute_id('$opt_bot')).to eq('111')
1037-
expect(spy_logger).to have_received(:log).with(Logger::WARN,
1038-
"Attribute '$opt_bot' unexpectedly has reserved prefix '$opt_'; using attribute ID instead of reserved attribute name.")
1038+
expect(spy_logger).to have_received(:log).with(
1039+
Logger::WARN,
1040+
"Attribute '$opt_bot' unexpectedly has reserved prefix '$opt_'; using attribute ID instead of reserved attribute name."
1041+
)
10391042
end
1043+
10401044
it 'should return attribute ID when provided attribute key is valid' do
10411045
expect(config.get_attribute_id('browser_type')).to eq('111094')
10421046
end
1043-
it 'should return nil when provided attribute key is bot_filtering_constant' do
1044-
expect(config.get_attribute_id('$opt_bot_filtering')).to eq(nil)
1045-
end
1047+
10461048
it 'should return attribute key as attribute ID when key has reserved prefix but is not present in data file' do
10471049
expect(config.get_attribute_id('$opt_user_agent')).to eq('$opt_user_agent')
10481050
end

0 commit comments

Comments
 (0)