Skip to content

Commit c906ee9

Browse files
authored
Merge branch 'main' into WRSAT-484
2 parents 43605e4 + df8083f commit c906ee9

File tree

4 files changed

+134
-64
lines changed

4 files changed

+134
-64
lines changed

app/models/screener.rb

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,10 @@ def full_name_with_middle
235235
[first_name, middle_name.presence, last_name].compact.join(" ")
236236
end
237237

238+
def no_exemptions_and_greater_than_or_equal_to_20_hours_of_volunteer_work_or_training?
239+
!exempt_from_work_rules? && total_work_volunteer_and_training_hours >= 20
240+
end
241+
238242
def pregnancy_due_date_day
239243
pregnancy_due_date&.day
240244
end
@@ -251,11 +255,24 @@ def receiving_disability_benefits?
251255
DISABILITY_BENEFIT_ATTRIBUTES.any? { |attr| public_send("#{attr}_yes?") }
252256
end
253257

258+
def requires_proof?
259+
(earnings_above_minimum? && !exempt_from_work_rules?) ||
260+
is_student_yes? ||
261+
preventing_work_drugs_alcohol_yes? ||
262+
preventing_work_medical_condition_yes? ||
263+
receiving_disability_benefits? ||
264+
is_in_alcohol_treatment_program_yes?
265+
end
266+
254267
def strip_email_and_confirmation
255268
self.email = email.strip.downcase if email.present?
256269
self.email_confirmation = email_confirmation.strip.downcase if email_confirmation.present?
257270
end
258271

272+
def total_work_volunteer_and_training_hours
273+
working_hours.to_i + volunteering_hours.to_i + work_training_hours.to_i
274+
end
275+
259276
def volunteering?
260277
is_volunteer_yes? && volunteering_hours.to_i > 0
261278
end
@@ -268,14 +285,6 @@ def working_exempt?
268285
is_working_yes? && (working_30_or_more_hours? || earnings_above_minimum?)
269286
end
270287

271-
def total_work_volunteer_and_training_hours
272-
working_hours.to_i + volunteering_hours.to_i + work_training_hours.to_i
273-
end
274-
275-
def no_exemptions_and_greater_than_or_equal_to_20_hours_of_volunteer_work_or_training?
276-
!exempt_from_work_rules? && total_work_volunteer_and_training_hours >= 20
277-
end
278-
279288
private
280289

281290
def remove_county_if_state_does_not_require

app/views/proof_guidance/edit.html.erb

Lines changed: 56 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -9,66 +9,69 @@
99
<% end %>
1010
</ol>
1111

12-
<h2 class="h2"><%= t("views.proof_guidance.edit.proof_you_may_need") %></h2>
12+
<% if @current_screener.requires_proof? %>
1313

14-
<div class="reveal">
15-
<button class="reveal__button" aria-expanded="true">
16-
<i class="icon-help" style="padding-right: 1rem;"></i><strong><%= t("views.proof_guidance.edit.already_has_proof") %></strong>
17-
</button>
18-
<div class="reveal__content">
19-
<ul class="list--bulleted spacing-above-0">
20-
<% t("views.proof_guidance.edit.already_has_proof_content_html").each do |list_item| %>
21-
<li><%= list_item %></li>
22-
<% end %>
23-
</ul>
24-
</div>
25-
</div>
14+
<h2 class="h2"><%= t("views.proof_guidance.edit.proof_you_may_need") %></h2>
2615

27-
<div class="spacing-below-60">
28-
<% if @current_screener.earnings_above_minimum? && !@current_screener.exempt_from_work_rules? %>
29-
<div>
30-
<%= image_tag "work.svg", class: "illustration left-justified" %>
31-
<%= t("views.proof_guidance.edit.proof_of_working_html") %>
16+
<div class="reveal">
17+
<button class="reveal__button" aria-expanded="true">
18+
<i class="icon-help" style="padding-right: 1rem;"></i><strong><%= t("views.proof_guidance.edit.already_has_proof") %></strong>
19+
</button>
20+
<div class="reveal__content">
21+
<ul class="list--bulleted spacing-above-0">
22+
<% t("views.proof_guidance.edit.already_has_proof_content_html").each do |list_item| %>
23+
<li><%= list_item %></li>
24+
<% end %>
25+
</ul>
3226
</div>
33-
<% end %>
27+
</div>
3428

