@@ -4916,5 +4916,39 @@ class InvalidEventManager; end # rubocop:disable Lint/ConstantDefinitionInBlock
4916
4916
4917
4917
project . close
4918
4918
end
4919
+
4920
+ it 'should log error with nil action' do
4921
+ expect ( spy_logger ) . to receive ( :log ) . once . with ( Logger ::ERROR , 'ODP action is not valid (cannot be empty).' )
4922
+ project = Optimizely ::Project . new ( config_body_integrations_JSON , nil , spy_logger )
4923
+ project . send_odp_event ( type : 'wow' , action : nil , identifiers : { amazing : 'fantastic' } , data : { } )
4924
+ project . close
4925
+ end
4926
+
4927
+ it 'should log error with empty string action' do
4928
+ expect ( spy_logger ) . to receive ( :log ) . once . with ( Logger ::ERROR , 'ODP action is not valid (cannot be empty).' )
4929
+ project = Optimizely ::Project . new ( config_body_integrations_JSON , nil , spy_logger )
4930
+ project . send_odp_event ( type : 'wow' , action : '' , identifiers : { amazing : 'fantastic' } , data : { } )
4931
+ project . close
4932
+ end
4933
+
4934
+ it 'should use default with nil type' do
4935
+ project = Optimizely ::Project . new ( config_body_integrations_JSON , nil , spy_logger )
4936
+ expect ( project . odp_manager ) . to receive ( 'send_event' ) . with ( type : 'fullstack' , action : 'great' , identifiers : { amazing : 'fantastic' } , data : { } )
4937
+ project . send_odp_event ( type : nil , action : 'great' , identifiers : { amazing : 'fantastic' } , data : { } )
4938
+
4939
+ expect ( spy_logger ) . not_to have_received ( :log ) . with ( Logger ::ERROR , anything )
4940
+
4941
+ project . close
4942
+ end
4943
+
4944
+ it 'should use default with empty string type' do
4945
+ project = Optimizely ::Project . new ( config_body_integrations_JSON , nil , spy_logger )
4946
+ expect ( project . odp_manager ) . to receive ( 'send_event' ) . with ( type : 'fullstack' , action : 'great' , identifiers : { amazing : 'fantastic' } , data : { } )
4947
+ project . send_odp_event ( type : '' , action : 'great' , identifiers : { amazing : 'fantastic' } , data : { } )
4948
+
4949
+ expect ( spy_logger ) . not_to have_received ( :log ) . with ( Logger ::ERROR , anything )
4950
+
4951
+ project . close
4952
+ end
4919
4953
end
4920
4954
end
0 commit comments