Skip to content

Commit cf3def6

Browse files
authored
Merge pull request #2398 from seek4science/allow-doi-if-non-seek-creators
Ensure DOI can be minted when only non-SEEK creators are present
2 parents 63dcb18 + 13e4a1b commit cf3def6

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

lib/seek/doi/acts_as_doi_mintable.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def mint_doi
4343
return false
4444
end
4545

46-
if creators.empty?
46+
if (respond_to?(:assets_creators) ? assets_creators : creators).empty?
4747
errors.add(:base, "At least one creator is required. To add, go to Actions -> Manage #{self.class.model_name.human}.")
4848
return false
4949
end

test/integration/doi_minting_test.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ class DoiMintingTest < ActionDispatch::IntegrationTest
112112
asset.creators = []
113113
asset.save!
114114
assert_empty asset.creators
115+
assert_empty asset.assets_creators
115116

116117
post "/workflows/#{asset.id}/mint_doi"
117118
assert_redirected_to polymorphic_path(asset, version: asset.version)
@@ -120,6 +121,24 @@ class DoiMintingTest < ActionDispatch::IntegrationTest
120121
refute AssetDoiLog.was_doi_minted_for?(asset.class.name, asset.id, asset.version)
121122
end
122123

124+
test 'do not show error if non-SEEK creator present' do
125+
mock_datacite_request
126+
asset = FactoryBot.create(:workflow, policy: FactoryBot.create(:public_policy))
127+
assert asset.is_published?
128+
assert asset.can_manage?
129+
130+
asset.creators = []
131+
asset.assets_creators.create!(given_name: 'Julia', family_name: 'Jones', orcid: 'https://orcid.org/0000-0001-8172-8981')
132+
asset.save!
133+
assert_empty asset.creators
134+
assert_not_empty asset.assets_creators
135+
136+
post "/workflows/#{asset.id}/mint_doi"
137+
assert_redirected_to polymorphic_path(asset, version: asset.version)
138+
assert_not_nil flash[:notice]
139+
assert AssetDoiLog.was_doi_minted_for?(asset.class.name, asset.id, asset.version)
140+
end
141+
123142
test 'handle error when mint_doi' do
124143
mock_datacite_request
125144
DOIABLE_ASSETS.each do |type|

0 commit comments

Comments
 (0)