Skip to content
This repository was archived by the owner on Oct 14, 2025. It is now read-only.

Commit 5c9ea37

Browse files
Accession spawn Digital Object
1 parent 21c8279 commit 5c9ea37

File tree

10 files changed

+281
-36
lines changed

10 files changed

+281
-36
lines changed

.rubocop.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,18 @@ Metrics/AbcSize:
99
Metrics/MethodLength:
1010
Max: 50
1111

12+
Metrics/BlockLength:
13+
Max: 90
14+
1215
Layout/LineLength:
1316
Max: 180
1417

1518
Layout/ElseAlignment:
1619
Enabled: false
1720

21+
Layout/LineLength:
22+
Max: 174
23+
1824
Style/ConditionalAssignment:
1925
Enabled: false
2026

helpers/helpers.rb

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,39 @@ def ensure_test_agent_exists
123123
end
124124
end
125125

126+
def ensure_test_subject_exists
127+
visit STAFF_URL
128+
129+
fill_in 'global-search-box', with: 'test_subject'
130+
find('#global-search-button').click
131+
132+
begin
133+
find 'tr', text: 'test_subject'
134+
rescue Capybara::ElementNotFound
135+
visit "#{STAFF_URL}/subjects/new"
136+
select 'Art & Architecture Thesaurus', from: 'subject_source_'
137+
fill_in 'subject_terms__0__term_', with: 'test_subject_term'
138+
select 'Cultural context', from: 'subject_terms__0__term_type_'
139+
click_on 'Save'
140+
end
141+
end
142+
143+
def ensure_test_classification_exists
144+
visit STAFF_URL
145+
146+
fill_in 'global-search-box', with: 'test_classification'
147+
find('#global-search-button').click
148+
149+
begin
150+
find 'tr', text: 'test_classification'
151+
rescue Capybara::ElementNotFound
152+
visit "#{STAFF_URL}/classifications/new"
153+
fill_in 'classification_identifier_', with: 'test_classification'
154+
fill_in 'classification_title_', with: 'test_classification'
155+
click_on 'Save'
156+
end
157+
end
158+
126159
def find_user_table_row_in_manage_user_access_page(username)
127160
loop do
128161
begin

helpers/original_values.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# frozen_string_literal: true
22

33
ORIGINAL_ACCESSION_DATE = '2000-01-01'
4+
ORIGINAL_ACCESSION_RIGHTS_STATEMENT_START_DATE = '2000-01-01'

staff_features/accessions/accession_edit.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Feature: Accession Edit
2727
Then the Accession Title field has the original value
2828
Scenario: Accession update fails due to invalid date input
2929
Given the Accession is opened in edit mode
30-
When the user fills in 'Date' with '2024-13-15'
30+
When the user fills in 'Accession Date' with '2024-13-15'
3131
And the user clicks on 'Save'
3232
Then the following error message is displayed
3333
| Accession Date - Not a valid date |
Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,29 @@
1-
Feature: Resource Spawn from an Accession
1+
Feature: Accession Spawn Resource
22
Background:
3-
Given an administrator user is logged in
4-
And an Accession has been created
5-
And the Accession with the title "Original Accession Title" is opened in edit mode
6-
7-
Scenario: Resource Spawn from Accession page is opened
8-
When the user clicks on 'Spawn'
9-
And the user clicks on 'Resource' in the spawn dropdown menu
10-
Then the New Resource page is displayed
11-
And the following info message is displayed
12-
| A new Resource has been spawned from Accession "Original Accession Title". This record is unsaved. You must click Save for the record to be created in the system. |
13-
14-
Scenario: Original Accession record is linked to the spawned Resource
15-
Given the user is on the New Resource page spawned from the original Accession
16-
When the user click on 'Related Accessions' at the sidebar
17-
Then the 'Related Accessions' form is displayed
18-
And the original Accession Title is filled in
19-
20-
Scenario: Backing out of creating a resource record
21-
Given the user is on the New Resource page spawned from the original Accession
22-
When the user clicks on the 'Return to Accession' button
23-
Then the original Accession Record page is displayed
3+
Given an administrator user is logged in
4+
And an Accession has been created
5+
And the Accession is opened in edit mode
6+
Scenario: Resource form is prefilled with Accession data
7+
When the user clicks on 'Spawn'
8+
And the user clicks on 'Resource' in the spawn dropdown menu
9+
Then the New Resource page is displayed
10+
And the Resource has been spawned from Accession info message is displayed
11+
And the Resource is linked to the Accession in the Related Accessions form
12+
And the Resource title is filled in with the Accession Title
13+
And the Resource publish is set from the Accession publish
14+
And the Resource notes are set from the Accession Content Description and Condition Description
15+
And the following Resource forms have the same values as the Accession
16+
| Agent Links |
17+
| Related Accessions |
18+
| Subjects |
19+
| Languages |
20+
| Dates |
21+
| Extents |
22+
| Rights Statements |
23+
| Metadata Rights Declarations |
24+
| Classifications |
25+
Scenario: Return to Accession
26+
When the user clicks on 'Spawn'
27+
And the user clicks on 'Resource' in the spawn dropdown menu
28+
And the user clicks on 'Return to Accession'
29+
Then the Accession page is displayed

