Skip to content

Commit

Permalink
760 - Addresses comments from code review
Browse files Browse the repository at this point in the history
Renames the model field to `acknowledgment_page_submitted_at`
  • Loading branch information
jlandiseigsti committed Jun 24, 2024
1 parent c429fc4 commit caf6f80
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 17 deletions.
4 changes: 2 additions & 2 deletions app/controllers/author/submissions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def acknowledge_update
@ack = AcknowledgmentSignatures.new(acknowledge_params)
@ack.validate!
@submission = find_submission
@submission.update!(author_edit: false, acknowledgment_page_viewed_at: DateTime.now)
@submission.update!(author_edit: false, acknowledgment_page_submitted_at: DateTime.now)
redirect_to edit_author_submission_path(@submission)
rescue ActiveModel::ValidationError
flash[:alert] = 'Please initial for every statement.'
Expand All @@ -55,7 +55,7 @@ def acknowledge_update

def edit
@submission = find_submission
redirect_to author_submission_acknowledge_path(@submission) if @submission.acknowledgment_page_viewed_at.nil? && current_partner.graduate?
redirect_to author_submission_acknowledge_path(@submission) if @submission.acknowledgment_page_submitted_at.nil? && current_partner.graduate?
status_giver = SubmissionStatusGiver.new(@submission)
status_giver.can_update_program_information?
rescue SubmissionStatusGiver::AccessForbidden
Expand Down
2 changes: 1 addition & 1 deletion app/views/author/submissions/acknowledge.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<%= form.input :sig_4, label: false, placeholder: I18n.t("graduate.submission.acknowledge.initial") %>
<%= form.label :sig_5, I18n.t("graduate.submission.acknowledge.point5", degree_type: @degree_type) %>
<%= form.input :sig_5, label: false, placeholder: I18n.t("graduate.submission.acknowledge.initial") %>
<%= form.label :sig_5, I18n.t("graduate.submission.acknowledge.point6") %>
<%= form.label :sig_6, I18n.t("graduate.submission.acknowledge.point6") %>
<%= form.input :sig_6, label: false, placeholder: I18n.t("graduate.submission.acknowledge.initial") %>
<%= form.label :sig_7, I18n.t("graduate.submission.acknowledge.point7") %>
<%= form.input :sig_7, label: false, placeholder: I18n.t("graduate.submission.acknowledge.initial") %>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class AddAcknowledgementPageToSubmission < ActiveRecord::Migration[6.1]
def change
add_column :submissions, :acknowledgment_page_viewed_at, :datetime
add_column :submissions, :acknowledgment_page_submitted_at, :datetime
end
end
14 changes: 11 additions & 3 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,15 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2024_06_04_152657) do
ActiveRecord::Schema.define(version: 2024_06_13_195728) do

create_table "admin_feedback_files", charset: "utf8mb4", force: :cascade do |t|
t.bigint "submission_id"
t.text "asset"
t.string "feedback_type"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
end

create_table "admins", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
t.string "access_id", default: "", null: false
Expand Down Expand Up @@ -293,9 +301,9 @@
t.string "lionpath_semester"
t.string "academic_program"
t.string "degree_checkout_status"
t.integer "candidate_number"
t.datetime "acknowledgment_page_viewed_at"
t.datetime "author_release_warning_sent_at"
t.datetime "acknowledgment_page_submitted_at"
t.integer "candidate_number"
t.index ["author_id"], name: "submissions_author_id_fk"
t.index ["degree_id"], name: "submissions_degree_id_fk"
t.index ["final_submission_legacy_id"], name: "index_submissions_on_final_submission_legacy_id"
Expand Down
16 changes: 8 additions & 8 deletions spec/controllers/author/submissions_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@

describe '#edit' do
it 'routes to the edit page' do
submission = FactoryBot.create(:submission, acknowledgment_page_viewed_at: nil)
submission = FactoryBot.create(:submission, acknowledgment_page_submitted_at: nil)
expect(get: edit_author_submission_path(submission.id)).to route_to(controller: 'author/submissions', action: 'edit', id: submission.id.to_s)
end

