Skip to content

Commit

Permalink
Renaming Identifiers tab to Curator Controlled (#452)
Browse files Browse the repository at this point in the history
Also only allowing collection admins and super admins access to the edit form

refs #421
  • Loading branch information
carolyncole authored Sep 29, 2022
1 parent 1938727 commit 75103bb
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 23 deletions.
13 changes: 13 additions & 0 deletions app/views/works/_curator_controlled_display.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<div class="section-title">
<!-- DOI field (mostly for legacy DSpace works) -->
<div class="field">
DOI <span class="text-muted field-hint">(enter the Digital Object Identifier, e.g. 10.80021/62qy-nj36)</span><br>
<%= @work.doi %>
</div>

<!-- ARK field (mostly for legacy DSpace works) -->
<div class="field">
ARK <span class="text-muted field-hint">(enter the core ARK identifier, e.g. ark:/88435/xyz123)</span><br>
<%= @work.ark %>
</div>
</div>
File renamed without changes.
12 changes: 8 additions & 4 deletions app/views/works/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<div class="nav flex-column nav-pills me-3" id="v-pills-tab" role="tablist" aria-orientation="vertical">
<button class="nav-link active" id="v-pills-required-tab" data-bs-toggle="pill" data-bs-target="#v-pills-required" type="button" role="tab" aria-controls="v-pills-required" aria-selected="true">Required Metadata</button>
<button class="nav-link" id="v-pills-additional-tab" data-bs-toggle="pill" data-bs-target="#v-pills-additional" type="button" role="tab" aria-controls="v-pills-additional" aria-selected="false">Additional Metadata</button>
<button class="nav-link" id="v-pills-identifier-tab" data-bs-toggle="pill" data-bs-target="#v-pills-identifier" type="button" role="tab" aria-controls="v-pills-identifier" aria-selected="false">Identifiers</button>
<button class="nav-link" id="v-pills-curator-controlled-tab" data-bs-toggle="pill" data-bs-target="#v-pills-curator-controlled" type="button" role="tab" aria-controls="v-pills-curator-controlled" aria-selected="false">Curator Controlled</button>
</div>

<div>
Expand All @@ -30,9 +30,13 @@
<%= render 'additional_form' %>
</div>

<!-- tab: identifier fields -->
<div class="tab-pane fade" id="v-pills-identifier" role="tabpanel" aria-labelledby="v-pills-identifier-tab">
<%= render 'identifier_form' %>
<!-- tab: curator controlled fields -->
<div class="tab-pane fade" id="v-pills-curator-controlled" role="tabpanel" aria-labelledby="v-pills-curator-controlled-tab">
<% if current_user.has_role?(:collection_admin, @work.collection) %>
<%= render 'curator_controlled_form' %>
<% else %>
<%= render 'curator_controlled_display' %>
<% end %>
</div>

</div>
Expand Down
4 changes: 2 additions & 2 deletions spec/system/bitklavier_form_submission_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require "rails_helper"

RSpec.describe "Form submission for migrating bitklavier", type: :system, mock_ezid_api: true, js: true do
let(:user) { FactoryBot.create(:princeton_submitter) }
let(:user) { FactoryBot.create(:research_data_moderator) }
let(:title) { "bitKlavier Grand Sample Library—Binaural Mic Image" }
let(:description) do
"The bitKlavier Grand consists of sample collections of a new Steinway D grand piano from nine different stereo mic images, with: 16 velocity layers, at every minor 3rd (starting at A0); Hammer release samples; Release resonance samples; Pedal samples. Release packages at 96k/24bit, 88.2k/24bit, 48k/24bit, 44.1k/16bit are available for various applications.
Expand Down Expand Up @@ -46,7 +46,7 @@
fill_in "publisher", with: publisher
fill_in "publication_year", with: 2021
find("#collection_id").find(:xpath, "option[1]").select_option
click_on "v-pills-identifier-tab"
click_on "v-pills-curator-controlled-tab"
fill_in "doi", with: doi
fill_in "ark", with: ark
click_on "Create"
Expand Down
52 changes: 52 additions & 0 deletions spec/system/curator_controlled_metadata_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# frozen_string_literal: true
require "rails_helper"

RSpec.describe "Curator Controlled metadata tab", type: :system do
let(:draft_work) do
resource = FactoryBot.build(:resource, creators: [PDCMetadata::Creator.new_person("Harriet", "Tubman", "1234-5678-9012-3456")])
FactoryBot.create(:draft_work, resource: resource, created_by_user_id: user.id, collection: Collection.research_data)
end

before do
stub_s3
sign_in user
visit edit_work_path(draft_work)
click_on "Curator Controlled"
end

context "As a princeton submitter" do
let(:user) { FactoryBot.create :princeton_submitter }
it "does not allow editing of curator controlled fields", js: true, mock_ezid_api: true do
# I can not edit curator fields
expect(page).to have_content("ARK")
expect(page).not_to have_css("#ark.input-text-long")

# I can edit other fields
click_on "Required Metadata"
fill_in "description", with: "The work can be changed"
click_on "Save Work"
expect(draft_work.reload.resource.description).to eq "The work can be changed"
end
end
context "As a collection admin" do
let(:user) { FactoryBot.create :research_data_moderator }

it "allows editing of curator controlled fields", js: true, mock_ezid_api: true do
expect(page).to have_css("#ark.input-text-long")
fill_in "ark", with: "http://arks.princeton.edu/ark:/88435/dsp01hx11xj13h"
click_on "Save Work"
expect(draft_work.reload.ark).to eq "ark:/88435/dsp01hx11xj13h"
end
end

context "As a super admin" do
let(:user) { FactoryBot.create :super_admin_user }

it "allows editing of curator controlled fields", js: true, mock_ezid_api: true do
expect(page).to have_css("#ark.input-text-long")
fill_in "ark", with: "http://arks.princeton.edu/ark:/88435/dsp01hx11xj13h"
click_on "Save Work"
expect(draft_work.reload.ark).to eq "ark:/88435/dsp01hx11xj13h"
end
end
end
10 changes: 5 additions & 5 deletions spec/system/migrate_submission_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require "rails_helper"

RSpec.describe "Form submission for a legacy dataset", type: :system, mock_ezid_api: true, js: true do
let(:user) { FactoryBot.create(:princeton_submitter) }
let(:user) { FactoryBot.create(:research_data_moderator) }
let(:doi) { "10.34770/123-abc" }
let(:title) { "Sowing the Seeds for More Usable Web Archives: A Usability Study of Archive-It" }
let(:contributors) do
Expand Down Expand Up @@ -51,7 +51,7 @@
fill_in "family_name_1", with: "Abrams"
fill_in "description", with: description
find("#rights_identifier").find(:xpath, "option[2]").select_option
click_on "Identifiers"
click_on "Curator Controlled"
fill_in "doi", with: doi
fill_in "ark", with: ark
click_on "Additional Metadata"
Expand Down Expand Up @@ -80,15 +80,15 @@
fill_in "family_name_1", with: "Abrams"
fill_in "description", with: description
find("#rights_identifier").find(:xpath, "option[2]").select_option
click_on "Identifiers"
click_on "Curator Controlled"
fill_in "doi", with: "abc123"
click_on "Create"
expect(page).to have_content "Invalid DOI: does not match format"
click_on "Identifiers"
click_on "Curator Controlled"
fill_in "doi", with: "10.34770/123-ab"
click_on "Create"
expect(page).to have_content "Invalid DOI: can not verify it's authenticity"
click_on "Identifiers"
click_on "Curator Controlled"
fill_in "doi", with: doi
fill_in "ark", with: ark
click_on "Additional Metadata"
Expand Down
12 changes: 0 additions & 12 deletions spec/system/work_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,6 @@
expect(page.html.include?("By initiating this new submission, we have reserved a draft DOI for your use")).to be true
end

it "Handles ARK URLs in the ARK field", js: true, mock_ezid_api: true do
resource = FactoryBot.build(:resource, creators: [PDCMetadata::Creator.new_person("Harriet", "Tubman", "1234-5678-9012-3456")])
work = FactoryBot.create(:draft_work, resource: resource)
user = work.created_by_user
sign_in user
visit edit_work_path(work)
click_on "Identifiers"
fill_in "ark", with: "http://arks.princeton.edu/ark:/88435/dsp01hx11xj13h"
click_on "Save Work"
expect(work.reload.ark).to eq "ark:/88435/dsp01hx11xj13h"
end

it "Handles Rights field", js: true do
resource = FactoryBot.build(:resource, creators: [PDCMetadata::Creator.new_person("Harriet", "Tubman", "1234-5678-9012-3456")])
work = FactoryBot.create(:draft_work, resource: resource)
Expand Down

0 comments on commit 75103bb

Please sign in to comment.