diff --git a/app/helpers/materials_helper.rb b/app/helpers/materials_helper.rb index d3a5f59db..d7b72b8fc 100644 --- a/app/helpers/materials_helper.rb +++ b/app/helpers/materials_helper.rb @@ -105,7 +105,8 @@ def display_people(resource, attribute) display_attribute(resource, attribute) do |values| html = values.map do |person| if person.profile - link_to(person.profile.full_name, person.profile) + target = person.profile.is_a?(Trainer) ? person.profile : person.profile.user + link_to(person.profile.full_name, target) elsif person.orcid.present? image_tag('ORCID-iD_icon_vector.svg', size: 16) + ' ' + external_link(person.display_name, person.orcid_url) diff --git a/test/controllers/materials_controller_test.rb b/test/controllers/materials_controller_test.rb index 5fab13938..c5ae48ad1 100644 --- a/test/controllers/materials_controller_test.rb +++ b/test/controllers/materials_controller_test.rb @@ -1629,6 +1629,28 @@ class MaterialsControllerTest < ActionController::TestCase end end + test 'should display non-trainer contributor with linked ORCID' do + jc = profiles(:trainer_one_profile) + jc.update!(public: false, website: nil, image_url: nil) + jc = Profile.find(jc.id) + assert @material.update(authors: [{ name: 'John Doe' }, + { name: 'Jane Smith', orcid: '0000-0001-9999-9990' }], + contributors: [{ name: 'Jos Ca', orcid: '0000-0002-1825-0097' }]) + + get :show, params: { id: @material.id } + + assert_select '.authors', text: 'Authors: John Doe, Jane Smith' + assert_select '.authors a', count: 1 do + assert_select '[href=?]', 'https://orcid.org/0000-0001-9999-9990' + end + + assert_select '.contributors', { text: 'Contributors: Josiah Carberry' }, + "Should use name from person's profile, if linked" + assert_select '.contributors a', count: 1 do + assert_select '[href=?]', user_path(jc.user) + end + end + test 'should update material authors using structured authors' do sign_in @material.user update = @updated_material.merge(authors: [