if current_partner.graduate?
it 'redirects to the acknowledge page if acknowledgement page has not been viewed' do
oidc_authorize_author
submission = FactoryBot.create(:submission, acknowledgment_page_viewed_at: nil)
submission = FactoryBot.create(:submission, acknowledgment_page_submitted_at: nil)
params = { id: submission.id.to_s }
allow(controller).to receive(:find_submission).and_return(submission)
expect(get(:edit, params:)).to redirect_to author_submission_acknowledge_path(submission.id)
Expand All @@ -41,7 +41,7 @@
describe '#acknowledge' do
if current_partner.graduate?
it 'follows correct route' do
submission = FactoryBot.create(:submission, acknowledgment_page_viewed_at: nil)
submission = FactoryBot.create(:submission, acknowledgment_page_submitted_at: nil)
expect(get: author_submission_acknowledge_path(submission.id)).to route_to(controller: 'author/submissions', action: 'acknowledge', submission_id: submission.id.to_s)
end
end
Expand All @@ -50,21 +50,21 @@
describe '#acknowledge_update' do
if current_partner.graduate?
it 'follows correct route' do
submission = FactoryBot.create(:submission, acknowledgment_page_viewed_at: nil)
submission = FactoryBot.create(:submission, acknowledgment_page_submitted_at: nil)
expect(patch: author_submission_acknowledge_update_path(submission.id)).to route_to(controller: 'author/submissions', action: 'acknowledge_update', submission_id: submission.id.to_s)
end

it 'redirects back to acknowledge page with an alert if the user does not initial for every statement' do
oidc_authorize_author
submission = FactoryBot.create(:submission, acknowledgment_page_viewed_at: nil)
submission = FactoryBot.create(:submission, acknowledgment_page_submitted_at: nil)
params = { acknowledgment_signatures: { sig_1: '', sig_2: '', sig_3: '3', sig_4: '4', sig_5: '5', sig_6: '6', sig_7: '7' }, submission_id: submission.id.to_s }
expect(patch(:acknowledge_update, params:)).to redirect_to author_submission_acknowledge_path(submission.id)
expect(flash[:alert]).to be_present
end

it 'redirects back to edit page if the user submits valid program information data' do
oidc_authorize_author
submission = FactoryBot.create(:submission, acknowledgment_page_viewed_at: nil)
submission = FactoryBot.create(:submission, acknowledgment_page_submitted_at: nil)
params = { acknowledgment_signatures: { sig_1: '1', sig_2: '2', sig_3: '3', sig_4: '4', sig_5: '5', sig_6: '6', sig_7: '7' }, submission_id: submission.id.to_s }
allow(controller).to receive(:find_submission).and_return(submission)
expect(patch(:acknowledge_update, params:)).to redirect_to edit_author_submission_path(submission.id)
Expand All @@ -73,11 +73,11 @@

it 'save the updated submission if the user submits valid program information data' do
oidc_authorize_author
submission = FactoryBot.create(:submission, acknowledgment_page_viewed_at: nil)
submission = FactoryBot.create(:submission, acknowledgment_page_submitted_at: nil)
params = { acknowledgment_signatures: { sig_1: '1', sig_2: '2', sig_3: '3', sig_4: '4', sig_5: '5', sig_6: '6', sig_7: '7' }, submission_id: submission.id.to_s }
allow(controller).to receive(:find_submission).and_return(submission)
patch(:acknowledge_update, params:)
expect(submission.reload.acknowledgment_page_viewed_at).not_to be_nil
expect(submission.reload.acknowledgment_page_submitted_at).not_to be_nil
expect(submission).to be_persisted
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/submissions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
campus { 'UP' }
academic_program { 'GREN' }
degree_checkout_status { 'EG' }
acknowledgment_page_viewed_at { Time.zone.now if current_partner.graduate? }
acknowledgment_page_submitted_at { Time.zone.now if current_partner.graduate? }

trait :collecting_program_information do
committee_provided_at { nil }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
it "page progresses to edit page" do
skip 'graduate only' unless current_partner.graduate?
second_program = FactoryBot.create :program, name: 'A different program'
new_submission = FactoryBot.create(:submission, :collecting_committee, author:, acknowledgment_page_viewed_at: nil)
new_submission = FactoryBot.create(:submission, :collecting_committee, author:, acknowledgment_page_submitted_at: nil)
visit "/author/submissions/#{new_submission.id}/edit"
expect(page).to have_content('I acknowledge that')
fields = all('input[type="text"]')
Expand Down

0 comments on commit caf6f80

Please sign in to comment.