staff_features/accessions/step_definitions/accession_edit.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,11 @@
122122
end
123123

124124
When 'User A changes the {string} field' do |field|
125-
fill_in field, with: SecureRandom.uuid
125+
fill_in field, with: SecureRandom.uuid, match: :first
126126
end
127127

128128
When 'User B changes the {string} field' do |field|
129-
@user_b_session.fill_in field, with: SecureRandom.uuid
129+
@user_b_session.fill_in field, with: SecureRandom.uuid, match: :first
130130
end
131131

132132
When 'User B clicks on {string}' do |string|

staff_features/accessions/step_definitions/accession_shared.rb

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,94 @@
11
# frozen_string_literal: true
22

3+
Given 'an Accession has been created' do
4+
visit "#{STAFF_URL}/accessions/new"
5+
6+
fill_in 'accession_id_0_', with: "Accession #{@uuid}"
7+
fill_in 'Title', with: "Accession Title #{@uuid}"
8+
fill_in 'Accession Date', with: ORIGINAL_ACCESSION_DATE
9+
check 'Publish?'
10+
11+
fill_in 'accession_content_description_', with: "Content Description #{@uuid}"
12+
fill_in 'accession_condition_description_', with: "Condition Description #{@uuid}"
13+
fill_in 'accession_disposition_', with: "Disposition #{@uuid}"
14+
fill_in 'accession_inventory_', with: "Inventory #{@uuid}"
15+
fill_in 'accession_provenance_', with: "Provenance #{@uuid}"
16+
fill_in 'accession_retention_rule_', with: "Retention Rule #{@uuid}"
17+
fill_in 'accession_general_note_', with: "General Note #{@uuid}"
18+
select 'Deposit', from: 'accession_acquisition_type_'
19+
select 'Collection', from: 'accession_resource_type_'
20+
21+
fill_in 'accession_language_', with: 'english'
22+
dropdown_items = all('.typeahead.typeahead-long.dropdown-menu')
23+
dropdown_items.first.click
24+
fill_in 'accession_script_', with: 'adlam'
25+
dropdown_items = all('.typeahead.typeahead-long.dropdown-menu')
26+
dropdown_items.first.click
27+
find('#accession_restrictions_apply_').check
28+
find('#accession_access_restrictions_').check
29+
fill_in 'accession_access_restrictions_note_', with: "Access Restrictions Note #{@uuid}"
30+
find('#accession_use_restrictions_').check
31+
fill_in 'accession_use_restrictions_note_', with: "Use Restrictions Note #{@uuid}"
32+
33+
click_on 'Add Language'
34+
fill_in 'Language', with: 'English'
35+
dropdown_items = all('.typeahead.typeahead-long.dropdown-menu')
36+
dropdown_items.first.click
37+
fill_in 'Script', with: 'adlam'
38+
dropdown_items = all('.typeahead.typeahead-long.dropdown-menu')
39+
dropdown_items.first.click
40+
41+
click_on 'Add Date'
42+
select 'Single', from: 'accession_dates__0__date_type_'
43+
fill_in 'accession_dates__0__begin_', with: ORIGINAL_ACCESSION_DATE
44+
45+
click_on 'Add Extent'
46+
fill_in 'Number', with: @uuid
47+
select 'Cassettes', from: 'accession_extents__0__extent_type_'
48+
49+
click_on 'Add Agent Link'
50+
select 'Creator', from: 'accession_linked_agents__0__role_'
51+
fill_in 'accession_linked_agents__0__title_', with: "Accession #{@uuid} Agent Title"
52+
fill_in 'accession_linked_agents__0__relator_', with: 'annotator'
53+
dropdown_items = all('.typeahead.typeahead-long.dropdown-menu')
54+
dropdown_items.first.click
55+
fill_in 'token-input-accession_linked_agents__0__ref_', with: 'test_agent'
56+
dropdown_items = all('li.token-input-dropdown-item2')
57+
dropdown_items.first.click
58+
59+
click_on 'Add Subject'
60+
fill_in 'token-input-accession_subjects__0__ref_', with: 'test_subject'
61+
dropdown_items = all('li.token-input-dropdown-item2')
62+
dropdown_items.first.click
63+
64+
click_on 'Add Rights Statement'
65+
select 'Copyright', from: 'accession_rights_statements__0__rights_type_'
66+
fill_in 'accession_rights_statements__0__jurisdiction_', with: 'andorra'
67+
dropdown_items = all('.typeahead.typeahead-long.dropdown-menu')
68+
dropdown_items.first.click
69+
fill_in 'accession_rights_statements__0__start_date_', with: ORIGINAL_ACCESSION_RIGHTS_STATEMENT_START_DATE
70+
71+
click_on 'Add Metadata Rights Declaration'
72+
select 'This record is made available under an Universal 1.0 Public Domain Dedication Creative Commons license.',
73+
from: 'accession_metadata_rights_declarations__0__license_'
74+
fill_in 'accession_metadata_rights_declarations__0__descriptive_note_', with: "Descriptive Note #{@uuid}"
75+
fill_in 'accession_metadata_rights_declarations__0__file_uri_', with: "file-uri-#{@uuid}"
76+
select 'onLoad', from: 'accession_metadata_rights_declarations__0__file_version_xlink_actuate_attribute_'
77+
select 'embed', from: 'accession_metadata_rights_declarations__0__file_version_xlink_show_attribute_'
78+
fill_in 'accession_metadata_rights_declarations__0__xlink_title_attribute_', with: "Xlink Title Attribute #{@uuid}"
79+
fill_in 'accession_metadata_rights_declarations__0__xlink_role_attribute_', with: "Xlink Role Attribute #{@uuid}"
80+
fill_in 'accession_metadata_rights_declarations__0__xlink_arcrole_attribute_', with: "Xlink Arcrole Attribute #{@uuid}"
81+
fill_in 'accession_metadata_rights_declarations__0__last_verified_date_', with: '2000-01-01'
82+
83+
click_on 'Add Classification'
84+
fill_in 'token-input-accession_classifications__0__ref_', with: 'test_classification'
85+
dropdown_items = all('li.token-input-dropdown-item2')
86+
dropdown_items.first.click
87+
88+
click_on 'Save'
89+
expect(page).to have_text "Accession Accession Title #{@uuid} created"
90+
end
91+
392
Given 'the Accession is opened in edit mode' do
493
visit "#{STAFF_URL}/accessions"
594

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# frozen_string_literal: true
2+
3+
Then 'the New Resource page is displayed' do
4+
uri = current_url.split('/')
5+
6+
last_part = uri.pop
7+
last_part_split = last_part.split('?')
8+
action = last_part_split.pop if last_part_split.length > 1
9+
action = last_part_split[0] if last_part_split.length == 1
10+
11+
entity = uri.pop
12+
13+
expect(entity).to eq 'resources'
14+
expect(action).to eq 'new'
15+
end
16+
17+
Then 'the Resource is linked to the Accession in the Related Accessions form' do
18+
section_title = find('h3', text: 'Related Accession')
19+
section = section_title.ancestor('section')
20+
expect(section[:id]).to_not eq nil
21+
22+
related_accessions_elements = section.all('.subrecord-form-fields')
23+
expect(related_accessions_elements.length).to eq 1
24+
related_accession = related_accessions_elements[0].find('.accession')
25+
26+
expect(related_accession[:'data-content']).to include "accessions/#{@accession_id}"
27+
end
28+
29+
Then 'the Resource has been spawned from Accession info message is displayed' do
30+
message = "A new Resource has been spawned from Accession Accession Title #{@uuid}. This record is unsaved. You must click Save for the record to be created in the system."
31+
32+
expect(page).to have_text message
33+
end
34+
35+
Then 'the Accession page is displayed' do
36+
expect(current_url).to include "accessions/#{@accession_id}"
37+
end
38+
39+
Then 'the Resource title is filled in with the Accession Title' do
40+
expect(find('#resource_title_').value).to eq "Accession Title #{@uuid}"
41+
end
42+
43+
Then 'the Resource publish is set from the Accession publish' do
44+
expect(find('#resource_publish_').checked?).to eq true
45+
end
46+
47+
Then 'the Resource notes are set from the Accession Content Description and Condition Description' do
48+
notes = all('#resource_notes_ .subrecord-form-wrapper')
49+
expect(notes.length).to eq 2
50+
51+
notes[0].click
52+
expect(find('#resource_notes__0__label_').value).to eq 'Content Description'
53+
expect(find('#resource_notes__0__type_').value).to eq 'scopecontent'
54+
expect(find('#resource_notes__0__subnotes__0_ textarea', match: :first, visible: false).value).to eq "Content Description #{@uuid}"
55+
56+
notes[1].click
57+
expect(find('#resource_notes__1__label_').value).to eq 'Condition Description'
58+
expect(find('#resource_notes__1__type_').value).to eq 'physdesc'
59+
expect(find('#resource_notes__1__content__0_ textarea', match: :first, visible: false).value).to eq "Condition Description #{@uuid}"
60+
end
61+
62+
Then 'the following Resource forms have the same values as the Accession' do |linked_record_forms|
63+
linked_record_forms.raw.each do |form_title|
64+
form_title = form_title[0]
65+
66+
section_title = find('h3', text: form_title)
67+
section = section_title.ancestor('section')
68+
expect(section[:id]).to_not eq nil
69+
70+
case form_title
71+
when 'Agent Links'
72+
expect(find('#resource_linked_agents__0__role_').value).to eq 'creator'
73+
expect(find('#resource_linked_agents__0__title_').value).to eq "Accession #{@uuid} Agent Title"
74+
expect(find('#resource_linked_agents__0__relator_').value).to eq 'Annotator'
75+
expect(find('#resource_linked_agents__0__ref__combobox .token-input-token').text).to include 'test_agent'
76+
when 'Related Accessions'
77+
expect(find('#resource_related_accessions__0_ .token-input-token').text).to include "Accession #{@uuid}: Accession Title #{@uuid}"
78+
when 'Subjects'
79+
expect(find('#resource_subjects__0_ .token-input-token').text).to include 'test_subject_term'
80+
when 'Languages'
81+
expect(find('#resource_lang_materials__0__language_and_script__language_').value).to eq 'English'
82+
expect(find('#resource_lang_materials__0__language_and_script__script_').value).to eq 'Adlam'
83+
when 'Dates'
84+
expect(find('#resource_dates__0__label_').value).to eq 'creation'
85+
expect(find('#resource_dates__0__date_type_').value).to eq 'single'
86+
expect(find('#resource_dates__0__begin_').value).to eq ORIGINAL_ACCESSION_DATE
87+
when 'Extents'
88+
expect(find('#resource_extents__0__portion_').value).to eq 'whole'
89+
expect(find('#resource_extents__0__number_').value).to eq @uuid
90+
expect(find('#resource_extents__0__extent_type_').value).to eq 'cassettes'
91+
when 'Rights Statements'
92+
expect(find('#resource_rights_statements__0__rights_type_').value).to eq 'copyright'
93+
expect(find('#resource_rights_statements__0__status_').value).to eq 'copyrighted'
94+
expect(find('#resource_rights_statements__0__jurisdiction_').value).to eq 'Andorra'
95+
expect(find('#resource_rights_statements__0__start_date_').value).to eq ORIGINAL_ACCESSION_DATE
96+
when 'Metadata Rights Declarations'
97+
expect(find('#resource_metadata_rights_declarations__0__license_').value).to eq 'public_domain'
98+
expect(find('#resource_metadata_rights_declarations__0__descriptive_note_').value).to eq "Descriptive Note #{@uuid}"
99+
expect(find('#resource_metadata_rights_declarations__0__descriptive_note_').value).to eq "Descriptive Note #{@uuid}"
100+
expect(find('#resource_metadata_rights_declarations__0__file_uri_').value).to eq "file-uri-#{@uuid}"
101+
expect(find('#resource_metadata_rights_declarations__0__file_version_xlink_actuate_attribute_').value).to eq 'onLoad'
102+
expect(find('#resource_metadata_rights_declarations__0__file_version_xlink_show_attribute_').value).to eq 'embed'
103+
expect(find('#resource_metadata_rights_declarations__0__xlink_role_attribute_').value).to eq "Xlink Role Attribute #{@uuid}"
104+
expect(find('#resource_metadata_rights_declarations__0__xlink_arcrole_attribute_').value).to eq "Xlink Arcrole Attribute #{@uuid}"
105+
expect(find('#resource_metadata_rights_declarations__0__last_verified_date_').value).to eq '2000-01-01 00:00:00 UTC'
106+
when 'Classifications'
107+
expect(find('#resource_classifications__0__ref__combobox .token-input-token').text).to include 'test_classification'
108+
else
109+
raise "Invalid form provided: #{form_title}"
110+
end
111+
end
112+
end

staff_features/accessions/step_definitions/accessions_search.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
# frozen_string_literal: true
22

3-
Given 'an Accession has been created' do
4-
create_accession(@uuid)
5-
end
6-
73
Then 'the Accession is in the search results' do
84
expect(page).to have_css('tr', text: @uuid)
95
end

0 commit comments

Comments
 (0)