Skip to content

Commit

Permalink
updated is_upload_documents filed name to has_uploaded_documents
Browse files Browse the repository at this point in the history
  • Loading branch information
edwin-jebaraj committed Dec 9, 2024
1 parent 23c6111 commit 0c8df69
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 26 deletions.
6 changes: 3 additions & 3 deletions app/controllers/support/cases/document_uploads_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ def set_current_case
end

def document_uploader_params
params.fetch(:document_uploader, {}).permit(:is_upload_documents, files: [])
params.fetch(:document_uploader, {}).permit(:has_uploaded_documents, files: [])
end

def case_document_uploader_params
params.require(:document_uploader).permit(:is_upload_documents)
params.require(:document_uploader).permit(:has_uploaded_documents)
end

def reset_uploaded_documents
@current_case.update!(is_upload_documents: nil)
@current_case.update!(has_uploaded_documents: nil)
end
end
end
6 changes: 3 additions & 3 deletions app/models/support/case/document_uploader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ class Support::Case::DocumentUploader
attribute :files
attribute :upload_document_files
attribute :support_case
attribute :is_upload_documents
attribute :has_uploaded_documents

validates :files, presence: true, if: -> { support_case.is_upload_documents.nil? }
validates :files, presence: true, if: -> { support_case.has_uploaded_documents.nil? }
validate :files_safe, if: -> { files.present? }
validates :is_upload_documents, presence: true
validates :has_uploaded_documents, presence: true

def save!
support_case.upload_document_files(files:)
Expand Down
8 changes: 4 additions & 4 deletions app/views/support/cases/document_uploads/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
<legend class="govuk-fieldset__legend govuk-fieldset__legend--s">Have you uploaded all documents?</legend>
<div class="govuk-radios">
<div class="govuk-radios__item">
<%= form.radio_button :is_upload_documents, true, checked: @current_case.is_upload_documents == true, class: "govuk-radios__input" %>
<%= form.label :is_upload_documents, "Yes, I have uploaded all documents", value: true, class: "govuk-label govuk-radios__label" %>
<%= form.radio_button :has_uploaded_documents, true, checked: @current_case.has_uploaded_documents == true, class: "govuk-radios__input" %>
<%= form.label :has_uploaded_documents, "Yes, I have uploaded all documents", value: true, class: "govuk-label govuk-radios__label" %>
</div>
<div class="govuk-radios__item">
<%= form.radio_button :is_upload_documents, false, checked: @current_case.is_upload_documents == false, class: "govuk-radios__input" %>
<%= form.label :is_upload_documents, "No", value: false, class: "govuk-label govuk-radios__label" %>
<%= form.radio_button :has_uploaded_documents, false, checked: @current_case.has_uploaded_documents == false, class: "govuk-radios__input" %>
<%= form.label :has_uploaded_documents, "No", value: false, class: "govuk-label govuk-radios__label" %>
</div>
</div>
</fieldset>
Expand Down
4 changes: 2 additions & 2 deletions app/views/support/cases/show/_tasklist.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
task_list.with_item(title: I18n.t("support.case.label.tasklist.item.add_evaluators"), href: '#', status: govuk_tag(text: I18n.t("support.case.label.tasklist.status.to_do")))
task_list.with_item(title: I18n.t("support.case.label.tasklist.item.set_due_date"), href: '#', status: govuk_tag(text: I18n.t("support.case.label.tasklist.status.to_do")))

if @current_case.is_upload_documents == true
if @current_case.has_uploaded_documents == true
document_upload_Status = govuk_tag(text: I18n.t("support.case.label.tasklist.status.complete"), colour: "green")
elsif @current_case.is_upload_documents == false
elsif @current_case.has_uploaded_documents == false
document_upload_Status = govuk_tag(text: I18n.t("support.case.label.tasklist.status.in_progress"))
else
document_upload_Status = govuk_tag(text: I18n.t("support.case.label.tasklist.status.to_do"))
Expand Down
2 changes: 1 addition & 1 deletion config/locales/validation/support/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ en:
attributes:
files:
blank: Select files to upload
is_upload_documents:
has_uploaded_documents:
blank: Please confirm that you uploaded all documents


Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddHasUploadedDocumentsToSupportCases < ActiveRecord::Migration[7.2]
def change
add_column :support_cases, :has_uploaded_documents, :boolean
end
end
5 changes: 3 additions & 2 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.2].define(version: 2024_12_03_125911) do
ActiveRecord::Schema[7.2].define(version: 2024_12_09_104836) do
create_sequence "evaluation_refs"
create_sequence "framework_refs"

