Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/helpers/materials_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
22 changes: 22 additions & 0 deletions test/controllers/materials_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down
Loading