Skip to content
Merged
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 @@ -19,8 +19,9 @@ def load_clients
end

def load_template_variables
@locale_counts = @clients.where.not(id: @clients.with_insufficient_contact_info).locale_counts
@no_contact_info_count = @clients.with_insufficient_contact_info.size
insufficient_contact_ids = @clients.with_insufficient_contact_info.pluck(:id)
@locale_counts = @clients.where.not(id: insufficient_contact_ids).locale_counts
@no_contact_info_count = insufficient_contact_ids.size
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,36 @@ def edit
expect(assigns(:locale_counts).values.sum).to eq(0)
end
end

context "with mixed client contact info statuses" do
let(:intake_with_email) { build :intake, email_notification_opt_in: "yes", email_address: "[email protected]" }
let(:intake_with_sms) { build :intake, sms_notification_opt_in: "yes", sms_phone_number: "+14155551212", locale: "es" }
let(:intake_without_contact) { build :intake, email_notification_opt_in: "yes", email_address: nil }

let(:client_with_email) { create :client, vita_partner: organization, intake: intake_with_email }
let(:client_with_sms) { create :client, vita_partner: organization, intake: intake_with_sms }
let(:client_without_contact) { create :client, vita_partner: organization, intake: intake_without_contact }

let(:tax_return_4) { create :tax_return, client: client_with_email, year: 2020 }
let(:tax_return_5) { create :tax_return, client: client_with_sms, year: 2020 }
let(:tax_return_6) { create :tax_return, client: client_without_contact, year: 2020 }
let(:tax_return_selection) { create :tax_return_selection, tax_returns: [tax_return_4, tax_return_5, tax_return_6] }

it "correctly separates clients with and without contact info" do
get :edit, params: params

expect(assigns(:no_contact_info_count)).to eq(1)
expect(assigns(:locale_counts).values.sum).to eq(2)
end

it "locale_counts includes only clients with sufficient contact info" do
get :edit, params: params

locale_counts = assigns(:locale_counts)
expect(locale_counts["en"]).to eq(1)
expect(locale_counts["es"]).to eq(1)
end
end
end
end
end
Expand Down
Loading