Skip to content

Commit d24160a

Browse files
committed
Handle blank orcid in orcid_url
1 parent b339fbd commit d24160a

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

app/models/profile.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def full_name
2626
end
2727

2828
def orcid_url
29+
return nil if orcid.blank?
2930
"#{OrcidValidator::ORCID_PREFIX}#{orcid}"
3031
end
3132

test/models/profile_test.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,4 +134,10 @@ class ProfileTest < ActiveSupport::TestCase
134134
assert profile.orcid.present?
135135
assert profile.orcid_authenticated
136136
end
137+
138+
test 'orcid_url' do
139+
assert_nil Profile.new.orcid_url
140+
assert_nil Profile.new(orcid: '').orcid_url
141+
assert_equal 'https://orcid.org/0009-0006-0987-5702', Profile.new(orcid: '0009-0006-0987-5702').orcid_url
142+
end
137143
end

0 commit comments

Comments
 (0)