Expand Down Expand Up @@ -635,7 +635,8 @@
t.string "project"
t.string "other_school_urns", default: [], array: true
t.boolean "is_evaluator", default: false
t.boolean "is_upload_documents"
t.date "evaluation_due_date"
t.boolean "has_uploaded_documents"
t.index ["category_id"], name: "index_support_cases_on_category_id"
t.index ["existing_contract_id"], name: "index_support_cases_on_existing_contract_id"
t.index ["new_contract_id"], name: "index_support_cases_on_new_contract_id"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
end

specify "when files are uploaded and confirmation choosen as No (In progress)" do
support_case.update!(is_upload_documents: false)
support_case.update!(has_uploaded_documents: false)

expect { document_uploader.save! }.to change { support_case.upload_documents.count }.from(0).to(2)
expect(support_case.upload_documents.pluck(:file_name)).to contain_exactly("text-file.txt", "another-text-file.txt")
Expand All @@ -35,7 +35,7 @@
end

specify "when files are uploaded and confirmation choosen as Yes (Complete)" do
support_case.update!(is_upload_documents: true)
support_case.update!(has_uploaded_documents: true)

expect { document_uploader.save! }.to change { support_case.upload_documents.count }.from(0).to(2)
expect(support_case.upload_documents.pluck(:file_name)).to contain_exactly("text-file.txt", "another-text-file.txt")
Expand All @@ -46,8 +46,8 @@
expect(find("#complete-evaluation-3-status")).to have_text("Complete")
end

specify "viewing uploaded files and deleting files" do
support_case.update!(is_upload_documents: true)
specify "viewing uploaded files" do
support_case.update!(has_uploaded_documents: true)
document_uploader.save!

visit edit_support_case_document_uploads_path(case_id: support_case)
Expand All @@ -69,7 +69,7 @@

support_case.reload

support_case.update!(is_upload_documents: nil)
support_case.update!(has_uploaded_documents: nil)

expect(support_case.upload_documents.count).to eq(0)

Expand Down
2 changes: 1 addition & 1 deletion spec/models/support/case_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
describe "#to_csv" do
it "includes headers" do
expect(described_class.to_csv).to eql(
"id,ref,category_id,request_text,support_level,status,state,created_at,updated_at,agent_id,first_name,last_name,email,phone_number,source,organisation_id,existing_contract_id,new_contract_id,procurement_id,savings_status,savings_estimate_method,savings_actual_method,savings_estimate,savings_actual,action_required,organisation_type,value,closure_reason,extension_number,other_category,other_query,procurement_amount,confidence_level,special_requirements,query_id,exit_survey_sent,detected_category_id,creation_source,user_selected_category,created_by_id,procurement_stage_id,initial_request_text,with_school,next_key_date,next_key_date_description,discovery_method,discovery_method_other_text,project,other_school_urns,is_evaluator,is_upload_documents\n",
"id,ref,category_id,request_text,support_level,status,state,created_at,updated_at,agent_id,first_name,last_name,email,phone_number,source,organisation_id,existing_contract_id,new_contract_id,procurement_id,savings_status,savings_estimate_method,savings_actual_method,savings_estimate,savings_actual,action_required,organisation_type,value,closure_reason,extension_number,other_category,other_query,procurement_amount,confidence_level,special_requirements,query_id,exit_survey_sent,detected_category_id,creation_source,user_selected_category,created_by_id,procurement_stage_id,initial_request_text,with_school,next_key_date,next_key_date_description,discovery_method,discovery_method_other_text,project,other_school_urns,is_evaluator,has_uploaded_documents\n",
)
end
end
Expand Down

0 comments on commit 0c8df69

Please sign in to comment.