Skip to content

Commit 8186ae1

Browse files
committed
Move methods that are only used for tests into test helper
1 parent 05b1e55 commit 8186ae1

29 files changed

+110
-261
lines changed

app/helpers/application_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def ctc_current_tax_year
162162
end
163163

164164
def ctc_prior_tax_year
165-
MultiTenantService.new(:ctc).prior_tax_year
165+
MultiTenantService.new(:ctc).current_tax_year - 1
166166
end
167167

168168
def request_domain

app/models/intake/gyr_intake.rb

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -618,17 +618,8 @@ def self.current_tax_year
618618
MultiTenantService.gyr.current_tax_year.to_i
619619
end
620620

621-
def most_recent_filing_year
622-
filing_years.first || MultiTenantService.new(:gyr).current_tax_year
623-
end
624-
625-
def most_recent_needs_help_or_filing_year
626-
return filing_years.first if filing_years.first.present?
627-
return MultiTenantService.new(:gyr).current_tax_year - 1 if needs_help_previous_year_1_yes?
628-
return MultiTenantService.new(:gyr).current_tax_year - 2 if needs_help_previous_year_2_yes?
629-
return MultiTenantService.new(:gyr).current_tax_year - 3 if needs_help_previous_year_3_yes?
630-
631-
MultiTenantService.new(:gyr).current_tax_year
621+
def most_recent_filing_year(time = DateTime.now)
622+
filing_years.first || MultiTenantService.new(:gyr).current_tax_year(time)
632623
end
633624

634625
def year_before_most_recent_filing_year

app/models/state_file_dependent.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,6 @@ class StateFileDependent < ApplicationRecord
9191
message: :blank
9292
}, if: -> { id_has_grocery_credit_ineligible_months == "yes" }, on: :id_grocery_credit_form
9393

94-
def self.senior_cutoff_date
95-
# Deprecated: please use `#senior?` (this method used only in tests)
96-
MultiTenantService.statefile.end_of_current_tax_year.years_ago(65)
97-
end
98-
9994
def full_name
10095
parts = [first_name, middle_initial, last_name]
10196
parts << suffix if suffix.present?

app/services/multi_tenant_service.rb

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,6 @@ def current_tax_year(time = DateTime.now)
9191
end
9292
end
9393

94-
def end_of_current_tax_year
95-
DateTime.new(current_tax_year).end_of_year
96-
end
97-
98-
def prior_tax_year
99-
current_tax_year - 1
100-
end
101-
10294
def between_deadline_and_end_of_in_progress_intake?(now = DateTime.now)
10395
now.between?(Rails.configuration.tax_deadline, Rails.configuration.end_of_in_progress_intake)
10496
end
@@ -116,8 +108,8 @@ def filing_years(now = DateTime.now)
116108
end
117109
end
118110

119-
def backtax_years(now = DateTime.now)
120-
filing_years(now).without(current_tax_year)
111+
def backtax_years(time = DateTime.now)
112+
filing_years(time).without(current_tax_year(time))
121113
end
122114

123115
def twilio_creds
@@ -152,11 +144,8 @@ def statefile
152144
private
153145

154146
def gyr_current_tax_year(time)
155-
filing_seasons = Rails.configuration.tax_year_filing_seasons.select do |key, val|
156-
# val = open, closed date
157-
time > val[0]
158-
end
159-
160-
filing_seasons.keys.max
147+
Rails.configuration.tax_year_filing_seasons.select do |_year, (open_date, _close_date)|
148+
time > open_date
149+
end.keys.max
161150
end
162151
end

app/views/hub/clients/show.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,11 +345,11 @@
345345
<div class="client-profile__field-group">
346346
<h2 class="text--bold">Prior Year AGI Amount</h2>
347347
<div class="field-display">
348-
<span class="form-question">Primary Prior Year (<%= MultiTenantService.new(:ctc).prior_tax_year %>) AGI:</span>
348+
<span class="form-question">Primary Prior Year (<%= ctc_prior_tax_year %>) AGI:</span>
349349
<span class="label-value"><%= number_to_currency(@client.intake.primary_prior_year_agi_amount || 0) %></span>
350350
</div>
351351
<div class="field-display">
352-
<span class="form-question">Spouse Prior Year (<%= MultiTenantService.new(:ctc).prior_tax_year %>) AGI:</span>
352+
<span class="form-question">Spouse Prior Year (<%= ctc_prior_tax_year %>) AGI:</span>
353353
<span class="label-value"><%= number_to_currency(@client.intake.spouse_prior_year_agi_amount || 0) %></span>
354354
</div>
355355
</div>

