Skip to content

Commit

Permalink
added specs
Browse files Browse the repository at this point in the history
  • Loading branch information
jayreddy519 committed May 29, 2024
1 parent 22803d1 commit 1ef6d36
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/models/enrollment_action/dependent_add.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def publish
else
member_date_map = {}
policy_to_change.enrollees.each do |en|
member_date_map[en.m_id] = en.coverage_start if en.active?
member_date_map[en.m_id] = en.coverage_start if en.coverage_status == 'active'
end
change_publish_helper.set_policy_id(policy_to_change.eg_id)
change_publish_helper.set_member_starts(member_date_map)
Expand Down
62 changes: 59 additions & 3 deletions spec/models/enrollment_action/dependent_add_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@
let(:amqp_connection) { double }
let(:event_xml) { double }
let(:event_responder) { instance_double(::ExternalEvents::EventResponder, :connection => amqp_connection) }
let(:enrollee_primary) { double(:m_id => 1, :coverage_start => :one_month_ago) }
let(:enrollee_new) { double(:m_id => 2, :coverage_start => :one_month_ago) }
let(:enrollee_primary) { double(:m_id => 1, :coverage_start => :one_month_ago, :coverage_status => 'active') }
let(:enrollee_new) { double(:m_id => 2, :coverage_start => :one_month_ago, :coverage_status => 'active') }

let(:plan) { instance_double(Plan, :id => 1) }
let(:carrier) { instance_double(Carrier, :renewal_dependent_add_transmitted_as_renewal => true) }
Expand Down Expand Up @@ -158,6 +158,62 @@
end
end

describe EnrollmentAction::DependentAdd, "given a qualified enrollment set, with active & inactive enrollees" do
let(:amqp_connection) { double }
let(:event_xml) { double }
let(:event_responder) { instance_double(::ExternalEvents::EventResponder, :connection => amqp_connection) }
let(:enrollee_primary) { double(:m_id => 1, :coverage_start => :one_month_ago, :coverage_status => 'active') }
let(:enrollee_new) { double(:m_id => 2, :coverage_start => :one_month_ago, :coverage_status => nil) }

let(:plan) { instance_double(Plan, :id => 1) }
let(:carrier) { instance_double(Carrier, :renewal_dependent_add_transmitted_as_renewal => true) }
let(:policy) { instance_double(Policy, :enrollees => [enrollee_primary, enrollee_new], :eg_id => 1, carrier: carrier) }
let(:active_policy) { instance_double(Policy) }

let(:dependent_add_event) { instance_double(
::ExternalEvents::EnrollmentEventNotification,
:event_xml => event_xml,
:all_member_ids => [1,2],
:hbx_enrollment_id => 2,
employer_hbx_id: 1
) }
let(:termination_event) { instance_double(
::ExternalEvents::EnrollmentEventNotification,
:existing_policy => policy,
:all_member_ids => [1],
:event_responder => event_responder,
:hbx_enrollment_id => 1,
:employer_hbx_id => 1
) }
let(:action_helper_result_xml) { double }

let(:action_publish_helper) { instance_double(
EnrollmentAction::ActionPublishHelper,
:to_xml => action_helper_result_xml
) }

before :each do
allow(EnrollmentAction::ActionPublishHelper).to receive(:new).with(event_xml).and_return(action_publish_helper)
allow(action_publish_helper).to receive(:set_policy_id).with(1).and_return(true)
allow(action_publish_helper).to receive(:filter_affected_members).with([2]).and_return(true)
allow(action_publish_helper).to receive(:set_event_action).with("urn:openhbx:terms:v1:enrollment#change_member_add")
allow(action_publish_helper).to receive(:set_member_starts).with({ 1 => :one_month_ago, 2 => :one_month_ago })
allow(action_publish_helper).to receive(:keep_member_ends).with([])
allow(subject).to receive(:publish_edi).with(amqp_connection, action_helper_result_xml, termination_event.hbx_enrollment_id, termination_event.employer_hbx_id)
allow(subject).to receive(:same_carrier_renewal_candidates).with(dependent_add_event).and_return([active_policy])
allow(dependent_add_event).to receive(:dep_add_or_drop_to_renewal_policy?).with(active_policy, policy).and_return(false)
end

subject do
EnrollmentAction::DependentAdd.new(termination_event, dependent_add_event)
end

it "sets member start dates" do
expect(action_publish_helper).to receive(:set_member_starts).with({ 1 => :one_month_ago})
subject.publish
end
end

describe "given renewal event, dependent adding to IVL renewal policy", :dbclean => :after_each do
let(:amqp_connection) { double }
let(:event_xml) { double }
Expand Down Expand Up @@ -412,4 +468,4 @@
subject.publish
end
end
end
end

0 comments on commit 1ef6d36

Please sign in to comment.