Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check create_renewals_on_date_change RR configs to display warning #4555

Open
wants to merge 6 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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 @@ -467,5 +467,37 @@ def insurance_kind_select_options(kind)
[hr_kind(kind, insurance_kind), insurance_kind, {:'data-esi' => display_esi_fields?(insurance_kind, kind), :'data-mvsq' => display_minimum_value_standard_question?(insurance_kind)}]
end
end

def benefit_coverage_period_info
return @benefit_coverage_period_info if defined? @benefit_coverage_period_info

current_hbx = HbxProfile.current_hbx
is_under_open_enrollment = current_hbx.under_open_enrollment?
latest_benefit_coverage_period = current_hbx.benefit_sponsorship.benefit_coverage_periods.last
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just sharing an opinion here-- I would lean towards the use of an existing method on the model, like current_benefit_coverage_period on the BenefitSponsorship. I find the use of .last as a proxy for "latest" a little fuzzy/brittle, at least in theory. Great variable name, tho; the intention is very clear!

open_enrollment_start_on = latest_benefit_coverage_period.open_enrollment_start_on
open_enrollment_end_on = latest_benefit_coverage_period.open_enrollment_end_on

@benefit_coverage_period_info = {
is_under_open_enrollment: is_under_open_enrollment,
not_under_open_enrollment: !is_under_open_enrollment,
open_enrollment_start_on: open_enrollment_start_on,
open_enrollment_end_on: open_enrollment_end_on
}
end

def can_display_coverage_update_reminder?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea adding these helper methods to abstract the logic out of the views!

FinancialAssistanceRegistry.feature_enabled?(:oe_application_warning_display) && benefit_coverage_period_info[:is_under_open_enrollment]
end

def can_display_oe_application_warning?
FinancialAssistanceRegistry.feature_enabled?(:oe_application_warning_display) && benefit_coverage_period_info[:not_under_open_enrollment] && (TimeKeeper.date_of_record >= bulk_application_renewal_trigger_date)
end

def bulk_application_renewal_trigger_date
day = FinancialAssistanceRegistry[:create_renewals_on_date_change].settings(:renewals_creation_day).item
month = FinancialAssistanceRegistry[:create_renewals_on_date_change].settings(:renewals_creation_month).item
year = TimeKeeper.date_of_record.year
Date.new(year, month, day)
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@

<h1><%= l10n('faa.cost_savings_applications') %></h1>
<p><%= l10n('faa.cost_savings_applications_desc') %></p>
<% if FinancialAssistanceRegistry.feature_enabled?(:oe_application_warning_display) %>
<% if HbxProfile.current_hbx.under_open_enrollment? %>
<% oe_year = Family.application_applicable_year %>
<% current_year = oe_year - 1 %>
<p><strong data-cuke='coverage_update_reminder_display'><%= l10n('faa.coverage_update_reminder', year: current_year, year2: oe_year) %></strong></p>
<% elsif HbxProfile.current_hbx.benefit_sponsorship.benefit_coverage_periods.last.open_enrollment_start_on > TimeKeeper.date_of_record %>
<p><strong data-cuke='oe_application_warning_display'><%= l10n('faa.cost_savings_applications_oe_desc', next_year: HbxProfile.current_hbx.benefit_sponsorship.benefit_coverage_periods.last.open_enrollment_end_on.year, oe_start: HbxProfile.current_hbx.benefit_sponsorship.benefit_coverage_periods.last.open_enrollment_start_on&.strftime("%B %d, %Y")) %></strong></p>
<% end %>
<% if can_display_coverage_update_reminder? %>
<% oe_year = Family.application_applicable_year %>
<% current_year = oe_year - 1 %>
<p><strong data-cuke='coverage_update_reminder_display'><%= l10n('faa.coverage_update_reminder', year: current_year, year2: oe_year) %></strong></p>
<% else can_display_oe_application_warning? %>
<p><strong data-cuke='oe_application_warning_display'><%= l10n('faa.cost_savings_applications_oe_desc', next_year: benefit_coverage_period_info[:open_enrollment_end_on].year, oe_start: benefit_coverage_period_info[:open_enrollment_start_on]&.strftime("%B %d, %Y")) %></strong></p>
<% end %>

