Skip to content

Commit

Permalink
Mailing controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
rpruizc committed Jun 20, 2020
1 parent 8834313 commit 47b0b49
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/controllers/posts_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class PostsController < ApplicationController
before_action :set_post, only: [:show, :edit, :update, :destroy]
before_action :require_user!
# before_action :require_user!

# GET /posts
# GET /posts.json
Expand All @@ -11,6 +11,7 @@ def index
# GET /posts/1
# GET /posts/1.json
def show
SubscriptionMailer.test_email.deliver_later
end

# GET /posts/new
Expand Down
2 changes: 1 addition & 1 deletion app/mailers/application_mailer.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class ApplicationMailer < ActionMailer::Base
default from: 'from@example.com'
default from: 'subscriptions@remotearn.xyz'
layout 'mailer'
end
2 changes: 2 additions & 0 deletions app/mailers/jobs_mailer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class JobsMailer < ApplicationMailer
end
14 changes: 14 additions & 0 deletions app/mailers/subscription_mailer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class SubscriptionMailer < ApplicationMailer
# Default Mail Values
default from: 'subscription@remotearn.xyz', to: 'rpruiz@gmail.com'

def welcome_email(user)
@user = user
# Overriding the 'to' default
mail(to: @user.email, subject: 'Test from rails')
end

def test_email
mail(to: 'rpruiz@gmail.com', subject: 'Test from rails')
end
end
1 change: 1 addition & 0 deletions app/views/subscription_mailer/test_email.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>This is a test email</p>
3 changes: 3 additions & 0 deletions app/views/subscription_mailer/welcome_email.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<p>Dear <%= @user.email %>, </p>

<p>This is a test from the passwordless gem</p>
1 change: 1 addition & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ class Application < Rails::Application
# Application configuration can go into files in config/initializers
# -- all .rb files in that directory are automatically loaded after loading
# the framework and any gems in your application.
config.action_mailer.delivery_method = :mailjet_api
end
end
7 changes: 7 additions & 0 deletions test/mailers/jobs_mailer_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'test_helper'

class JobsMailerTest < ActionMailer::TestCase
# test "the truth" do
# assert true
# end
end
4 changes: 4 additions & 0 deletions test/mailers/previews/jobs_mailer_preview.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Preview all emails at http://localhost:3000/rails/mailers/jobs_mailer
class JobsMailerPreview < ActionMailer::Preview

end
4 changes: 4 additions & 0 deletions test/mailers/previews/subscription_mailer_preview.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Preview all emails at http://localhost:3000/rails/mailers/subscription_mailer
class SubscriptionMailerPreview < ActionMailer::Preview

end
7 changes: 7 additions & 0 deletions test/mailers/subscription_mailer_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'test_helper'

class SubscriptionMailerTest < ActionMailer::TestCase
# test "the truth" do
# assert true
# end
end

0 comments on commit 47b0b49

Please sign in to comment.