Skip to content

Commit

Permalink
Adding a submission completion page
Browse files Browse the repository at this point in the history
fixes #1791
  • Loading branch information
carolyncole authored and jrgriffiniii committed May 14, 2024
1 parent 2d9e632 commit b614f0b
Show file tree
Hide file tree
Showing 12 changed files with 102 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/controllers/works_wizard_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
20 changes: 20 additions & 0 deletions app/controllers/works_wizard_submission_complete_controller.rb
Original file line number Diff line number Diff line change
@@ -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
"[email protected]"
else
"[email protected]"
end
end
end
14 changes: 14 additions & 0 deletions app/views/works_wizard_submission_complete/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<div class="wizard-area">

<h1>Submission complete</h1>
<%= render "works_wizard/wizard_progress", wizard_step: 5 %>

<p> 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.
</p>

<div class="actions">
<%= link_to "My Dashboard", user_path(current_user), class: "btn btn-primary" %>
</div>

</div>
3 changes: 3 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion docs/wizard_flow.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
```
2 changes: 1 addition & 1 deletion spec/controllers/works_wizard_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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("[email protected]")
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("[email protected]")
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
3 changes: 3 additions & 0 deletions spec/system/authz_super_admin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions spec/system/external_ids_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion spec/system/pppl_work_create_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions spec/system/work_create_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/system/work_wizard_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit b614f0b

Please sign in to comment.