35-
<% if @current_screener.is_student_yes? %>
36-
<div class="spacing-above-35">
37-
<%= image_tag "school.svg", class: "illustration left-justified" %>
38-
<%= t("views.proof_guidance.edit.proof_of_education_html") %>
39-
<% if @current_screener.age && @current_screener.age > 50 %>
40-
<%= t("views.proof_guidance.edit.proof_of_education_over_50_html") %>
41-
<% end %>
42-
</div>
43-
<% end %>
29+
<div class="spacing-below-60">
30+
<% if @current_screener.earnings_above_minimum? && !@current_screener.exempt_from_work_rules? %>
31+
<div>
32+
<%= image_tag "work.svg", class: "illustration left-justified" %>
33+
<%= t("views.proof_guidance.edit.proof_of_working_html") %>
34+
</div>
35+
<% end %>
4436

45-
<% if @current_screener.preventing_work_drugs_alcohol_yes? || @current_screener.preventing_work_medical_condition_yes? %>
46-
<div class="spacing-above-35">
47-
<%= image_tag "health.svg", class: "illustration left-justified" %>
48-
<%= t("views.proof_guidance.edit.proof_of_health_condition_html") %>
49-
</div>
50-
<% end %>
37+
<% if @current_screener.is_student_yes? %>
38+
<div class="spacing-above-35">
39+
<%= image_tag "school.svg", class: "illustration left-justified" %>
40+
<%= t("views.proof_guidance.edit.proof_of_education_html") %>
41+
<% if @current_screener.age && @current_screener.age > 50 %>
42+
<%= t("views.proof_guidance.edit.proof_of_education_over_50_html") %>
43+
<% end %>
44+
</div>
45+
<% end %>
46+
47+
<% if @current_screener.preventing_work_drugs_alcohol_yes? || @current_screener.preventing_work_medical_condition_yes? %>
48+
<div class="spacing-above-35">
49+
<%= image_tag "health.svg", class: "illustration left-justified" %>
50+
<%= t("views.proof_guidance.edit.proof_of_health_condition_html") %>
51+
</div>
52+
<% end %>
5153

52-
<% if @current_screener.receiving_disability_benefits? %>
53-
<div class="spacing-above-35">
54-
<%= image_tag "disability.svg", class: "illustration left-justified" %>
55-
<%= t("views.proof_guidance.edit.proof_of_disability_benefits_html") %>
56-
<ul class="list--bulleted">
57-
<% Screener::DISABILITY_BENEFIT_ATTRIBUTES.each do |benefit| %>
58-
<% if @current_screener.public_send("#{benefit}_yes?") %>
59-
<li><%= t("views.disability_benefits.edit.#{benefit}") %></li>
54+
<% if @current_screener.receiving_disability_benefits? %>
55+
<div class="spacing-above-35">
56+
<%= image_tag "disability.svg", class: "illustration left-justified" %>
57+
<%= t("views.proof_guidance.edit.proof_of_disability_benefits_html") %>
58+
<ul class="list--bulleted">
59+
<% Screener::DISABILITY_BENEFIT_ATTRIBUTES.each do |benefit| %>
60+
<% if @current_screener.public_send("#{benefit}_yes?") %>
61+
<li><%= t("views.disability_benefits.edit.#{benefit}") %></li>
62+
<% end %>
6063
<% end %>
61-
<% end %>
62-
</ul>
63-
</div>
64-
<% end %>
64+
</ul>
65+
</div>
66+
<% end %>
6567

66-
<% if @current_screener.is_in_alcohol_treatment_program_yes? %>
67-
<div class="spacing-above-35">
68-
<%= image_tag "treatment-program.svg", class: "illustration left-justified" %>
69-
<%= t("views.proof_guidance.edit.proof_of_treatment_program_html") %>
70-
</div>
71-
<% end %>
72-
</div>
68+
<% if @current_screener.is_in_alcohol_treatment_program_yes? %>
69+
<div class="spacing-above-35">
70+
<%= image_tag "treatment-program.svg", class: "illustration left-justified" %>
71+
<%= t("views.proof_guidance.edit.proof_of_treatment_program_html") %>
72+
</div>
73+
<% end %>
74+
</div>
75+
<% end %>
7376

