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
2 changes: 1 addition & 1 deletion lib/seek/doi/acts_as_doi_mintable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def mint_doi
return false
end

if creators.empty?
if (respond_to?(:assets_creators) ? assets_creators : creators).empty?
errors.add(:base, "At least one creator is required. To add, go to Actions -> Manage #{self.class.model_name.human}.")
return false
end
Expand Down
19 changes: 19 additions & 0 deletions test/integration/doi_minting_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ class DoiMintingTest < ActionDispatch::IntegrationTest
asset.creators = []
asset.save!
assert_empty asset.creators
assert_empty asset.assets_creators

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

test 'do not show error if non-SEEK creator present' do
mock_datacite_request
asset = FactoryBot.create(:workflow, policy: FactoryBot.create(:public_policy))
assert asset.is_published?
assert asset.can_manage?

asset.creators = []
asset.assets_creators.create!(given_name: 'Julia', family_name: 'Jones', orcid: 'https://orcid.org/0000-0001-8172-8981')
asset.save!
assert_empty asset.creators
assert_not_empty asset.assets_creators

post "/workflows/#{asset.id}/mint_doi"
assert_redirected_to polymorphic_path(asset, version: asset.version)
assert_not_nil flash[:notice]
assert AssetDoiLog.was_doi_minted_for?(asset.class.name, asset.id, asset.version)
end

test 'handle error when mint_doi' do
mock_datacite_request
DOIABLE_ASSETS.each do |type|
Expand Down
Loading