Skip to content

Commit b1102e8

Browse files
authored
Digital Object file versions (#64)
1 parent e4d8523 commit b1102e8

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Feature: Digital Object File versions
2+
Background:
3+
Given an administrator user is logged in
4+
And a Digital Object has been created
5+
And the Digital Object is opened in the edit mode
6+
Scenario: Add a single File Version with required fields
7+
When the user clicks on 'Add File Version' in the 'File Versions' form
8+
And the user fills in 'File URI' with 'http://example.com/file.pdf'
9+
And the user clicks on 'Save Digital Object'
10+
Then the 'Digital Object' updated message is displayed
11+
And a new File Version is added to the Digital Object with the following values
12+
| File URI | http://example.com/file.pdf |
13+
Scenario: Remove a File Version from a Digital Object
14+
Given the user has added a File Version to the Digital Object with the following values
15+
| File URI | http://example.com/file.pdf |
16+
When the user clicks on remove icon in the 'File Version' form
17+
And the user clicks on 'Confirm Removal'
18+
And the user clicks on 'Save Digital Object'
19+
And the 'Digital Object' updated message is displayed
20+
Then the File Version is removed from the Digital Object

staff_features/digital_objects/step_definitions/digital_object_shared.rb

+35
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
select 'Single', from: 'digital_object_dates__0__date_type_'
1111
fill_in 'digital_object_dates__0__begin_', with: '2000-01-01'
1212

13+
@digital_object_number_of_file_versions = 0
14+
1315
click_on 'Save'
1416

1517
wait_for_ajax
@@ -100,3 +102,36 @@
100102

101103
expect(page).to have_field('Identifier', with: "Digital Object Identifier #{@uuid}")
102104
end
105+
106+
Then 'a new File Version is added to the Digital Object with the following values' do |form_values_table|
107+
subrecords = all('#digital_object_file_versions_ .subrecord-form-list li')
108+
109+
expect(subrecords.length).to eq @digital_object_number_of_file_versions + 1
110+
111+
created_subrecord = subrecords.last
112+
113+
form_values_hash = form_values_table.rows_hash
114+
form_values_hash.each do |field, value|
115+
expect(created_subrecord.find_field(field).value).to eq value.downcase.gsub(' ', '_')
116+
end
117+
end
118+
119+
Given 'the user has added a File Version to the Digital Object with the following values' do |form_values_table|
120+
click_on 'Add File Version'
121+
122+
form_values_hash = form_values_table.rows_hash
123+
form_values_hash.each do |field, value|
124+
fill_in field, with: value
125+
end
126+
127+
click_on 'Save'
128+
wait_for_ajax
129+
130+
@digital_object_number_of_file_versions += 1
131+
end
132+
133+
Then 'the File Version is removed from the Digital Object' do
134+
subrecords = all('#digital_object_file_versions_ .subrecord-form-list li')
135+
136+
expect(subrecords.length).to eq @digital_object_number_of_file_versions - 1
137+
end

0 commit comments

Comments
 (0)