<%= form_tag(main_app.help_paying_coverage_response_insured_consumer_role_index_path, method: :get, id: 'start-new-app-form') do %>
Expand Down Expand Up @@ -130,13 +128,13 @@
<div class="col-md-10">
<h1 class="darkblue no-buffer"><%= l10n('faa.cost_savings_applications') %></h1>
<h4><%= l10n('faa.cost_savings_applications_desc') %></h4>
<% if FinancialAssistanceRegistry.feature_enabled?(:oe_application_warning_display) && HbxProfile.current_hbx.under_open_enrollment? %>
<% if can_display_coverage_update_reminder? %>
<% oe_year = Family.application_applicable_year %>
<% current_year = oe_year - 1 %>
<h4 data-cuke='coverage_update_reminder_display'><b><%= l10n('faa.coverage_update_reminder', year: current_year, year2: oe_year) %></b></h4>
<% end %>
<% if FinancialAssistanceRegistry.feature_enabled?(:oe_application_warning_display) && !HbxProfile.current_hbx.under_open_enrollment? && (HbxProfile.current_hbx.benefit_sponsorship.benefit_coverage_periods.last.open_enrollment_start_on > TimeKeeper.date_of_record) %>
<h4 data-cuke='oe_application_warning_display'><%= l10n('faa.cost_savings_applications_oe_desc', next_year: HbxProfile.current_hbx.benefit_sponsorship.benefit_coverage_periods.last.open_enrollment_end_on.year, oe_start: HbxProfile.current_hbx.benefit_sponsorship.benefit_coverage_periods.last.open_enrollment_start_on&.strftime("%B %d, %Y")) %></h4>
<% if can_display_oe_application_warning? %>
<h4 data-cuke='oe_application_warning_display'><%= l10n('faa.cost_savings_applications_oe_desc', next_year: benefit_coverage_period_info[:open_enrollment_end_on].year, oe_start: benefit_coverage_period_info[:open_enrollment_start_on]&.strftime("%B %d, %Y")) %></h4>
<% end %>
<div class="pull-right" style="display:flex; justify-content: space-between; padding: 10px 0px;">
<%= form_tag(main_app.help_paying_coverage_response_insured_consumer_role_index_path, method: :get, id: 'start_new_app', style: "align-self:flex-end;") do %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
<%= render partial: 'shared/family_side_nav' %>
<h1><%= l10n('faa.cost_savings_applications') %></h1>
<p><%= l10n('faa.cost_savings_applications_desc') %></p>
<% if FinancialAssistanceRegistry.feature_enabled?(:oe_application_warning_display) %>
<% if HbxProfile.current_hbx.under_open_enrollment? %>
<% oe_year = Family.application_applicable_year %>
<% current_year = oe_year - 1 %>
<p><strong data-cuke='coverage_update_reminder_display'><%= l10n('faa.coverage_update_reminder', year: current_year, year2: oe_year) %></strong></p>
<% elsif HbxProfile.current_hbx.benefit_sponsorship.benefit_coverage_periods.last.open_enrollment_start_on > TimeKeeper.date_of_record %>
<p><strong data-cuke='oe_application_warning_display'><%= l10n('faa.cost_savings_applications_oe_desc', next_year: HbxProfile.current_hbx.benefit_sponsorship.benefit_coverage_periods.last.open_enrollment_end_on.year, oe_start: HbxProfile.current_hbx.benefit_sponsorship.benefit_coverage_periods.last.open_enrollment_start_on&.strftime("%B %d, %Y")) %></strong></p>
<% end %>
<% if can_display_coverage_update_reminder? %>
<% oe_year = Family.application_applicable_year %>
<% current_year = oe_year - 1 %>
<p><strong data-cuke='coverage_update_reminder_display'><%= l10n('faa.coverage_update_reminder', year: current_year, year2: oe_year) %></strong></p>
<% else can_display_oe_application_warning? %>
<p><strong data-cuke='oe_application_warning_display'><%= l10n('faa.cost_savings_applications_oe_desc', next_year: benefit_coverage_period_info[:open_enrollment_end_on].year, oe_start: benefit_coverage_period_info[:open_enrollment_start_on]&.strftime("%B %d, %Y")) %></strong></p>
<% end %>

