Skip to content

Commit

Permalink
Use references in URLs
Browse files Browse the repository at this point in the history
This changing the routing and URLs to use the application form reference
rather than the ID. This change allows the assessors to navigate
directly to an application if it's no longer visible in the case
management list, since the IDs are an internal identifier and not
presented anywhere.
  • Loading branch information
thomasleese committed Nov 8, 2023
1 parent e17fe84 commit 231d4ce
Show file tree
Hide file tree
Showing 93 changed files with 301 additions and 299 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,11 @@ def assessment
@assessment ||=
Assessment
.includes(:application_form)
.where(application_form_id: params[:application_form_id])
.where(
application_form: {
reference: params[:application_form_reference],
},
)
.find(params[:assessment_id])
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@ def assessment
@assessment ||=
Assessment
.includes(:application_form)
.where(application_form_id: params[:application_form_id])
.where(
application_form: {
reference: params[:application_form_reference],
},
)
.find(params[:assessment_id])
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ def assessment
@assessment ||=
Assessment
.includes(:application_form)
.where(application_form_id: params[:application_form_id])
.where(
application_form: {
reference: params[:application_form_reference],
},
)
.find(params[:assessment_id])
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,11 @@ def assessment
@assessment ||=
Assessment
.includes(:application_form)
.where(application_form_id: params[:application_form_id])
.where(
application_form: {
reference: params[:application_form_reference],
},
)
.find(params[:assessment_id])
end

Expand Down
6 changes: 5 additions & 1 deletion app/controllers/assessor_interface/assessments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ def assessment
@assessment ||=
Assessment
.includes(:application_form)
.where(application_form_id: params[:application_form_id])
.where(
application_form: {
reference: params[:application_form_reference],
},
)
.find(params[:id])
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ def create
private

def application_form
@application_form ||= ApplicationForm.find(params[:application_form_id])
@application_form ||=
ApplicationForm.find_by!(reference: params[:application_form_reference])
end

def assessor_params
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def application_form
@application_form ||=
ApplicationForm.includes(
assessment: :further_information_requests,
).find(params[:application_form_id])
).find_by(reference: params[:application_form_reference])
end

def view_object
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/assessor_interface/notes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ def create
private

def application_form
@application_form ||= ApplicationForm.find(params[:application_form_id])
@application_form ||=
ApplicationForm.find_by!(reference: params[:application_form_reference])
end

