Skip to content

Commit

Permalink
uses most recent employee role id when plan shop with multiple ERs (#…
Browse files Browse the repository at this point in the history
…2708)

Co-authored-by: Sri Harsha <sriharsha.poosa@gmail.com>
  • Loading branch information
utkarsh7989 and sri49 authored Jul 9, 2024
1 parent 522b688 commit ebd0d51
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/interactors/fetch_shopping_role.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ def possible_role
if context.employee_role.present?
context.employee_role
elsif context.employee_role.nil? && context.person.has_active_employee_role?
context.employee_role = context.person&.active_employee_roles&.first
context.employee_role = context.person&.active_employee_roles&.last
elsif context.person.consumer_role.present?
context.consumer_role = context.person&.consumer_role
elsif context.resident_role.present?
context.resident_role
end
end
end
end
10 changes: 10 additions & 0 deletions spec/controllers/insured/members_selection_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,14 @@
it_behaves_like 'logged in user has no authorization roles for MembersSelectionController', :fetch
end
end

context "with two employee roles" do
let(:census_employee_2){FactoryBot.build(:census_employee)}
let!(:employee_role_2){FactoryBot.build(:employee_role, person: ee_person, :census_employee => census_employee_2)}

it "return http success" do
get :new, params: {person_id: ee_person.id, employee_role_id: employee_role_2.id}
expect(response).to have_http_status(:success)
end
end
end

0 comments on commit ebd0d51

Please sign in to comment.