Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions app/models/ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,15 @@ def processor
# Allow processors to see the admin dashboard link in the main site nav. See the _site_nav layout for more info.
can :administrate, Admin

# Authorize processors to use all submitter dashboard controller actions. If not, any attempts to access the
# dashboard will trigger Admin::ApplicationController#authorized_or_redirect.
# Authorize processors to use all submitter and advisor dashboard controller actions. If not,
# any attempts to access the dashboard will trigger
# Admin::ApplicationController#authorized_or_redirect.
can :manage, :advisor
can :manage, :submitter

# Authorize processors to access submitter model. If not, administrate will raise a NotAuthorizedError when
# controller methods are called.
# Authorize processors to access submitter and advisor model. If not, administrate will raise a
# NotAuthorizedError when controller methods are called.
can :manage, Advisor
can :manage, Submitter

can :files, Report
Expand Down
4 changes: 0 additions & 4 deletions test/integration/admin/admin_advisor_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ def delete_advisor_denied
end

test 'processors can create advisors via admin dashboard' do
skip('Processors currently can not _use_ the admin dashboard, so this fails.')
mock_auth(users(:processor))
create_advisor
end
Expand All @@ -188,7 +187,6 @@ def delete_advisor_denied
end

test 'processors can edit advisors through admin dashboard' do
skip('Processors currently can not _use_ the admin dashboard, so this fails.')
mock_auth(users(:processor))
edit_advisor_name
end
Expand All @@ -215,7 +213,6 @@ def delete_advisor_denied
end

test 'processors can assign theses to advisors via advisor form' do
skip('Processors currently can not _use_ the admin dashboard, so this fails.')
mock_auth(users(:processor))
assign_advisor_to_thesis
end
Expand All @@ -242,7 +239,6 @@ def delete_advisor_denied
end

test 'processors can delete an advisor' do
skip('Processors currently can not _use_ the admin dashboard, so this fails.')
mock_auth(users(:processor))
delete_advisor
end
Expand Down
3 changes: 1 addition & 2 deletions test/integration/admin/admin_department_thesis_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ def teardown
end

test 'can edit department_thesis through admin dashboard' do
skip('This test is failing in GitHub Actions and passing everywhere else. We are skipping it until we fix it in CI.')
mock_auth(users(:thesis_admin))
link = DepartmentThesis.first
link = department_theses(:primary)
assert_not_equal false, link.primary
patch admin_department_thesis_path(link),
params: { department_thesis: { primary: false } }
Expand Down
9 changes: 0 additions & 9 deletions test/integration/thesis_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,6 @@ def teardown
assert_select 'span.error', text: Thesis::VALIDATION_MSGS[:departments]
end

test 'invalid files message' do
skip('Unclear why this used to pass but now fails, but the data model never properly validated attached thesis so this failing is not surprising')
mock_auth(users(:basic))
params = @thesis_params
params[:files] = nil
post thesis_index_path, params: { thesis: params }
assert_select "input.required[data-msg='#{Thesis::VALIDATION_MSGS[:files]}']"
end

test 'coauthor field' do
mock_auth(users(:basic))
orig_count = Thesis.count
Expand Down
25 changes: 21 additions & 4 deletions test/jobs/preservation_submission_job_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ def stub_apt_lambda_200_failure
)
end

def stub_apt_lambda_bad_request
stub_request(:post, ENV.fetch('APT_LAMBDA_URL', nil))
.to_return(
status: 400,
body: { error: 'Invalid input payload' }.to_json,
headers: { 'Content-Type' => 'application/json' }
)
end

test 'sends report emails on success' do
stub_apt_lambda_success
ClimateControl.modify DISABLE_ALL_EMAIL: 'false' do
Expand Down Expand Up @@ -175,10 +184,18 @@ def stub_apt_lambda_200_failure
assert_equal 1, another_good_thesis.archivematica_payloads.count
end

test 'throws exceptions and probably creates payloads when a bad key is provided' do
skip('Test not implemented yet')
# Our lambda returns 400 Bad Request with a error body of Invalid input payload
# This should never happen as we submit it via ENV, but just in case we should understand what it looks like
test 'creates payloads when a a 400 error is returned' do
stub_apt_lambda_bad_request
thesis = setup_thesis
assert_equal 0, thesis.archivematica_payloads.count

# The job handles the 400 error gracefully.
PreservationSubmissionJob.perform_now([thesis])

# Confirms that payloads are created even when a 400 Bad Request is returned, but the payload
# is not preserved.
assert_equal 1, thesis.archivematica_payloads.count
assert_equal 'unpreserved', thesis.archivematica_payloads.last.preservation_status
end

test 'retries on 502 Bad Gateway errors' do
Expand Down