GRN2-6: Notify admins when a approve/invite user signs up (#538)

* Notify admins when a approve/invite user signs up

* Fix formating

* Uses admins_url variable
This commit is contained in:
shawn-higgins1
2019-05-22 13:38:00 -04:00
committed by Jesus Federico
parent 83a9edf81d
commit f88d67f6fb
12 changed files with 270 additions and 0 deletions

View File

@ -223,6 +223,36 @@ describe SessionsController, type: :controller do
expect(response).to redirect_to(root_path)
end
context 'registration notification emails' do
before do
allow(Rails.configuration).to receive(:enable_email_verification).and_return(true)
@user = create(:user, provider: "greenlight")
@admin = create(:user, provider: "greenlight", email: "test@example.com")
@admin.add_role :admin
end
it "should notify admin on new user signup with approve/reject registration" do
allow_any_instance_of(Registrar).to receive(:approval_registration).and_return(true)
request.env["omniauth.auth"] = OmniAuth.config.mock_auth[:bn_launcher]
expect { get :omniauth, params: { provider: 'bn_launcher' } }
.to change { ActionMailer::Base.deliveries.count }.by(1)
end
it "should notify admin on new user signup with invite registration" do
allow_any_instance_of(Registrar).to receive(:invite_registration).and_return(true)
invite = Invitation.create(email: "user@google.com", provider: "greenlight")
@request.session[:invite_token] = invite.invite_token
request.env["omniauth.auth"] = OmniAuth.config.mock_auth[:bn_launcher]
expect { get :omniauth, params: { provider: 'bn_launcher' } }
.to change { ActionMailer::Base.deliveries.count }.by(1)
end
end
end
it "should not create session without omniauth env set for bn_launcher" do