def author
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ def professional_standing_request
assessment: :application_form,
).find_by(
assessment_id: params[:assessment_id],
assessment: {
application_form_id: params[:application_form_id],
application_form: {
reference: params[:application_form_reference],
},
)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ def qualification_requests
.includes(:qualification)
.where(
assessment_id: params[:assessment_id],
assessment: {
application_form_id: params[:application_form_id],
application_form: {
reference: params[:application_form_reference],
},
)
.order("qualifications.start_date": :desc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ def reference_requests
.includes(:work_history)
.where(
assessment_id: params[:assessment_id],
assessment: {
application_form_id: params[:application_form_id],
application_form: {
reference: params[:application_form_reference],
},
)
.order("work_histories.start_date": :desc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ def assessment
@assessment ||=
Assessment
.includes(:application_form)
.where(application_form_id: params[:application_form_id])
.where(
application_form: {
reference: params[:application_form_reference],
},
)
.find(params[:assessment_id])
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ def create
private

def application_form
@application_form ||= ApplicationForm.find(params[:application_form_id])
@application_form ||=
ApplicationForm.find_by!(reference: params[:application_form_reference])
end

def reviewer_params
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ class TimelineEventsController < BaseController
before_action :authorize_assessor

def index
@application_form = ApplicationForm.find(params[:application_form_id])
@application_form =
ApplicationForm.find_by!(reference: params[:application_form_reference])

@timeline_events =
TimelineEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ def work_history
@work_history ||=
WorkHistory
.includes(:application_form)
.where(application_form_id: params[:application_form_id])
.where(
application_form: {
reference: params[:application_form_reference],
},
)
.find(params[:id])
end

Expand Down
4 changes: 2 additions & 2 deletions app/jobs/update_working_days_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def update_assessments_submission_to_recommendation
Assessment
.joins(:application_form)
.includes(:application_form)
.where.not(application_forms: { submitted_at: nil })
.where.not(application_form: { submitted_at: nil })
.where.not(recommended_at: nil)
.find_each do |assessment|
assessment.update!(
Expand All @@ -85,7 +85,7 @@ def update_assessments_submission_to_started
Assessment
.joins(:application_form)
.includes(:application_form)
.where.not(application_forms: { submitted_at: nil })
.where.not(application_form: { submitted_at: nil })
.where.not(started_at: nil)
.find_each do |assessment|
assessment.update!(
Expand Down
4 changes: 4 additions & 0 deletions app/models/application_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ class ApplicationForm < ApplicationRecord

scope :remindable, -> { draft.where("created_at < ?", 5.months.ago) }

def to_param
reference
end

def teaching_qualification
qualifications.find(&:is_teaching_qualification?)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def application_form
ApplicationForm
.includes(assessment: :sections)
.not_draft
.find(params[:id])
.find_by!(reference: params[:reference])
end

def duplicate_matches
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ def assessment_section
).find_by!(
id: params[:id],
assessment_id: params[:assessment_id],
assessment: {
application_form_id: params[:application_form_id],
application_form: {
reference: params[:application_form_reference],
},
)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ def further_information_request
.received
.where(
assessment_id: params[:assessment_id],
assessment: {
application_form_id: params[:application_form_id],
application_form: {
reference: params[:application_form_reference],
},
)
.find(params[:id])
Expand Down
5 changes: 4 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
namespace :assessor_interface, path: "/assessor" do
root to: redirect("/assessor/applications")

resources :application_forms, path: "/applications", except: :new do
resources :application_forms,
path: "/applications",
except: :new,
param: :reference do
collection do
post "filters/apply", to: "application_forms#apply_filters"
get "filters/clear", to: "application_forms#clear_filters"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
describe "heading link" do
subject(:href) { component.at_css("h2 > a")["href"] }

it { is_expected.to eq("/assessor/applications/#{application_form.id}") }
it do
is_expected.to eq("/assessor/applications/#{application_form.reference}")
end
end

describe "description list" do
Expand Down
5 changes: 5 additions & 0 deletions spec/models/application_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,11 @@
expect(application_form.written_statement_document).to_not be_nil
end

describe "#to_param" do
subject(:to_param) { application_form.to_param }
it { is_expected.to eq(application_form.reference) }
end

describe "#created_under_new_regulations?" do
subject(:created_under_new_regulations?) do
application_form.created_under_new_regulations?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module PageObjects
module AssessorInterface
class AgeRangeSubjectsAssessmentRecommendationAward < SitePrism::Page
set_url "/assessor/applications/{application_form_id}/assessments/{assessment_id}" \
set_url "/assessor/applications/{reference}/assessments/{assessment_id}" \
"/recommendation/award/age-range-subjects"

element :heading, "h1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module PageObjects
module AssessorInterface
class Application < SitePrism::Page
set_url "/assessor/applications/{application_form_id}"
set_url "/assessor/applications/{reference}"

element :back_link, "a", text: "Back"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module PageObjects
module AssessorInterface
class ApplicationStatus < SitePrism::Page
set_url "/assessor/applications/{application_form_id}/status"
set_url "/assessor/applications/{reference}/status"

element :back_link, "a", text: "Back"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module PageObjects
module AssessorInterface
class AssessmentRecommendationReview < SitePrism::Page
set_url "/assessor/applications/{application_form_id}/assessments/{assessment_id}" \
set_url "/assessor/applications/{reference}/assessments/{assessment_id}" \
"/recommendation/review/edit"

element :continue_button, ".govuk-button"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module PageObjects
module AssessorInterface
class AssessmentSection < SitePrism::Page
set_url "/assessor/applications/{application_form_id}/assessments/{assessment_id}/sections/{section_id}"
set_url "/assessor/applications/{reference}/assessments/{assessment_id}/sections/{section_id}"

element :heading, "h1"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module PageObjects
module AssessorInterface
class AssignAssessor < SitePrism::Page
set_url "/assessor/applications/{application_form_id}/assign-assessor"
set_url "/assessor/applications/{reference}/assign-assessor"

element :heading, "h1"
sections :assessors, PageObjects::GovukRadioItem, ".govuk-radios__item"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module PageObjects
module AssessorInterface
class AssignReviewer < SitePrism::Page
set_url "/assessor/applications/{application_form_id}/assign-reviewer"
set_url "/assessor/applications/{reference}/assign-reviewer"

element :heading, "h1"
sections :reviewers, PageObjects::GovukRadioItem, ".govuk-radios__item"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class EnglishLanguageProficiencyCard < SitePrism::Section
end

class CheckEnglishLanguageProficiency < AssessmentSection
set_url "/assessor/applications/{application_form_id}/assessments/{assessment_id}/sections/{section_id}"
set_url "/assessor/applications/{reference}/assessments/{assessment_id}/sections/{section_id}"

sections :cards, EnglishLanguageProficiencyCard, ".govuk-summary-card"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class PersonalInformationCard < SitePrism::Section
end

class CheckPersonalInformation < AssessmentSection
set_url "/assessor/applications/{application_form_id}/assessments/{assessment_id}/sections/{section_id}"
set_url "/assessor/applications/{reference}/assessments/{assessment_id}/sections/{section_id}"

sections :cards, PersonalInformationCard, ".govuk-summary-card"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class ProfessionalStandingCard < SitePrism::Section
end

class CheckProfessionalStanding < AssessmentSection
set_url "/assessor/applications/{application_form_id}/assessments/{assessment_id}/sections/{section_id}"
set_url "/assessor/applications/{reference}/assessments/{assessment_id}/sections/{section_id}"

sections :cards, ProfessionalStandingCard, ".govuk-summary-card"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class QualificationCard < SitePrism::Section
end

class CheckQualifications < AssessmentSection
set_url "/assessor/applications/{application_form_id}/assessments/{assessment_id}/sections/{section_id}"
set_url "/assessor/applications/{reference}/assessments/{assessment_id}/sections/{section_id}"

sections :cards, QualificationCard, ".govuk-summary-card"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class WorkHistoryCard < GovukSummaryCard
end

class CheckWorkHistory < AssessmentSection
set_url "/assessor/applications/{application_form_id}/assessments/{assessment_id}/sections/{section_id}"
set_url "/assessor/applications/{reference}/assessments/{assessment_id}/sections/{section_id}"

sections :cards, WorkHistoryCard, ".govuk-summary-card"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module PageObjects
module AssessorInterface
class CompleteAssessment < SitePrism::Page
set_url "/assessor/applications/{application_form_id}/assessments/{assessment_id}/edit"
set_url "/assessor/applications/{reference}/assessments/{assessment_id}/edit"

element :heading, "h1"
sections :new_states, GovukRadioItem, ".govuk-radios__item"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module PageObjects
module AssessorInterface
class ConfirmAssessmentRecommendation < SitePrism::Page
set_url "/assessor/applications/{application_form_id}/assessments/{assessment_id}" \
set_url "/assessor/applications/{reference}/assessments/{assessment_id}" \
"/recommendation/{recommendation}/confirm"

element :heading, "h1"
Expand Down
Loading

0 comments on commit 231d4ce

Please sign in to comment.