Skip to content

Commit

Permalink
[wip]
Browse files Browse the repository at this point in the history
  • Loading branch information
jrgriffiniii committed Jan 17, 2023
1 parent 26af9ff commit fcc91b4
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions spec/requests/works_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,58 @@
expect { get work_url(work) }.to raise_error(Work::InvalidCollectionError, "The Work test-id does not belong to any Collection")
end
end

context "when the work has been approved" do
let(:work) { FactoryBot.create(:approved_work) }
let(:collection) { work.collection }
let(:user) { FactoryBot.create(:super_admin_user) }

context "when appending a second title" do
let(:params) do
{
id: work.id,
title_main: work.title,
collection_id: collection.id,
new_title_1: "the subtitle",
new_title_type_1: "Subtitle",
existing_title_count: "1",
new_title_count: "1",
given_name_1: "Toni",
family_name_1: "Morrison",
sequence_1: "1",
given_name_2: "Sonia",
family_name_2: "Sotomayor",
sequence_2: "1",
orcid_2: "1234-1234-1234-1234",
creator_count: "1",
new_creator_count: "1",
rights_identifier: "CC BY",
description: "a new description"
}
end

before do
# work.update_curator(user.id, user)
# collection.add_administrator(admin, user)
patch work_url(work), params: params
end

it "updates the title" do
expect(response.status).to eq(302)
work.reload

expect(work.metadata).to be_a(Hash)
expect(work.metadata).to include("titles")
titles = work.metadata["titles"]
expect(titles.length).to eq(2)

subtitle = titles.last
expect(subtitle).to be_a(Hash)
expect(subtitle).to include("title" => "the subtitle")
expect(subtitle).to include("title_type" => "Subtitle")
end
end
end
end
end
end

0 comments on commit fcc91b4

Please sign in to comment.