@@ -361,6 +361,12 @@ class InvalidErrorHandler; end
361
361
}
362
362
end
363
363
364
+ it 'should return nil when user_id is empty or nil' do
365
+ expect ( project_instance . track ( 'test_event' , '' , nil , 'revenue' => 42 ) ) . to eq ( nil )
366
+ expect ( project_instance . track ( 'test_event' , nil , nil , 'revenue' => 42 ) ) . to eq ( nil )
367
+ expect ( spy_logger ) . to have_received ( :log ) . twice . with ( Logger ::ERROR , 'User ID cannot be empty.' )
368
+ end
369
+
364
370
it 'should properly track an event by calling dispatch_event with right params' do
365
371
params = @expected_track_event_params
366
372
@@ -529,6 +535,12 @@ class InvalidErrorHandler; end
529
535
end
530
536
531
537
describe '#get_variation' do
538
+ it 'should return nil when user_id is empty or nil' do
539
+ expect ( project_instance . get_variation ( 'test_experiment_with_audience' , '' , nil ) ) . to eq ( nil )
540
+ expect ( project_instance . get_variation ( 'test_experiment_with_audience' , nil , nil ) ) . to eq ( nil )
541
+ expect ( spy_logger ) . to have_received ( :log ) . twice . with ( Logger ::ERROR , 'User ID cannot be empty.' )
542
+ end
543
+
532
544
it 'should have get_variation return expected variation when there are no audiences' do
533
545
expect ( project_instance . get_variation ( 'test_experiment' , 'test_user' ) )
534
546
. to eq ( config_body [ 'experiments' ] [ 0 ] [ 'variations' ] [ 0 ] [ 'key' ] )
@@ -1012,10 +1024,12 @@ class InvalidErrorHandler; end
1012
1024
expect ( spy_logger ) . to have_received ( :log ) . once . with ( Logger ::ERROR , 'Variable key cannot be empty.' )
1013
1025
end
1014
1026
1015
- it 'should return nil if user_id is nil' do
1027
+ it 'should return nil if user_id is empty or nil' do
1016
1028
expect ( project_instance . get_feature_variable_integer ( 'integer_single_variable_feature' , 'integer_variable' , nil , user_attributes ) )
1017
1029
. to eq ( nil )
1018
- expect ( spy_logger ) . to have_received ( :log ) . once . with ( Logger ::ERROR , 'User ID cannot be empty.' )
1030
+ expect ( project_instance . get_feature_variable_integer ( 'integer_single_variable_feature' , 'integer_variable' , '' , user_attributes ) )
1031
+ . to eq ( nil )
1032
+ expect ( spy_logger ) . to have_received ( :log ) . twice . with ( Logger ::ERROR , 'User ID cannot be empty.' )
1019
1033
end
1020
1034
end
1021
1035
0 commit comments