app/views/questions/backtaxes/edit.html.erb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,15 @@
2222
</p>
2323
<div class="form-card__stacked-checkboxes spacing-above-0">
2424
<% gyr_backtax_years.reverse.each do |backtax_year| %>
25-
<!-- does this need to use the filing year instead?-->
26-
<!-- MultiTenantService.gyr.current_tax_year should be gyr_backtax_years.max instead?-->
27-
<% previous_year_index = gyr_backtax_years.max - backtax_year %>
25+
<% previous_year_index = MultiTenantService.gyr.current_tax_year(app_time) - backtax_year %>
2826
<%= f.cfa_checkbox("needs_help_previous_year_#{previous_year_index}".to_sym,
2927
backtax_year.to_s,
3028
options: { checked_value: "yes", unchecked_value: "no" }) %>
3129
<% end %>
3230
<%= f.cfa_checkbox("needs_help_current_year".to_sym,
33-
MultiTenantService.gyr.current_tax_year.to_s,
31+
MultiTenantService.gyr.current_tax_year(app_time).to_s,
3432
options: { checked_value: "yes", unchecked_value: "no" }) %>
3533
</div>
36-
<% binding.pry %>
3734

3835
<%= f.continue %>
3936
<% end %>

app/views/questions/start_with_current_year/edit.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<% content_for :page_title, t("views.questions.start_with_current_year.title", :year => current_intake.most_recent_filing_year) %>
1+
<% content_for :page_title, t("views.questions.start_with_current_year.title", :year => current_intake.most_recent_filing_year(app_time)) %>
22

33
<% content_for :card do %>
44
<div class="form-card">
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<div id="prior-agi">
22
<div class="hub-form__card card-small">
33
<h3>Prior Tax Year Adjusted Gross Income</h3>
4-
<p>If the client filed taxes in <%= MultiTenantService.new(:ctc).prior_tax_year %>, either AGI field(s) or PIN field(s) must have accurate values.</p>
4+
<p>If the client filed taxes in <%= ctc_prior_tax_year %>, either AGI field(s) or PIN field(s) must have accurate values.</p>
55
<p>If PIN(s) are provided, PIN will be sent on the return. Otherwise, AGI is used.</p>
6-
<%= f.cfa_input_field(:primary_prior_year_agi_amount, "Primary #{MultiTenantService.new(:ctc).prior_tax_year} AGI (Form 1040 8b)") %>
7-
<%= f.cfa_input_field(:spouse_prior_year_agi_amount, "Spouse #{MultiTenantService.new(:ctc).prior_tax_year} AGI (Form 1040b)") %>
8-
<%= f.cfa_input_field(:primary_prior_year_signature_pin, "Primary #{MultiTenantService.new(:ctc).prior_tax_year} Signature PIN") %>
9-
<%= f.cfa_input_field(:spouse_prior_year_signature_pin, "Spouse #{MultiTenantService.new(:ctc).prior_tax_year} Signature PIN") %>
6+
<%= f.cfa_input_field(:primary_prior_year_agi_amount, "Primary #{ctc_prior_tax_year} AGI (Form 1040 8b)") %>
7+
<%= f.cfa_input_field(:spouse_prior_year_agi_amount, "Spouse #{ctc_prior_tax_year} AGI (Form 1040b)") %>
8+
<%= f.cfa_input_field(:primary_prior_year_signature_pin, "Primary #{ctc_prior_tax_year} Signature PIN") %>
9+
<%= f.cfa_input_field(:spouse_prior_year_signature_pin, "Spouse #{ctc_prior_tax_year} Signature PIN") %>
1010
</div>
1111
</div>

spec/controllers/state_file/questions/id_disability_controller_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
render_views
1313

1414
let!(:state_file1099_r) { create(:state_file1099_r, intake: intake, taxable_amount: 25) }
15-
let(:between_dob) { Date.new((MultiTenantService.statefile.end_of_current_tax_year.year - 63), 1, 1) }
16-
let(:not_between_dob) { Date.new((MultiTenantService.statefile.end_of_current_tax_year.year - 60), 1, 1) }
15+
let(:between_dob) { age_at_end_of_tax_year(63) }
16+
let(:not_between_dob) { age_at_end_of_tax_year(60) }
1717

1818
it 'succeeds' do
1919
get :edit

spec/factories/state_file_az_intakes.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@
148148
spouse_first_name { "Senior" }
149149
spouse_middle_initial { "B" }
150150
spouse_last_name { "Spouse" }
151-
spouse_birth_date { MultiTenantService.statefile.end_of_current_tax_year - 70 }
151+
spouse_birth_date { age_at_end_of_tax_year(70) }
152152
end
153153

154154
trait :with_az321_contributions do

0 commit comments

Comments
 (0)