<div class="d-flex align-items-center">
Expand Down Expand Up @@ -144,13 +142,13 @@
<div class="col-md-10">
<h1 class="no-buffer"><%= l10n('faa.cost_savings_applications') %></h1>
<h4><%= l10n('faa.cost_savings_applications_desc') %></h4>
<% if FinancialAssistanceRegistry.feature_enabled?(:oe_application_warning_display) && HbxProfile.current_hbx.under_open_enrollment? %>
<% if can_display_coverage_update_reminder? %>
<% oe_year = Family.application_applicable_year %>
<% current_year = oe_year - 1 %>
<h4 data-cuke='coverage_update_reminder_display'><b><%= l10n('faa.coverage_update_reminder', year: current_year, year2: oe_year) %></b></h4>
<% end %>
<% if FinancialAssistanceRegistry.feature_enabled?(:oe_application_warning_display) && !HbxProfile.current_hbx.under_open_enrollment? && (HbxProfile.current_hbx.benefit_sponsorship.benefit_coverage_periods.last.open_enrollment_start_on > TimeKeeper.date_of_record) %>
<h4 data-cuke='oe_application_warning_display'><%= l10n('faa.cost_savings_applications_oe_desc', next_year: HbxProfile.current_hbx.benefit_sponsorship.benefit_coverage_periods.last.open_enrollment_end_on.year, oe_start: HbxProfile.current_hbx.benefit_sponsorship.benefit_coverage_periods.last.open_enrollment_start_on&.strftime("%B %d, %Y")) %></h4>
<% if can_display_oe_application_warning? %>
<h4 data-cuke='oe_application_warning_display'><%= l10n('faa.cost_savings_applications_oe_desc', next_year: benefit_coverage_period_info[:open_enrollment_end_on].year, oe_start: benefit_coverage_period_info[:open_enrollment_start_on]&.strftime("%B %d, %Y")) %></h4>
<% end %>
<div style="display:flex; justify-content: space-between; padding: 10px 0px;">
<%= form_with url: "", method: "get", class:"" do %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -492,4 +492,54 @@
end
end
end

context "can_display_oe_application_warning?" do
let(:current_hbx_profile) {FactoryBot.create(:hbx_profile)}
let(:benefit_sponsorship) { FactoryBot.create(:benefit_sponsorship, :open_enrollment_coverage_period, hbx_profile: current_hbx_profile) }
let(:benefit_coverage_period) { current_hbx_profile.benefit_sponsorship.benefit_coverage_periods.first }

before do
allow(FinancialAssistanceRegistry).to receive(:feature_enabled?).with(:oe_application_warning_display).and_return(true)
allow(HbxProfile).to receive(:current_hbx).and_return(current_hbx_profile)
end

after(:each) do
TimeKeeper.set_date_of_record_unprotected!(Date.today)
end

it 'should return false if system date is not within open enrollment' do
TimeKeeper.set_date_of_record_unprotected!(benefit_coverage_period.open_enrollment_start_on - 1.day)
expect(helper.can_display_oe_application_warning?).to eq(true)
end

it 'should return true if system date is within open enrollment' do
TimeKeeper.set_date_of_record_unprotected!(benefit_coverage_period.open_enrollment_start_on + 1.day)
expect(helper.can_display_oe_application_warning?).to eq(false)
end
end

