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

Commit d8e27ed

Browse files
Calculate extent
1 parent 21b7d41 commit d8e27ed

File tree

9 files changed

+168
-23
lines changed

9 files changed

+168
-23
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'
Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
Feature: Calculate extent of an accession
1+
Feature: Calculate Extent of an accession
22
Background:
33
Given an administrator user is logged in
44
And an Accession has been created
55
And the Accession is opened in edit mode
66
Scenario: Extent sub record is added to the Accession
7-
When the user clicks on 'More' button on the toolbar
8-
And the user selects 'Calculate Extent'
9-
And the user fills in 'Portion'
10-
And the user fills in 'Number'
11-
And the user fills in 'Type'
12-
And the user clicks on 'Create Extent'
7+
When the user clicks on 'More'
8+
And the user clicks on 'Calculate Extent'
9+
And the user selects 'Whole' from 'Portion' in the modal
10+
And the user fills in 'Number' with '123456789' in the modal
11+
And the user selects 'Cassettes' from 'Type' in the modal
12+
And the user clicks on 'Create Extent' in the modal
1313
And the user clicks on 'Save'
14-
Then a new Extent sub-record should be added to the accession record
15-
And the 'Accession' updated message is displayed
14+
Then the 'Accession' updated message is displayed
15+
And a new Extent is added to the Accession with the following values
16+
| Portion | Whole |
17+
| Number | 123456789 |
18+
| Type | Cassettes |

staff_features/accessions/accession_event_create.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Feature: Accession Event Create
1313
And the user fills in 'Begin' with '2020-01-01' in the 'Event Date/Time' form
1414
And the user links an Agent
1515
And the user clicks on 'Save'
16-
Then the 'Event Created' message is displayed
16+
Then the 'Event' created message is displayed
1717
Scenario: Accession Event is not created due to missing required fields
1818
Given the New Event page is open for an Accession
1919
When the user selects 'Single' from 'Type' in the 'Event Date/Time' form

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: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,78 @@
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_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+
@accession_number_of_extents = 1
49+
50+
click_on 'Add Agent Link'
51+
select 'Creator', from: 'accession_linked_agents__0__role_'
52+
fill_in 'accession_linked_agents__0__title_', with: "Accession #{@uuid} Agent Title"
53+
fill_in 'accession_linked_agents__0__relator_', with: 'annotator'
54+
dropdown_items = all('.typeahead.typeahead-long.dropdown-menu')
55+
dropdown_items.first.click
56+
fill_in 'token-input-accession_linked_agents__0__ref_', with: 'test_agent'
57+
dropdown_items = all('li.token-input-dropdown-item2')
58+
dropdown_items.first.click
59+
60+
click_on 'Add Subject'
61+
fill_in 'token-input-accession_subjects__0__ref_', with: 'test_subject'
62+
dropdown_items = all('li.token-input-dropdown-item2')
63+
dropdown_items.first.click
64+
65+
click_on 'Add Rights Statement'
66+
select 'Copyright', from: 'accession_rights_statements__0__rights_type_'
67+
fill_in 'accession_rights_statements__0__jurisdiction_', with: 'andorra'
68+
dropdown_items = all('.typeahead.typeahead-long.dropdown-menu')
69+
dropdown_items.first.click
70+
fill_in 'accession_rights_statements__0__start_date_', with: ORIGINAL_ACCESSION_RIGHTS_STATEMENT_START_DATE
71+
72+
click_on 'Save'
73+
expect(page).to have_text "Accession Accession Title #{@uuid} created"
74+
end
75+
376
Given 'the Accession is opened in edit mode' do
477
visit "#{STAFF_URL}/accessions"
578

@@ -20,3 +93,16 @@
2093

2194
click_on 'Edit'
2295
end
96+
97+
Then 'a new Extent is added to the Accession with the following values' do |form_values_table|
98+
extents = all('#accession_extents_ .subrecord-form-list li')
99+
100+
expect(extents.length).to eq @accession_number_of_extents + 1
101+
102+
created_extend = extents.last
103+
104+
form_values_hash = form_values_table.rows_hash
105+
form_values_hash.each do |field, value|
106+
expect(created_extend.find_field(field).value).to eq value.downcase.gsub(' ', '_')
107+
end
108+
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

staff_features/shared/step_definitions.rb

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
ensure_test_repository_exists
1111
ensure_test_user_exists
1212
ensure_test_agent_exists
13+
ensure_test_subject_exists
14+
ensure_test_classification_exists
1315
end
1416

1517
Given 'an archivist user is logged in' do
@@ -20,6 +22,12 @@
2022
click_on_string string
2123
end
2224

25+
When 'the user clicks on {string} in the modal' do |string|
26+
within '.modal-content' do
27+
click_on_string string
28+
end
29+
end
30+
2331
When 'the user clicks on {string} in the dropdown menu' do |string|
2432
within '.dropdown-menu' do |dropdown_menu|
2533
elements = dropdown_menu.all(:xpath, "//*[contains(text(), '#{string}')]")
@@ -42,15 +50,21 @@
4250
When 'the user fills in {string}' do |label|
4351
@uuid = SecureRandom.uuid if @uuid.nil?
4452

45-
fill_in label, with: @uuid
53+
fill_in label, with: @uuid, match: :first
4654
end
4755

4856
When 'the user clears the {string} field' do |label|
49-
fill_in label, with: ''
57+
fill_in label, with: '', match: :first
5058
end
5159

5260
When 'the user fills in {string} with {string}' do |label, value|
53-
fill_in label, with: value
61+
fill_in label, with: value, match: :first
62+
end
63+
64+
When 'the user fills in {string} with {string} in the modal' do |label, value|
65+
within '.modal-content' do
66+
fill_in label, with: value, match: :first
67+
end
5468
end
5569

5670
When 'the user fills in {string} with {string} in the {string} form' do |label, value, form_title|
@@ -64,7 +78,13 @@
6478
end
6579

6680
When 'the user selects {string} from {string}' do |option, label|
67-
select option, from: label
81+
select option, from: label, match: :first
82+
end
83+
84+
When 'the user selects {string} from {string} in the modal' do |option, label|
85+
within '.modal-content' do
86+
select option, from: label
87+
end
6888
end
6989

7090
When 'the user selects {string} from {string} in the {string} form' do |option, label, form_title|
@@ -78,15 +98,15 @@
7898
end
7999

80100
When 'the user checks {string}' do |label|
81-
check label
101+
check label, match: :first
82102
end
83103

84104
When 'the user changes the {string} field to {string}' do |field, value|
85-
fill_in field, with: value
105+
fill_in field, with: value, match: :first
86106
end
87107

88108
When 'the user changes the {string} field' do |field|
89-
fill_in field, with: SecureRandom.uuid
109+
fill_in field, with: SecureRandom.uuid, match: :first
90110
end
91111

92112
Then('the {string} created message is displayed') do |string|

0 commit comments

Comments
 (0)