Skip to content

Commit

Permalink
Add checks for job application presence and status
Browse files Browse the repository at this point in the history
Checks render different banner link components depending on the presence and status of a job application. Save job link not rendered if a job application exists
  • Loading branch information
josephhull676 committed Mar 11, 2021
1 parent 0988f02 commit d7437c8
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 20 deletions.
46 changes: 32 additions & 14 deletions app/views/shared/vacancy/_jobseeker_view.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,29 @@
h2.govuk-caption-l.job-caption class="govuk-!-margin-bottom-5 govuk-!-margin-top-0"
= vacancy_job_location(@vacancy)
.govuk-grid-row
- if JobseekerApplicationsFeature.enabled?
.govuk-grid-column-one-third
= render(Shared::BannerLinkComponent.new(icon_class: "apply",
link_id: "apply-job-application",
link_method: :get,
link_path: new_jobseekers_job_job_application_path(@vacancy.id),
link_text: t("jobseekers.job_applications.apply")))
- if JobseekerApplicationsFeature.enabled? && @vacancy.apply_through_teaching_vacancies&.downcase == "yes"
- case current_jobseeker&.job_applications&.find_by(vacancy_id: @vacancy.id)&.status
- when "submitted"
.govuk-grid-column-one-third
= render(Shared::BannerLinkComponent.new(icon_class: "green-tick",
link_id: "apply-job-application",
link_method: :get,
link_path: jobseekers_job_application_path(current_jobseeker.job_applications.find_by(vacancy_id: @vacancy.id)),
link_text: t("jobseekers.job_applications.banner_links.submitted")))
- when "draft"
.govuk-grid-column-one-third
= render(Shared::BannerLinkComponent.new(icon_class: "green-tick",
link_id: "apply-job-application",
link_method: :get,
link_path: jobseekers_job_application_path(current_jobseeker.job_applications.find_by(vacancy_id: @vacancy.id)),
link_text: t("jobseekers.job_applications.banner_links.draft")))
- else
.govuk-grid-column-one-third
= render(Shared::BannerLinkComponent.new(icon_class: "apply",
link_id: "apply-job-application",
link_method: :get,
link_path: new_jobseekers_job_job_application_path(@vacancy.id),
link_text: t("jobseekers.job_applications.banner_links.apply")))

.govuk-grid-column-one-third
/ The "origin" param is used both for the back button on the subsequent page and for performance analysis.
Expand All @@ -32,13 +48,15 @@
link_path: new_subscription_path,
link_text: t("jobs.alert.similar.terse"),
params: { search_criteria: @devised_job_alert_search_criteria, origin: request.original_fullpath }))
.govuk-grid-column-one-third
= render(Shared::BannerLinkComponent.new(icon_class: @saved_job.present? ? "saved" : "save",
link_id: "#{@saved_job.present? ? 'saved' : 'save'}-job-listing",
link_method: @saved_job.present? ? :delete : :get,
link_path: @saved_job.present? ? jobseekers_saved_job_path(@vacancy.id, @saved_job) : new_jobseekers_saved_job_path(@vacancy.id),
params: { click_event: "vacancy_save_to_account_clicked" },
link_text: t("jobseekers.saved_jobs.#{@saved_job.present? ? 'saved' : 'save'}")))

- if current_jobseeker&.job_applications&.find_by(vacancy_id: @vacancy.id).nil?
.govuk-grid-column-one-third
= render(Shared::BannerLinkComponent.new(icon_class: @saved_job.present? ? "saved" : "save",
link_id: "#{@saved_job.present? ? 'saved' : 'save'}-job-listing",
link_method: @saved_job.present? ? :delete : :get,
link_path: @saved_job.present? ? jobseekers_saved_job_path(@vacancy.id, @saved_job) : new_jobseekers_saved_job_path(@vacancy.id),
params: { click_event: "vacancy_save_to_account_clicked" },
link_text: t("jobseekers.saved_jobs.#{@saved_job.present? ? 'saved' : 'save'}")))

.govuk-grid-row

Expand Down
6 changes: 5 additions & 1 deletion config/locales/jobseekers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ en:
apply: Apply for this job
applying_for_the_role_heading: Applying for the role
applying_for_the_role_paragraph: Please complete the online application.
current_step: Step %{current} of %{total}
banner_links:
apply: Apply for this job
draft: Started - continue application
submitted: Submitted - view application
build:
ask_for_support:
adjustments: "This could be:"
Expand Down Expand Up @@ -111,6 +114,7 @@ en:
heading: References
no_references: No referees specified
title: References — Application
current_step: Step %{current} of %{total}
details:
employment_history: Role
form:
Expand Down
10 changes: 5 additions & 5 deletions spec/system/jobseekers_can_start_a_job_application_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
before { login_as(jobseeker, scope: :jobseeker) }

context "when clicking apply on the job page" do
before { click_on I18n.t("jobseekers.job_applications.apply") }
before { click_on I18n.t("jobseekers.job_applications.banner_links.apply") }

it "starts a job application" do
expect(current_path).to eq(new_jobseekers_job_job_application_path(vacancy.id))
Expand All @@ -38,7 +38,7 @@

context "when the jobseeker is not signed in" do
context "when clicking apply on the job page" do
before { click_on I18n.t("jobseekers.job_applications.apply") }
before { click_on I18n.t("jobseekers.job_applications.banner_links.apply") }

it "starts a job application after signing in" do
expect(current_path).not_to eq(new_jobseekers_job_job_application_path(vacancy.id))
Expand All @@ -58,7 +58,7 @@

context "when the jobseeker does not have an account" do
context "when clicking apply on the job page" do
before { click_on I18n.t("jobseekers.job_applications.apply") }
before { click_on I18n.t("jobseekers.job_applications.banner_links.apply") }

it "starts a job application after signing up" do
expect(current_path).not_to eq(new_jobseekers_job_job_application_path(vacancy.id))
Expand All @@ -85,7 +85,7 @@

before do
login_as(jobseeker, scope: :jobseeker)
click_on I18n.t("jobseekers.job_applications.apply")
click_on I18n.t("jobseekers.job_applications.banner_links.apply")
end

it "redirects to job applications dashboard with correct message" do
Expand All @@ -105,7 +105,7 @@

before do
login_as(jobseeker, scope: :jobseeker)
click_on I18n.t("jobseekers.job_applications.apply")
click_on I18n.t("jobseekers.job_applications.banner_links.apply")
end

it "redirects to job applications dashboard with correct message" do
Expand Down

0 comments on commit d7437c8

Please sign in to comment.