diff --git a/app/controllers/oauths_controller.rb b/app/controllers/oauths_controller.rb index 9495375..815cbbb 100644 --- a/app/controllers/oauths_controller.rb +++ b/app/controllers/oauths_controller.rb @@ -14,9 +14,6 @@ class OauthsController < ApplicationController else begin @user = create_from(provider) - # NOTE: this is the place to add '@user.activate!' if you - # are using user_activation submodule - reset_session # protect from session fixation attack auto_login(@user) redirect_to root_path, notice: "Logged in from #{provider.titleize}!" diff --git a/app/helpers/oauths_helper.rb b/app/helpers/oauths_helper.rb deleted file mode 100644 index d6a2251..0000000 --- a/app/helpers/oauths_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module OauthsHelper -end diff --git a/app/mailers/account_mailer.rb b/app/mailers/account_mailer.rb index 569df6e..0569ab0 100644 --- a/app/mailers/account_mailer.rb +++ b/app/mailers/account_mailer.rb @@ -1,6 +1,23 @@ class AccountMailer < ApplicationMailer - def activation_needed - @blarg = "This was blarg" - mail(to: 'markamoser+test@gmail.com', subject: 'Activate me please!') + # Subject can be set in your I18n file at config/locales/en.yml + # with the following lookup: + # + # en.account_mailer.activation_needed_email.subject + # + def activation_needed_email(user) + @greeting = "Hi" + @user = user + mail to: Person.admins.map(&:email).join(', ') + end + + # Subject can be set in your I18n file at config/locales/en.yml + # with the following lookup: + # + # en.account_mailer.activation_success_email.subject + # + def activation_success_email(user) + @greeting = "Hi" + @user = user + mail to: user.email end end diff --git a/app/views/account_mailer/activation_needed.html.haml b/app/views/account_mailer/activation_needed.html.haml deleted file mode 100644 index eacb9f0..0000000 --- a/app/views/account_mailer/activation_needed.html.haml +++ /dev/null @@ -1,4 +0,0 @@ -!!! -%h3 Activate me please - -%p and then: #{@blarg} diff --git a/app/views/account_mailer/activation_needed_email.html.haml b/app/views/account_mailer/activation_needed_email.html.haml new file mode 100644 index 0000000..75c3d34 --- /dev/null +++ b/app/views/account_mailer/activation_needed_email.html.haml @@ -0,0 +1,4 @@ +%h1= "AccountMailer#" + @action.to_s + +%p + = @greeting + ", find me in app/views/account_mailer/activation_needed_email.html.haml" diff --git a/app/views/account_mailer/activation_needed_email.text.haml b/app/views/account_mailer/activation_needed_email.text.haml new file mode 100644 index 0000000..a571a95 --- /dev/null +++ b/app/views/account_mailer/activation_needed_email.text.haml @@ -0,0 +1,3 @@ +AccountMailer#activation_needed_email + += @greeting + ", find me in app/views/account_mailer/activation_needed_email.text.haml" diff --git a/app/views/account_mailer/activation_success_email.html.haml b/app/views/account_mailer/activation_success_email.html.haml new file mode 100644 index 0000000..69d9881 --- /dev/null +++ b/app/views/account_mailer/activation_success_email.html.haml @@ -0,0 +1,4 @@ +%h1= "AccountMailer#" + @action.to_s + +%p + = @greeting + ", find me in app/views/account_mailer/activation_success_email.html.haml" diff --git a/app/views/account_mailer/activation_success_email.text.haml b/app/views/account_mailer/activation_success_email.text.haml new file mode 100644 index 0000000..e7c4531 --- /dev/null +++ b/app/views/account_mailer/activation_success_email.text.haml @@ -0,0 +1,3 @@ +AccountMailer#activation_success_email + += @greeting + ", find me in app/views/account_mailer/activation_success_email.text.haml" diff --git a/app/views/layouts/mailer.html.haml b/app/views/layouts/mailer.html.haml index 28739ee..646235b 100644 --- a/app/views/layouts/mailer.html.haml +++ b/app/views/layouts/mailer.html.haml @@ -1,3 +1,4 @@ +!!! %hmtl %body - = yield \ No newline at end of file + = yield diff --git a/config/initializers/sorcery.rb b/config/initializers/sorcery.rb index 1ddfc04..dc5657d 100644 --- a/config/initializers/sorcery.rb +++ b/config/initializers/sorcery.rb @@ -282,7 +282,7 @@ Rails.application.config.sorcery.configure do |config| # your mailer class. Required. # Default: `nil` # - # user.user_activation_mailer = + user.user_activation_mailer = AccountMailer # when true sorcery will not automatically @@ -290,7 +290,7 @@ Rails.application.config.sorcery.configure do |config| # manually handle how and when email is sent. # Default: `false` # - user.activation_mailer_disabled = true + # user.activation_mailer_disabled = # activation needed email method on your mailer class. diff --git a/test/mailers/account_mailer_test.rb b/test/mailers/account_mailer_test.rb index f5d6e54..760ddbc 100644 --- a/test/mailers/account_mailer_test.rb +++ b/test/mailers/account_mailer_test.rb @@ -1,7 +1,21 @@ require 'test_helper' class AccountMailerTest < ActionMailer::TestCase - # test "the truth" do - # assert true - # end + test "activation_needed_email" do + user = Person.new + mail = AccountMailer.activation_needed_email user + assert_equal "Activation needed email", mail.subject + assert_match "Hi", mail.body.encoded + # assert_equal ["to@example.org"], mail.to + # assert_equal ["from@example.com"], mail.from + end + + test "activation_success_email" do + user = Person.new + mail = AccountMailer.activation_success_email user + assert_equal "Activation success email", mail.subject + assert_match "Hi", mail.body.encoded + # assert_equal ["to@example.org"], mail.to + # assert_equal ["from@example.com"], mail.from + end end diff --git a/test/mailers/previews/account_mailer_preview.rb b/test/mailers/previews/account_mailer_preview.rb index 9a25e39..3327136 100644 --- a/test/mailers/previews/account_mailer_preview.rb +++ b/test/mailers/previews/account_mailer_preview.rb @@ -1,3 +1,14 @@ # Preview all emails at http://localhost:3000/rails/mailers/account_mailer class AccountMailerPreview < ActionMailer::Preview + # Preview this email at http://localhost:3000/rails/mailers/account_mailer/activation_needed_email + def activation_needed_email + user = Person.new + AccountMailer.activation_needed_email user + end + + # Preview this email at http://localhost:3000/rails/mailers/account_mailer/activation_success_email + def activation_success_email + user = Person.new + AccountMailer.activation_success_email user + end end