forked from External/greenlight
GRN2-148: Always check that email notifications are enabled before sending an email (#539)
* Always check that email notificatiosn are enabled before sending an email * Fix tests * Fix formating * Change to hardcoding the validation
This commit is contained in:
parent
f88d67f6fb
commit
eac8290001
|
@ -21,12 +21,16 @@ module Emailer
|
|||
|
||||
# Sends account activation email.
|
||||
def send_activation_email(user)
|
||||
return unless Rails.configuration.enable_email_verification
|
||||
|
||||
@user = user
|
||||
UserMailer.verify_email(@user, user_verification_link, logo_image, user_color).deliver
|
||||
end
|
||||
|
||||
# Sends password reset email.
|
||||
def send_password_reset_email(user)
|
||||
return unless Rails.configuration.enable_email_verification
|
||||
|
||||
@user = user
|
||||
UserMailer.password_reset(@user, reset_link, logo_image, user_color).deliver_now
|
||||
end
|
||||
|
@ -41,11 +45,15 @@ module Emailer
|
|||
|
||||
# Sends inivitation to join
|
||||
def send_invitation_email(name, email, token)
|
||||
return unless Rails.configuration.enable_email_verification
|
||||
|
||||
@token = token
|
||||
UserMailer.invite_email(name, email, invitation_link, logo_image, user_color).deliver_now
|
||||
end
|
||||
|
||||
def send_user_approved_email(user)
|
||||
return unless Rails.configuration.enable_email_verification
|
||||
|
||||
UserMailer.approve_user(user, root_url, logo_image, user_color).deliver_now
|
||||
end
|
||||
|
||||
|
|
|
@ -26,6 +26,10 @@ describe AdminsController, type: :controller do
|
|||
end
|
||||
|
||||
describe "User Roles" do
|
||||
before do
|
||||
allow(Rails.configuration).to receive(:enable_email_verification).and_return(true)
|
||||
end
|
||||
|
||||
context "GET #index" do
|
||||
it "renders a 404 if a user tries to acccess it" do
|
||||
@request.session[:user_id] = @user.id
|
||||
|
|
Loading…
Reference in New Issue