-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding a new policy page to the front of the wizard
fixes #1688
- Loading branch information
1 parent
c9397eb
commit 1feff9c
Showing
16 changed files
with
191 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# frozen_string_literal: true | ||
|
||
require "nokogiri" | ||
require "open-uri" | ||
|
||
# Controller to handle the policy agreement acknowlegdement before the wizard is started | ||
# | ||
class WizardPolicyController < ApplicationController | ||
# get /works/policy | ||
def show; end | ||
|
||
# post /works/policy | ||
def update | ||
group = Group.find_by(code: params[:group_code]) || current_user.default_group | ||
if params[:agreement] == "1" | ||
work = Work.create!(created_by_user_id: current_user.id, group:) | ||
work.add_provenance_note(DateTime.now, "User agreed to the Data Acceptance and Retention policy", current_user.id) | ||
redirect_to work_create_new_submission_path(work) | ||
else | ||
redirect_to root_path, notice: "You must agree to the policy to deposit" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<div class="wizard-area"> | ||
|
||
<h1>New Submission Policy</h1> | ||
<%= render "works_wizard/wizard_progress", wizard_step: 0 %> | ||
|
||
<p> Before you proceed, please review the PDC policies for <a href="https://drive.google.com/file/d/1GECvKoOjwqvKTKYvyNThCyzTWjD6cPxs/view?usp=sharing" target="_blank">Acceptance and Retention</a> | ||
and <a href="https://drive.google.com/file/d/1E8EgfyL2yB2rH0xCIIqYrTFE0QfY8Sk_/view?usp=sharing" target="_blank">Distribution</a> to be sure your intended submission is eligible for PDC, | ||
that you are authorized to grant permission for redistribution, and that you are prepared to pay any applicable costs. If you are unsure about any of these points, please <a href="mailto:[email protected]" target="_blank">reach out to our team</a> before submitting. | ||
</p> | ||
|
||
<%= form_tag work_policy_path, method: :post %> | ||
<%= check_box_tag(:agreement) %> | ||
<%= label_tag(:agreement, "I understand this policy and wish to continue.") %> | ||
<hr /> | ||
<div class="actions"> | ||
<%= link_to "Cancel", root_path, class: "btn btn-secondary" %> | ||
<%= submit_tag "Confirm", class: "btn btn-primary wizard-next-button" %> | ||
</div> | ||
</form> | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# frozen_string_literal: true | ||
|
||
require "rails_helper" | ||
|
||
RSpec.describe WizardPolicyController do | ||
include ActiveJob::TestHelper | ||
|
||
let(:user) { FactoryBot.create :princeton_submitter } | ||
|
||
context "valid user login" do | ||
before do | ||
sign_in user | ||
end | ||
|
||
describe "#show" do | ||
it "show the user the policy agreement for" do | ||
get(:show) | ||
expect(response.status).to be 200 | ||
expect(response).to render_template(:show) | ||
end | ||
end | ||
|
||
describe "#update" do | ||
let(:params) { { "agreement" => "1" } } | ||
|
||
it "creates a work with an activity" do | ||
sign_in user | ||
expect { post(:update, params:) }.to change { Work.count }.by(1) | ||
expect(response.status).to be 302 | ||
work = Work.last | ||
expect(response).to redirect_to(work_create_new_submission_path(work)) | ||
|
||
expect(work.state).to eq("none") | ||
expect(work.work_activity.count).to eq(1) | ||
end | ||
|
||
context "agreement is missing" do | ||
let(:params) { {} } | ||
|
||
it "redirects to the dashboard" do | ||
sign_in user | ||
post(:update, params:) | ||
expect(response.status).to be 302 | ||
end | ||
end | ||
end | ||
end | ||
|
||
context "invalid user" do | ||
describe "#show" do | ||
it "redirects the user" do | ||
get(:show) | ||
expect(response.status).to be 302 | ||
end | ||
end | ||
|
||
describe "#update" do | ||
let(:params) { { "agreement" => "1" } } | ||
|
||
it "redirects the user" do | ||
post(:update, params:) | ||
expect(response.status).to be 302 | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.