Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ def create
end
end

def destroy
@job_application.referees.find(params[:id]).destroy!
redirect_to pre_interview_checks_organisation_job_job_application_path(@vacancy.id, @job_application),
success: t(".success")
end

private

def referee_form_params
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@
- @reference_requests.each do |reference_request|
- body.with_row do |row|
- row.with_cell(text: t("publishers.vacancies.job_applications.pre_interview_checks.reference"))
- if reference_request.reference_form.attached?
- row.with_cell do
div = reference_request.referee.name
div = govuk_link_to("#{reference_request.reference_form.filename} (#{number_to_human_size(reference_request.reference_form.byte_size)})", reference_request.reference_form)
- else
- row.with_cell(text: govuk_link_to(reference_request.referee.name, organisation_job_job_application_reference_request_path(@vacancy.id, @job_application.id, reference_request)))
- row.with_cell(text: govuk_link_to(reference_request.referee.name, organisation_job_job_application_reference_request_path(@vacancy.id, @job_application.id, reference_request)))
- status = reference_request_status(reference_request, reference_request.job_reference)

- row.with_cell(text: t("publishers.vacancies.job_applications.pre_interview_checks.#{status}_at", date: reference_request.updated_at.to_fs(:time_on_date)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@
= summary_list.with_row do |row|
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Being a little bit nitpicky here, if the attached/uploaded references have no values for the fields we may want to just not show the empty fields?
So we may always show the name and condition the rest of "when no reference doc is attached"?

Regarding this
Image

- row.with_key(text: key)
- row.with_value(text: value)
- if @reference_request.reference_form.attached?
= summary_list.with_row do |row|
- row.with_key(text: t(".uploaded_reference.heading"))
- row.with_value do
= govuk_link_to "#{@reference_request.reference_form.filename} (#{number_to_human_size(@reference_request.reference_form.byte_size)})", @reference_request.reference_form

- if @reference_request.reference_form.attached?
= govuk_button_link_to t(".uploaded_reference.delete"), organisation_job_job_application_reference_path(@vacancy.id, @job_application.id, @reference_request.referee), method: :delete, class: "govuk-button--warning"

- if @reference_request.sent?
- if @job_reference.complete?
Expand Down
5 changes: 5 additions & 0 deletions config/locales/publishers/vacancies/job_applications.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ en:
vacancies:
job_applications:
references:
destroy:
success: Reference deleted successfully
new:
page_title: Create reference
caption: Reference
Expand Down Expand Up @@ -166,6 +168,9 @@ en:
caption: Update referee information
heading: What is the correct email address for %{name}?
show:
uploaded_reference:
heading: Uploaded reference
delete: Delete reference
print: Download reference
how_would_you_rate: How would you rate %{name}?
page_title: Reference
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@
get :pre_employment_checks
end
resource :religious_reference, only: %i[edit update], controller: "publishers/vacancies/job_applications/religious_references"
resources :references, only: %i[new create], controller: "publishers/vacancies/job_applications/references"
resources :references, only: %i[new create destroy], controller: "publishers/vacancies/job_applications/references"
resource :online_checks, only: %i[edit update], controller: "publishers/vacancies/job_applications/online_checks"
resource :pre_employment_check_set, only: %i[update], controller: "publishers/vacancies/job_applications/pre_employment_checks"
member do
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
require "rails_helper"

RSpec.describe "Job applications references" do
let(:vacancy) { create(:vacancy) }
let(:organisation) { vacancy.organisations.first }
let(:job_application) { create(:job_application, :status_submitted, vacancy:) }
let(:referee) { create(:referee, job_application:) }
let(:publisher) { create(:publisher, accepted_terms_at: 1.day.ago) }

before do
# rubocop:disable RSpec/AnyInstance
allow_any_instance_of(ApplicationController).to receive(:current_organisation).and_return(organisation)
# rubocop:enable RSpec/AnyInstance
sign_in(publisher, scope: :publisher)
end

after { sign_out(publisher) }

describe "DELETE #destroy" do
it "destroys the referee and redirects to pre-interview checks" do
delete organisation_job_job_application_reference_path(vacancy.id, job_application.id, referee.id)

expect { referee.reload }.to raise_error(ActiveRecord::RecordNotFound)
expect(response).to redirect_to(pre_interview_checks_organisation_job_job_application_path(vacancy.id, job_application.id))
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,22 @@

let(:referee_name) { Faker::Name.name }

it "allows the publisher to add referee details" do
scenario "uploading and deleting a reference document" do
fill_in "Referee name", with: referee_name

page.attach_file("publishers-vacancies-job-applications-referee-form-reference-document-field", Rails.root.join("spec/fixtures/files/blank_job_spec.pdf"))
click_on "Save reference"

expect(page).to have_current_path(pre_interview_checks_organisation_job_job_application_path(vacancy.id, job_application.id))
expect(created_referee.name).to eq(referee_name)
expect(ReferenceRequest.last.slice(:marked_as_complete, :status).symbolize_keys).to eq(marked_as_complete: true, status: "received_off_service")

click_on referee_name
expect(page).to have_content("Uploaded reference")
expect(page).to have_content("blank_job_spec.pdf")

click_on "Delete reference"
expect(page).to have_current_path(pre_interview_checks_organisation_job_job_application_path(vacancy.id, job_application.id))
expect(page).to have_content("Reference deleted successfully")
expect(page).to have_no_content(referee_name)
end
end
end
Loading