From b614f0b5f2c390bb25e5030a60bb3f71f59f3b97 Mon Sep 17 00:00:00 2001 From: Carolyn Cole Date: Mon, 13 May 2024 13:41:04 -0400 Subject: [PATCH] Adding a submission completion page fixes #1791 --- app/controllers/works_wizard_controller.rb | 2 +- ...s_wizard_submission_complete_controller.rb | 20 +++++++++ .../show.html.erb | 14 ++++++ config/routes.rb | 3 ++ docs/wizard_flow.md | 9 +++- .../works_wizard_controller_spec.rb | 2 +- ...ard_submission_complete_controller_spec.rb | 45 +++++++++++++++++++ spec/system/authz_super_admin_spec.rb | 3 ++ spec/system/external_ids_spec.rb | 2 + spec/system/pppl_work_create_spec.rb | 3 +- spec/system/work_create_spec.rb | 2 + spec/system/work_wizard_spec.rb | 2 +- 12 files changed, 102 insertions(+), 5 deletions(-) create mode 100644 app/controllers/works_wizard_submission_complete_controller.rb create mode 100644 app/views/works_wizard_submission_complete/show.html.erb create mode 100644 spec/controllers/works_wizard_submission_complete_controller_spec.rb diff --git a/app/controllers/works_wizard_controller.rb b/app/controllers/works_wizard_controller.rb index 4f3ee18a2..2d726af18 100644 --- a/app/controllers/works_wizard_controller.rb +++ b/app/controllers/works_wizard_controller.rb @@ -115,7 +115,7 @@ def validate render :review else @work.complete_submission!(current_user) - redirect_to user_url(current_user) + redirect_to work_complete_path(@work.id) end end diff --git a/app/controllers/works_wizard_submission_complete_controller.rb b/app/controllers/works_wizard_submission_complete_controller.rb new file mode 100644 index 000000000..e7f7802a8 --- /dev/null +++ b/app/controllers/works_wizard_submission_complete_controller.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +require "nokogiri" +require "open-uri" + +# Controller to handle the completion of a submission +# +# The wizard flow is shown in the [mermaid diagram here](https://github.com/pulibrary/pdc_describe/blob/main/docs/wizard_flow.md). +# +class WorksWizardSubmissionCompleteController < ApplicationController + # get /works/policy + def show + @work = Work.find(params[:id]) + @email = if @work.group == Group.plasma_laboratory + "publications@pppl.gov" + else + "prds@princeton.edu" + end + end +end diff --git a/app/views/works_wizard_submission_complete/show.html.erb b/app/views/works_wizard_submission_complete/show.html.erb new file mode 100644 index 000000000..19de5224f --- /dev/null +++ b/app/views/works_wizard_submission_complete/show.html.erb @@ -0,0 +1,14 @@ +
+ +

Submission complete

+ <%= render "works_wizard/wizard_progress", wizard_step: 5 %> + +

Thank you for your submission. You should hear back from a curator within 5-10 business days. Your submission is not available to edit while the curators are reviewing it. + Please contact <%= mail_to(@email) %> for assistance if you have any question. +

