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 fcc91b4 commit 29d740a
Showing 1 changed file with 55 additions and 14 deletions.
69 changes: 55 additions & 14 deletions spec/requests/works_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
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
Expand All @@ -84,24 +83,66 @@
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
context "when authenticated as a super admin user" do
let(:user) { FactoryBot.create(:super_admin_user) }

expect(work.metadata).to be_a(Hash)
expect(work.metadata).to include("titles")
titles = work.metadata["titles"]
expect(titles.length).to eq(2)
it "updates the title" do
expect(response.status).to eq(302)
work.reload

subtitle = titles.last
expect(subtitle).to be_a(Hash)
expect(subtitle).to include("title" => "the subtitle")
expect(subtitle).to include("title_type" => "Subtitle")
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

context "when authenticated as the submitter of the Work" do
let(:user) { work.created_by_user }

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

context "when authenticated as the curator for the Work" do
let(:user) do
FactoryBot.create :user, collections_to_admin: [collection]
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
Expand Down

0 comments on commit 29d740a

Please sign in to comment.