diff --git a/app/controllers/avo/tests_controller.rb b/app/controllers/avo/tests_controller.rb new file mode 100644 index 0000000000000000000000000000000000000000..bd4a16da72231849df6fb8e5828c96d725ae9c92 --- /dev/null +++ b/app/controllers/avo/tests_controller.rb @@ -0,0 +1,11 @@ +module Avo + class TestsController < ApplicationController + rate_limit to: 1, within: 1.minute, only: :send_test_email, with: -> { redirect_to avo.avo_dashboards_path.concat("/home"), alert: "You can only send one test email every 60 seconds." } + + def send_test_email + AdminsMailer.test_email.deliver_later + + redirect_to avo.avo_dashboards_path.concat("/home"), notice: "Test email sent successfully!" + end + end +end diff --git a/app/mailers/admins_mailer.rb b/app/mailers/admins_mailer.rb index 37703ae695d58884f58296775960e52cd5667211..cbda443f04442f93c173156ec0c7cd43da4656db 100644 --- a/app/mailers/admins_mailer.rb +++ b/app/mailers/admins_mailer.rb @@ -5,4 +5,8 @@ class AdminsMailer < ApplicationMailer @user = user mail(to: ADMINS_EMAIL, subject: "Facem: New User Created") end + + def test_email + mail(to: ADMINS_EMAIL, subject: "Facem: Test Email for Admins") + end end diff --git a/app/views/admins_mailer/test_email.html.erb b/app/views/admins_mailer/test_email.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..4a8902fa00f7bcab6a35e52a21f6481e4798e086 --- /dev/null +++ b/app/views/admins_mailer/test_email.html.erb @@ -0,0 +1,3 @@ +<p>Hey there,</p> + +<p>this is just a test email to check how admin emails are distributed.</p> diff --git a/app/views/admins_mailer/test_email.text.erb b/app/views/admins_mailer/test_email.text.erb new file mode 100644 index 0000000000000000000000000000000000000000..06eb0982cf978ab82126f7b229527d162550d13f --- /dev/null +++ b/app/views/admins_mailer/test_email.text.erb @@ -0,0 +1,3 @@ +Hey there, + +this is just a test email to check how admin emails are distributed. \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index ff09c0439d646881c97df780179de9b1acc26c5b..985409e0781e17b9fcd1ec79373280eb727c1bc0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -22,5 +22,9 @@ if defined? ::Avo get "change_password", to: "settings#edit_password", as: :settings_password put "change_password", to: "settings#update_password" end + + scope :tests do + get "send_email_to_admins", to: "tests#send_test_email", as: :test_email_send + end end end