Skip to content

Commit

Permalink
Merge pull request #6621 from samvera/updates_read_only_mode_spec
Browse files Browse the repository at this point in the history
Valkyrizes `spec/features/read_only_mode_spec.rb`.
  • Loading branch information
dlpierce authored Jan 22, 2024
2 parents 5497eaf + 96fc49c commit 029e1ff
Showing 1 changed file with 10 additions and 21 deletions.
31 changes: 10 additions & 21 deletions spec/features/read_only_mode_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,9 @@
context 'a logged in user' do
let(:user) { create(:user) }
let(:admin_user) { FactoryBot.create(:admin) }
let(:admin_set) do
AdminSet.create(title: ["work admin set"],
description: ["some description"],
edit_users: [user.id])
end
let(:admin_set) { valkyrie_create(:hyrax_admin_set, edit_users: [user]) }

let(:permission_template) do
Hyrax::PermissionTemplate.create!(source_id: admin_set.id)
end
let(:permission_template) { Hyrax::PermissionTemplate.create!(source_id: admin_set.id) }

let(:workflow) { Sipity::Workflow.find_by!(name: 'default', permission_template: permission_template) }

Expand All @@ -43,9 +37,7 @@
permission_template.available_workflows.first.update!(active: true)
end

scenario 'as a non-admin', js: false do
login_as user

def common_read_only_page_tests
visit new_hyrax_generic_work_path
expect(page).to have_content('Add New Work')

Expand All @@ -58,19 +50,16 @@
expect(page).to have_content('Add New Work')
end

scenario 'as admin', js: false do
login_as admin_user
scenario 'as a non-admin', js: false do
login_as user

visit new_hyrax_generic_work_path
expect(page).to have_content('Add New Work')
common_read_only_page_tests
end

allow(Flipflop).to receive(:read_only?).and_return(true)
visit new_hyrax_generic_work_path
expect(page).to have_content('The repository is in read-only mode for maintenance.')
scenario 'as admin', js: false do
login_as admin_user

allow(Flipflop).to receive(:read_only?).and_return(false)
visit new_hyrax_generic_work_path
expect(page).to have_content('Add New Work')
common_read_only_page_tests
end
end
end

0 comments on commit 029e1ff

Please sign in to comment.