Skip to content

Commit

Permalink
Merge pull request #3865 from nulib/4530-duplicate-arks
Browse files Browse the repository at this point in the history
Don't mint a new ark for a work that already has one
  • Loading branch information
bmquinn authored Mar 5, 2024
2 parents ea57ca3 + 905a45b commit 33b5b69
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/lib/meadow/utils/arks.ex
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ defmodule Meadow.Arks do
{:noop,
%Work{...}}
"""
def mint_ark(%Work{descriptive_metadata: %{ark: ark}} = work, _)
def mint_ark(%Work{descriptive_metadata: %{ark: ark}} = work)
when not is_nil(ark) do
{:noop, work}
end
Expand Down
7 changes: 7 additions & 0 deletions app/test/meadow/arks_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ defmodule Meadow.ArksTest do
use Meadow.DataCase

alias Meadow.{Ark, Arks}
alias Meadow.Data.Schemas.Work
alias Meadow.Data.Works
alias Meadow.Utils.ArkClient.MockServer

Expand All @@ -23,6 +24,12 @@ defmodule Meadow.ArksTest do
assert Arks.mint_ark!(work)
end
end)

@tag work_type: "IMAGE"
test "mint_ark/1 does not mint a new ark for a work that already has an ark", %{work: work} do
assert {:ok, %Work{descriptive_metadata: %{ark: ark}} = work} = Arks.mint_ark(work)
assert {:noop, %Work{descriptive_metadata: %{ark: ^ark}}} = Arks.mint_ark(work)
end
end

describe "update_ark_metadata/1" do
Expand Down
6 changes: 2 additions & 4 deletions app/test/meadow/data/csv/export_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,8 @@ defmodule Meadow.Data.CSV.ExportTest do
assert Enum.member?(header, "collection_id")
assert Map.get(sample_record, "collection_id") == collection.id

with shoulder <- Meadow.Config.ark_config() |> Map.get(:default_shoulder) do
assert Enum.member?(header, "ark")
assert Map.get(sample_record, "ark") |> String.starts_with?(shoulder)
end
assert Enum.member?(header, "ark")
assert Map.get(sample_record, "ark") |> String.starts_with?("ark:/")

@sample_record
|> Enum.each(fn {field, expected_value} ->
Expand Down

0 comments on commit 33b5b69

Please sign in to comment.