diff --git a/.rubocop.yml b/.rubocop.yml index a4c38af..70c3cb5 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -18,9 +18,6 @@ Layout/LineLength: Layout/ElseAlignment: Enabled: false -Layout/LineLength: - Max: 174 - Style/ConditionalAssignment: Enabled: false diff --git a/helpers/helpers.rb b/helpers/helpers.rb index e5a54f8..7c7a8d9 100644 --- a/helpers/helpers.rb +++ b/helpers/helpers.rb @@ -197,6 +197,10 @@ def create_resource(uuid) find('button', text: 'Save Resource', match: :first).click expect(page).to have_text "Resource Resource #{uuid} created" + + url_parts = current_url.split('/') + url_parts.pop + @resource_id = url_parts.pop end def create_accession(uuid) diff --git a/staff_features/resources/step_definitions/resource_delete.rb b/staff_features/resources/step_definitions/resource_delete.rb new file mode 100644 index 0000000..7993062 --- /dev/null +++ b/staff_features/resources/step_definitions/resource_delete.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +Given 'the user is on the Resource view page' do + visit "#{STAFF_URL}/resources/#{@resource_id}" + + expect(current_url).to include "/resources/#{@resource_id}" +end + +When 'the user checks the checkbox of the Resource' do + find('#multiselect-item').check + row = find('tr.selected') + input = row.find('input') + expect(input.value).to include 'repositories' + expect(input.value).to include 'resource' + + @resource_id = input.value.split('/').pop +end + +Then 'the Resource is deleted' do + expect(@resource_id).to_not eq nil + + visit "#{STAFF_URL}/resources/#{@resource_id}/edit" + + expect(find('h2').text).to eq 'Record Not Found' + + expected_text = "The record you've tried to access may no longer exist or you may not have permission to view it." + expect(page).to have_text expected_text +end + +Then 'the Resources page is displayed' do + expect(find('h2').text).to have_text 'Resources' +end + +Then 'the user is still on the Resource view page' do + expect(current_url).to include "resources/#{@resource_id}" +end