Skip to content

Commit

Permalink
Merge pull request #5708 from yosefbennywidyo/fix-logic-surroundin-ca…
Browse files Browse the repository at this point in the history
…se-contacts-with-no-reimbursements

Fix logic surrounding case contacts with no reimbursements
  • Loading branch information
compwron authored May 12, 2024
2 parents ffcafe2 + 57c08d7 commit 031c94d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
14 changes: 6 additions & 8 deletions app/controllers/case_contacts/form_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ class CaseContacts::FormController < ApplicationController

before_action :set_progress
before_action :require_organization!
before_action :set_case_contact, only: [:show, :update]
after_action :verify_authorized

steps(*CaseContact::FORM_STEPS)

# wizard_path
def show
@case_contact = CaseContact.find(params[:case_contact_id])
authorize @case_contact
get_cases_and_contact_types
@page = wizard_steps.index(step) + 1
Expand All @@ -20,14 +20,8 @@ def show
end

def update
@case_contact = CaseContact.find(params[:case_contact_id])
authorize @case_contact
if @case_contact.active?
# do nothing
else
params[:case_contact][:status] = step.to_s
end

params[:case_contact][:status] = step.to_s if !@case_contact.active? && params.key?(:case_contact)
remove_unwanted_contact_types
remove_nil_draft_ids
if @case_contact.update(case_contact_params)
Expand All @@ -54,6 +48,10 @@ def update

private

def set_case_contact
@case_contact = CaseContact.find(params[:case_contact_id])
end

def get_cases_and_contact_types
@casa_cases = policy_scope(current_organization.casa_cases)
@casa_cases = @casa_cases.where(id: @case_contact.casa_case_id) if @case_contact.active?
Expand Down
2 changes: 1 addition & 1 deletion app/values/case_contact_parameters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
class CaseContactParameters < SimpleDelegator
def initialize(params)
new_params =
params.require(:case_contact).permit(
params.fetch(:case_contact, {}).permit(
:duration_minutes,
:occurred_at,
:contact_made,
Expand Down
1 change: 0 additions & 1 deletion app/views/case_contacts/form/expenses.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

<div>
<%= form_with(model: @case_contact, url: wizard_path(nil, case_contact_id: @case_contact.id), local: true, id: "casa-contact-form", class: "component-validated-form") do |form| %>
<%= form.hidden_field :placeholder, value: true %>
<%= render "/shared/error_messages", resource: @case_contact %>

<div class="card-style-1 pl-25 mb-10 pr-50">
Expand Down
4 changes: 2 additions & 2 deletions spec/system/mileage_rates/mileage_rates_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
it "add new mileage rate" do
click_on "New Mileage Rate"
expect(page).to have_text("New Mileage Rate")
fill_in "Effective date", with: "02/01/2020"
fill_in "Effective date", with: "01/02/2020"
fill_in "Amount", with: 1.35
uncheck "Currently active?"
click_on "Save Mileage Rate"

expect(page).to have_text("Mileage Rates")
expect(page).to have_text("Effective date")
expect(page).to have_text("February 1, 2020")
expect(page).to have_text("January 2, 2020")
expect(page).to have_text("Amount")
expect(page).to have_text("$1.35")
expect(page).to have_text("Active?")
Expand Down

0 comments on commit 031c94d

Please sign in to comment.