+ +
+ <%= link_to "My Dashboard", user_path(current_user), class: "btn btn-primary" %> +
+ +
diff --git a/config/routes.rb b/config/routes.rb index 95d325773..eddcf032c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -60,6 +60,9 @@ get "works/policy", to: "works_wizard_policy#show", as: :work_policy post "works/policy", to: "works_wizard_policy#update" + # policy agreement + get "works/:id/complete", to: "works_wizard_submission_complete#show", as: :work_complete + get "works/:id/file-list", to: "works#file_list", as: :work_file_list post "work/:id/approve", to: "works#approve", as: :approve_work post "work/:id/withdraw", to: "works#withdraw", as: :withdraw_work diff --git a/docs/wizard_flow.md b/docs/wizard_flow.md index 0cf25cd1a..e3726e693 100644 --- a/docs/wizard_flow.md +++ b/docs/wizard_flow.md @@ -31,9 +31,10 @@ file_upload -- User uploads Attachments --> review file_upload -- User cancels --> user_show file_upload -- User saves --> file_upload - review -- User Submits work as complete --> validate + review -- User Submits work as complete --> validate{ work valid?} review -- User cancels --> user_show review -- User saves --> review + validate -- no --> edit_wizard end subgraph WorksWizardUpdateAdditionalController @@ -42,4 +43,10 @@ update_additional_save -- User saves --> update_additional_save update_additional_save --> readme_select end + + subgraph WorksWizardSubmissionCompleteController + validate -- yes --> submission_complete[show] + submission_complete --> user_show + end + ``` \ No newline at end of file diff --git a/spec/controllers/works_wizard_controller_spec.rb b/spec/controllers/works_wizard_controller_spec.rb index 1e7741f8f..8c34eb46d 100644 --- a/spec/controllers/works_wizard_controller_spec.rb +++ b/spec/controllers/works_wizard_controller_spec.rb @@ -341,7 +341,7 @@ it "saves the submission notes and renders the user dashboard" do post :validate, params: { id: work.id, submission_notes: "I need this processed ASAP" } expect(response.status).to be 302 - expect(response.location).to eq "http://test.host/users/#{user.uid}" + expect(response.location).to eq "http://test.host/works/#{work.id}/complete" expect(Work.find(work.id).submission_notes).to eq "I need this processed ASAP" end diff --git a/spec/controllers/works_wizard_submission_complete_controller_spec.rb b/spec/controllers/works_wizard_submission_complete_controller_spec.rb new file mode 100644 index 000000000..ea75d2038 --- /dev/null +++ b/spec/controllers/works_wizard_submission_complete_controller_spec.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: true + +require "rails_helper" + +RSpec.describe WorksWizardSubmissionCompleteController do + include ActiveJob::TestHelper + + let(:user) { FactoryBot.create :princeton_submitter } + let(:work) { FactoryBot.create :draft_work, created_by_user_id: user.id } + + context "valid user login" do + before do + sign_in user + end + + describe "#show" do + it "show the user the work completion" do + get(:show, params: { id: work.id }) + expect(response.status).to be 200 + expect(response).to render_template(:show) + expect(assigns(:email)).to eq("prds@princeton.edu") + end + + context "a pppl work" do + let(:work) { FactoryBot.create :pppl_work } + + it "show the user the work completion with the pppl email" do + get(:show, params: { id: work.id }) + expect(response.status).to be 200 + expect(response).to render_template(:show) + expect(assigns(:email)).to eq("publications@pppl.gov") + end + end + end + end + + context "invalid user" do + describe "#show" do + it "redirects the user" do + get(:show, params: { id: work.id }) + expect(response.status).to be 302 + end + end + end +end diff --git a/spec/system/authz_super_admin_spec.rb b/spec/system/authz_super_admin_spec.rb index d72945ea1..c4026d925 100644 --- a/spec/system/authz_super_admin_spec.rb +++ b/spec/system/authz_super_admin_spec.rb @@ -48,6 +48,9 @@ click_on "Complete" page.driver.browser.switch_to.alert.accept + expect(page).to have_content("5-10 business days") + click_on "My Dashboard" + expect(page).to have_content "awaiting_approval" work = Work.last allow(Work).to receive(:find).with(work.id).and_return(work) diff --git a/spec/system/external_ids_spec.rb b/spec/system/external_ids_spec.rb index f5807cdbe..823d20c8a 100644 --- a/spec/system/external_ids_spec.rb +++ b/spec/system/external_ids_spec.rb @@ -37,6 +37,8 @@ click_on "Next" click_on "Complete" page.driver.browser.switch_to.alert.accept + expect(page).to have_content("5-10 business days") + click_on "My Dashboard" expect(page).to have_content "awaiting_approval" expect(Ezid::Identifier).not_to have_received(:mint) diff --git a/spec/system/pppl_work_create_spec.rb b/spec/system/pppl_work_create_spec.rb index 7f3aac749..5d5ed06ea 100644 --- a/spec/system/pppl_work_create_spec.rb +++ b/spec/system/pppl_work_create_spec.rb @@ -70,7 +70,8 @@ expect(page).to have_content("In furtherance of its non-profit educational mission, Princeton University") click_on "Complete" page.driver.browser.switch_to.alert.accept - + expect(page).to have_content("5-10 business days") + click_on "My Dashboard" expect(page).to have_content "awaiting_approval" end end diff --git a/spec/system/work_create_spec.rb b/spec/system/work_create_spec.rb index 7fdac7840..d2f88857f 100644 --- a/spec/system/work_create_spec.rb +++ b/spec/system/work_create_spec.rb @@ -305,6 +305,8 @@ expect(page).to have_content("In furtherance of its non-profit educational mission, Princeton University") click_on "Complete" page.driver.browser.switch_to.alert.accept + expect(page).to have_content("5-10 business days") + click_on "My Dashboard" work.reload expect(work.awaiting_approval?).to be true diff --git a/spec/system/work_wizard_spec.rb b/spec/system/work_wizard_spec.rb index 1d319f16c..2179590b2 100644 --- a/spec/system/work_wizard_spec.rb +++ b/spec/system/work_wizard_spec.rb @@ -94,7 +94,7 @@ expect(page).to have_content("this is not on the page") click_on "Grant License and Complete" page.driver.browser.switch_to.alert.accept - expect(page).to have_content("Welcome") + expect(page).to have_content("5-10 business days") expect(page).to have_content(work.title) end