@@ -103,23 +103,32 @@ class IngestorTest < ActiveSupport::TestCase
103103 content_provider : provider , user : users ( :admin ) )
104104 ingestor = Ingestors ::Ingestor . new
105105 new_event = OpenStruct . new ( url : 'https://some-course.net' ,
106- title : 'Yet another course ' ,
106+ title : 'Yet another event ' ,
107107 start : '2021-01-31 13:00:00' ,
108108 end :'2021-01-31 14:00:00' ,
109109 description : 'professor, tool criticism and software citation in text' )
110+ new_material = OpenStruct . new ( url : 'https://some-course.net' ,
111+ title : 'Yet another course' ,
112+ description : 'professor, tool criticism and software citation in text' )
110113 with_settings ( { feature : { auto_parse_vars : auto_parse_vars } } ) do
111114 ingestor . add_event ( new_event )
115+ ingestor . add_material ( new_material )
112116 assert_difference ( 'provider.events.count' , 1 ) do
113- ingestor . write ( user , provider , source : @source )
117+ assert_difference ( 'provider.materials.count' , 1 ) do
118+ ingestor . write ( user , provider , source : @source )
119+ end
114120 end
115121 end
116- event = Event . find_by ( title : 'Yet another course' )
117- if enabled == 'enabled'
118- assert_equal ( [ 'researchers' ] , event . target_audience )
119- assert_equal ( [ 'Research software management' , 'Data infrastructure' ] , event . keywords )
120- else
121- assert_equal ( [ ] , event . target_audience )
122- assert_equal ( [ ] , event . keywords )
122+ event = Event . find_by ( title : 'Yet another event' )
123+ material = Material . find_by ( title : 'Yet another course' )
124+ [ event , material ] . each do |obj |
125+ if enabled == 'enabled'
126+ assert_equal ( [ 'researchers' ] . sort , obj . target_audience . sort )
127+ assert_equal ( [ 'Research software management' , 'Data infrastructure' ] . sort , obj . keywords . sort )
128+ else
129+ assert_equal ( [ ] , obj . target_audience )
130+ assert_equal ( [ ] , obj . keywords )
131+ end
123132 end
124133 end
125134 end
0 commit comments