From 08d1a2758d171410ea2284cacf85120b99c7ad4b Mon Sep 17 00:00:00 2001 From: Benjamin Kiah Stroud <32469930+bkiahstroud@users.noreply.github.com> Date: Fri, 13 Oct 2023 10:26:12 -0700 Subject: [PATCH] test that invited users are added to the registered group --- .../hyku/invitations_controller_spec.rb | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/spec/controllers/hyku/invitations_controller_spec.rb b/spec/controllers/hyku/invitations_controller_spec.rb index 4ed0cf5c0..bf87c4ff4 100644 --- a/spec/controllers/hyku/invitations_controller_spec.rb +++ b/spec/controllers/hyku/invitations_controller_spec.rb @@ -31,5 +31,31 @@ expect(response).to redirect_to Hyrax::Engine.routes.url_helpers.admin_users_path(locale: 'en') expect(flash[:notice]).to eq 'An invitation email has been sent to user@guest.org.' end + + context 'when user already exists' do + let(:user) { create(:user) } + + # Mimic the state of a user who is only active in other tenants; + # i.e. a user who has no roles in this tenant + before do + user.roles.destroy_all + end + + it 'adds the user to the registered group' do + expect(user.roles).to be_empty + expect(user.groups).to be_empty + + post :create, params: { + user: { + email: user.email, + role: '' + } + } + + user.reload + expect(user.roles).not_to be_empty + expect(user.groups).to eq([Ability.registered_group_name]) + end + end end end