7477
<%= render "shared/continue_button" %>

spec/models/screener_spec.rb

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,52 @@
728728
end
729729
end
730730

731+
describe "#requires_proof?" do
732+
let(:screener) { build(:screener) }
733+
734+
before do
735+
allow(screener).to receive(:earnings_above_minimum?).and_return(false)
736+
allow(screener).to receive(:exempt_from_work_rules?).and_return(true)
737+
allow(screener).to receive(:is_student_yes?).and_return(false)
738+
allow(screener).to receive(:preventing_work_drugs_alcohol_yes?).and_return(false)
739+
allow(screener).to receive(:preventing_work_medical_condition_yes?).and_return(false)
740+
allow(screener).to receive(:receiving_disability_benefits?).and_return(false)
741+
allow(screener).to receive(:is_in_alcohol_treatment_program_yes?).and_return(false)
742+
end
743+
744+
it "returns false when everything is false" do
745+
expect(screener.requires_proof?).to be false
746+
end
747+
748+
[
749+
:is_student_yes?,
750+
:preventing_work_drugs_alcohol_yes?,
751+
:preventing_work_medical_condition_yes?,
752+
:receiving_disability_benefits?,
753+
:is_in_alcohol_treatment_program_yes?
754+
].each do |method_name|
755+
it "returns true when only #{method_name} is true" do
756+
allow(screener).to receive(method_name).and_return(true)
757+
758+
expect(screener.requires_proof?).to be true
759+
end
760+
end
761+
762+
it "returns true when earnings_above_minimum? is true and not exempt" do
763+
allow(screener).to receive(:earnings_above_minimum?).and_return(true)
764+
allow(screener).to receive(:exempt_from_work_rules?).and_return(false)
765+
766+
expect(screener.requires_proof?).to be true
767+
end
768+
769+
it "returns false when earnings_above_minimum? is true but exempt" do
770+
allow(screener).to receive(:earnings_above_minimum?).and_return(true)
771+
allow(screener).to receive(:exempt_from_work_rules?).and_return(true)
772+
773+
expect(screener.requires_proof?).to be false
774+
end
775+
end
776+
731777
describe "encryption" do
732778
it "stores ssn_last_four as encrypted data" do
733779
screener = create(:screener, ssn_last_four: "4567")

spec/views/proof_guidance/edit.html.erb_spec.rb

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,29 @@
1010
end
1111
end
1212

13-
it "always displays the title, next steps, and 'already has proof' section" do
13+
it "always displays the title and next steps" do
1414
render
1515
expect(rendered).to include(I18n.t("views.proof_guidance.edit.title"))
16-
expect(rendered).to include(I18n.t("views.proof_guidance.edit.proof_you_may_need"))
1716
I18n.t("views.proof_guidance.edit.next_steps_html").each do |step|
1817
expect(rendered).to include(step)
1918
end
20-
expect(rendered).to include(I18n.t("views.proof_guidance.edit.already_has_proof"))
2119
end
2220

2321
describe "proof of working section" do
22+
it "shows section when requires_proof? is true" do
23+
allow(screener).to receive(:requires_proof?).and_return(true)
24+
render
25+
expect(rendered).to include(I18n.t("views.proof_guidance.edit.proof_you_may_need"))
26+
expect(rendered).to include(I18n.t("views.proof_guidance.edit.already_has_proof"))
27+
end
28+
29+
it "hides section when requires_proof? is false" do
30+
allow(screener).to receive(:requires_proof?).and_return(false)
31+
render
32+
expect(rendered).not_to include(I18n.t("views.proof_guidance.edit.proof_you_may_need"))
33+
expect(rendered).not_to include(I18n.t("views.proof_guidance.edit.already_has_proof"))
34+
end
35+
2436
it "shows when earnings are above minimum and not exempt from work rules" do
2537
allow(screener).to receive(:earnings_above_minimum?).and_return(true)
2638
allow(screener).to receive(:exempt_from_work_rules?).and_return(false)

0 commit comments

Comments
 (0)