context 'can_display_coverage_update_reminder?' do
let(:current_hbx_profile) {FactoryBot.create(:hbx_profile)}
let(:benefit_sponsorship) { FactoryBot.create(:benefit_sponsorship, :open_enrollment_coverage_period, hbx_profile: current_hbx_profile) }
let(:benefit_coverage_period) { current_hbx_profile.benefit_sponsorship.benefit_coverage_periods.first }

before do
allow(FinancialAssistanceRegistry).to receive(:feature_enabled?).with(:oe_application_warning_display).and_return(true)
allow(HbxProfile).to receive(:current_hbx).and_return(current_hbx_profile)
end

after(:each) do
TimeKeeper.set_date_of_record_unprotected!(Date.today)
end

it 'should return false if system date is not within open enrollment' do
TimeKeeper.set_date_of_record_unprotected!(benefit_coverage_period.open_enrollment_start_on - 1.day)
expect(helper.can_display_coverage_update_reminder?).to eq(false)
end

it 'should return true if system date is within open enrollment' do
TimeKeeper.set_date_of_record_unprotected!(benefit_coverage_period.open_enrollment_start_on + 1.day)
expect(helper.can_display_coverage_update_reminder?).to eq(true)
end
end
end
6 changes: 3 additions & 3 deletions features/financial_assistance/cost_savings.feature
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Feature: Cost Savings
Scenario: FAA Feature Is Enabled - Consumer will see message if oe_application_warning_display feature is enabled
Given the oe application warning display feature is enabled
Given current hbx is not under open enrollment
Given it is before open enrollment
Given current date is between renewals generation date and open enrollment start on
Given consumer visits home page
And the Cost Savings link is visible
When the consumer clicks the Cost Savings link
Expand All @@ -63,7 +63,7 @@ Feature: Cost Savings
Given the oe application warning display feature is enabled
Given the filtered_application_list feature is enabled
Given current hbx is not under open enrollment
Given it is before open enrollment
Given current date is between renewals generation date and open enrollment start on
Given consumer visits home page
And the Cost Savings link is visible
When the consumer clicks the Cost Savings link
Expand All @@ -73,7 +73,7 @@ Feature: Cost Savings
Scenario: Consumer will not see message if after open enrollment
Given the oe application warning display feature is enabled
Given current hbx is not under open enrollment
Given it is after open enrollment
Given current date is outside renewals generation date and open enrollment start on
Given consumer visits home page
And the Cost Savings link is visible
When the consumer clicks the Cost Savings link
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@
HbxProfile.any_instance.stub(:under_open_enrollment?).and_return(true)
end

And(/^it is before open enrollment$/) do
oe_start_on = HbxProfile.current_hbx.benefit_sponsorship.benefit_coverage_periods.detect {|bcp| bcp.start_on.year == Date.today.year}.open_enrollment_start_on
allow(TimeKeeper).to receive(:date_of_record).and_return Date.new(oe_start_on.year,10,27)
And(/^current date is between renewals generation date and open enrollment start on$/) do
oe_start_on = HbxProfile.current_hbx.benefit_sponsorship.benefit_coverage_periods.detect { |bcp| bcp.start_on.year == Date.today.year }.open_enrollment_start_on
allow(TimeKeeper).to receive(:date_of_record).and_return Date.new(oe_start_on.year, 10, 27)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems virtually impossible that the renewals generation date would be after 10/27, but just noting that we have a hardcoded date here and the renewals generation date is env variable driven.

end

And(/^it is after open enrollment$/) do
And(/^current date is outside renewals generation date and open enrollment start on$/) do
oe_end_on = HbxProfile.current_hbx.benefit_sponsorship.benefit_coverage_periods.last.open_enrollment_end_on
allow(TimeKeeper).to receive(:date_of_record).and_return Date.new(oe_end_on.year,2,15)
allow(TimeKeeper).to receive(:date_of_record).and_return Date.new(oe_end_on.year, 2, 15)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar note as above-- there's probably no chance that the OE end date would be after 2/15, but that date is driven by a setting and this one is hardcoded.

end

And(/^current hbx is not under open enrollment$/) do
Expand Down
Loading