Skip to content

Commit 95b0de1

Browse files
committed
added source info verification to the tests for feature tests
1 parent 4ccea78 commit 95b0de1

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

spec/project_spec.rb

+7-6
Original file line numberDiff line numberDiff line change
@@ -2420,27 +2420,28 @@ def callback(_args); end
24202420
describe 'when the feature flag is enabled for the user' do
24212421
describe 'and a variable usage instance is not found' do
24222422
it 'should return the default variable value' do
2423+
Decision = Struct.new(:experiment, :variation, :source)
24232424
variation_to_return = project_config.rollout_id_map['166661']['experiments'][0]['variations'][0]
2424-
decision_to_return = {
2425-
'experiment' => nil,
2426-
'variation' => variation_to_return
2427-
}
2425+
decision_to_return = Decision.new({'key' => 'test-exp'}, variation_to_return, 'feature-test')
24282426
allow(project_instance.decision_service).to receive(:get_variation_for_feature).and_return(decision_to_return)
24292427

24302428
expect(project_instance.notification_center).to receive(:send_notifications).once.with(
24312429
Optimizely::NotificationCenter::NOTIFICATION_TYPES[:DECISION],
24322430
'all-feature-variables', 'test_user', {},
24332431
feature_enabled: true,
24342432
feature_key: 'all_variables_feature',
2435-
source: 'rollout',
2433+
source: 'feature-test',
24362434
variable_values: {
24372435
'json_variable' => {'val' => 'default json'},
24382436
'string_variable' => 'default string',
24392437
'boolean_variable' => false,
24402438
'double_variable' => 1.99,
24412439
'integer_variable' => 10
24422440
},
2443-
source_info: {}
2441+
source_info: {
2442+
experiment_key: 'test-exp',
2443+
variation_key: '177775'
2444+
}
24442445
)
24452446

24462447
expect(project_instance.get_all_feature_variables('all_variables_feature', user_id, user_attributes))

0 commit comments

Comments
 (0)