Skip to content

Commit

Permalink
Case contacts contact made default yes (rubyforgood#6023)
Browse files Browse the repository at this point in the history
* change contact_made column default to true

Fixes issue: rubyforgood#6016

* remove contact_made from new_spec attribute check

* revert changes

* create CaseContact instance with contact_made set to true

* update case_contact details form

* remove set_contact_made_false helper and tests

* update create_another case contact spec

* remove surplus line
panacotar authored Sep 7, 2024

Verified

This commit was signed with the committer’s verified signature. The key has expired.
robhogan Rob Hogan
1 parent e93c5e2 commit 4d3bf27
Showing 5 changed files with 3 additions and 25 deletions.
2 changes: 1 addition & 1 deletion app/controllers/case_contacts_controller.rb
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ def new
draft_case_ids = build_draft_case_ids(params, casa_cases)

@case_contact = CaseContact.create_with_answers(current_organization,
creator: current_user, draft_case_ids: draft_case_ids)
creator: current_user, draft_case_ids: draft_case_ids, contact_made: true)

if @case_contact.errors.any?
flash[:alert] = @case_contact.errors.full_messages.join("\n")
4 changes: 0 additions & 4 deletions app/helpers/case_contacts_helper.rb
Original file line number Diff line number Diff line change
@@ -8,10 +8,6 @@ def duration_minutes(case_contact)
case_contact.duration_minutes.to_i.remainder(60)
end

def set_contact_made_false(case_contact)
case_contact.persisted? && case_contact.contact_made == false
end

def contact_mediums
CaseContact::CONTACT_MEDIUMS.map { |contact_medium|
OpenStruct.new(value: contact_medium, label: contact_medium.titleize)
2 changes: 0 additions & 2 deletions app/views/case_contacts/form/details.html.erb
Original file line number Diff line number Diff line change
@@ -24,15 +24,13 @@
<h5 classs="mb-3"><label>a. Was contact made?</label></h5>
<div class="form-check radio-style mb-20">
<%= form.radio_button :contact_made, true,
checked: @case_contact.contact_made,
required: true,
class: ["form-check-input", "case-contacts-form-checkbox"] %>
<%= form.label "Yes", class: "form-check-label",
for: "case_contact_contact_made_true" %>
</div>
<div class="form-check radio-style mb-20">
<%= form.radio_button :contact_made, false,
checked: set_contact_made_false(@case_contact),
required: true,
class: ["form-check-input", "case-contacts-form-checkbox"] %>
<%= form.label "No", class: "form-check-label",
17 changes: 0 additions & 17 deletions spec/helpers/case_contacts_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -68,23 +68,6 @@
end
end

describe "#set_contact_made_false" do
it "returns false if contact_made is true" do
case_contact = create(:case_contact, contact_made: true)
expect(helper.set_contact_made_false(case_contact)).to eq(false)
end

it "returns true if contact_made is false" do
case_contact = create(:case_contact, contact_made: false)
expect(helper.set_contact_made_false(case_contact)).to eq(true)
end

it "returns false if contact_made is nil" do
case_contact = build(:case_contact, contact_made: nil)
expect(helper.set_contact_made_false(case_contact)).to eq(false)
end
end

describe "#show_volunteer_reimbursement" do
before(:each) do
@casa_cases = []
3 changes: 2 additions & 1 deletion spec/system/case_contacts/new_spec.rb
Original file line number Diff line number Diff line change
@@ -260,10 +260,11 @@
# default values for other attributes (not from the last contact)
expect(next_case_contact.status).to eq "started"
expect(next_case_contact.miles_driven).to be_zero
%i[casa_case_id duration_minutes occurred_at contact_made medium_type
%i[casa_case_id duration_minutes occurred_at medium_type
want_driving_reimbursement notes].each do |attribute|
expect(next_case_contact.send(attribute)).to be_blank
end
expect(next_case_contact.contact_made).to be true
end

it "does not reset referring location" do

0 comments on commit 4d3bf27

Please sign in to comment.