diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index 6c50f12..966f3ac 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -1,36 +1,36 @@ class UserMailer < ActionMailer::Base default from: Archiving.settings[:default_sender] # Notifies the host's owners that the host has been verified by an admin # and is now ready to be configured # # @param user_emails[Array] the owners' emails # @param host[String] the host's FQDN def notify_for_verification(user_emails, host) @host = host s = "[Archiving] Host #{host.name} verification" mail(to: user_emails, subject: s) end # Notifies the user that another user has requested that he should be able to # manage the given client's backups # # @param email[String] the user's email # @param invitation[Invitation] the target host def notify_for_invitation(email, invitation) @invitation = invitation subject = "[Archiving] Invitation to manage #{@invitation.host.name}'s backups" mail(to: email, subject: subject) end # Notifies admins about a new host that needs verification # # @param user[User] the user that created the host # @param host[String] the host's FQDN def notify_admin(user, host) - admin_emails = User.admin.pluck(:email) + admin_emails = User.admin.where(enabled: true).pluck(:email) @user = user @host = host mail(to: admin_emails, subject: 'New host pending verification') end end diff --git a/spec/factories/user.rb b/spec/factories/user.rb index 3688e52..e43e286 100644 --- a/spec/factories/user.rb +++ b/spec/factories/user.rb @@ -1,13 +1,14 @@ FactoryGirl.define do factory :user do sequence(:username) { |n| "user-#{n}" } user_type 0 sequence(:email) { |n| "user-#{n}@grnet.gr" } end trait :admin do after(:create) do |user| + user.enabled = true user.admin! end end end