@@ -253,7 +253,7 @@ class MaterialsControllerTest < ActionController::TestCase
253253 date_published : test_material . date_published ,
254254 doi : test_material . doi ,
255255 subsets : test_material . subsets ,
256- authors : test_material . authors ,
256+ authors_attributes : test_material . authors . map { | a | { first_name : a . first_name , last_name : a . last_name , orcid : a . orcid } } ,
257257 contributors : test_material . contributors ,
258258 prerequisites : test_material . prerequisites ,
259259 syllabus : test_material . syllabus ,
@@ -291,7 +291,15 @@ class MaterialsControllerTest < ActionController::TestCase
291291 assert_equal test_material . other_types , JSON . parse ( response . body ) [ 'other_types' ] , 'other_types not matched'
292292 #assert_equal test_material.events, JSON.parse(response.body)['events'], 'events not matched'
293293 assert_equal test_material . target_audience , JSON . parse ( response . body ) [ 'target_audience' ] , 'target audience not matched'
294- assert_equal test_material . authors , JSON . parse ( response . body ) [ 'authors' ] , 'authors not matched'
294+ # Authors is now an array of objects with id, first_name, last_name, orcid, full_name
295+ response_authors = JSON . parse ( response . body ) [ 'authors' ]
296+ assert_equal test_material . authors . size , response_authors . size , 'authors count not matched'
297+ response_authors . each_with_index do |author_json , i |
298+ expected_author = test_material . authors [ i ]
299+ assert_equal expected_author . first_name , author_json [ 'first_name' ] , "author #{ i } first_name not matched"
300+ assert_equal expected_author . last_name , author_json [ 'last_name' ] , "author #{ i } last_name not matched"
301+ assert_equal expected_author . full_name , author_json [ 'full_name' ] , "author #{ i } full_name not matched"
302+ end
295303 assert_equal test_material . contributors , JSON . parse ( response . body ) [ 'contributors' ] , 'contributors not matched'
296304 assert_equal test_material . subsets , JSON . parse ( response . body ) [ 'subsets' ] , 'subsets not matched'
297305 assert_equal test_material . prerequisites , JSON . parse ( response . body ) [ 'prerequisites' ] , 'prerequisites not matched'
0 commit comments