Skip to content
Snippets Groups Projects
Commit 59387a6d authored by Marcela Ribeiro de Oliveira's avatar Marcela Ribeiro de Oliveira
Browse files

Merge branch 'suggestions-mailer' into 'master'

Suggestions mailer

See merge request !412
parents 0f70c783 413a4f78
No related branches found
No related tags found
No related merge requests found
......@@ -32,7 +32,7 @@ test:
stage: test
script:
- bundle exec rake db:migrate:reset RAILS_ENV=test
- rake spec:acceptance
- bundle exec rake spec:acceptance
tags:
- ruby
- postgres
......
......@@ -18,6 +18,7 @@ class V1::ContactsController < ApplicationController
def create
@contact = Contact.new(contact_params)
if @contact.save
ContactsMailer.new_contact_received(@contact).deliver_now
render json: @contact, status: :created
else
render json: @contact.errors, status: :unprocessable_entity
......@@ -27,6 +28,7 @@ class V1::ContactsController < ApplicationController
# PATCH/PUT v1/contacts/1
def update
if @contact.update(contact_params)
ContactsMailer.contact_updated(@contact).deliver_now
render json: @contact
else
render json: @contact.errors, status: :unprocessable_entity
......
......@@ -19,6 +19,7 @@ class V1::SuggestionsController < ApplicationController
@suggestion = Suggestion.new(suggestion_params)
if @suggestion.save
SuggestionsMailer.new_suggestion_received(@suggestion).deliver_now
render json: @suggestion, status: :created
else
render json: @suggestion.errors, status: :unprocessable_entity
......@@ -28,6 +29,7 @@ class V1::SuggestionsController < ApplicationController
# PATCH/PUT v1/suggestions/1
def update
if @suggestion.update(suggestion_params)
SuggestionsMailer.suggestion_updated(@suggestion).deliver_now
render json: @suggestion
else
render json: @suggestion.errors, status: :unprocessable_entity
......
class ApplicationMailer < ActionMailer::Base
default from: 'from@example.com'
layout 'mailer'
default to: 'portalmec_tec@inf.ufpr.br'
default from: 'portalmec@inf.ufpr.br'
#layout 'mailer'
end
class ContactsMailer < ApplicationMailer
def new_contact_received(contact)
@contact = contact
@subject = "Contato de " + @contact.name
mail(subject: @subject)
end
def contact_updated(contact)
@contact = contact
@subject = "O contato de " + @contact.name + " foi atualizado"
mail(subject: @subject)
end
end
class SuggestionsMailer < ApplicationMailer
def new_suggestion_received(suggestion)
@suggestion = suggestion
@subject = "Sugestão de " + @suggestion.name
mail(subject: @subject)
end
def suggestion_updated(suggestion)
@suggestion = suggestion
@subject = "A sugestão de " + @suggestion.name + " foi atualizada"
mail(subject: @subject)
end
end
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>/* Email styles need to be inline */</style>
</head>
<body>
<h2>Nome do contato: <%= @contact.name %></h1>
<h2>Email do contato: <%= @contact.email %></h1>
<h2>Mensagem: <%= @contact.message %></h1>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>/* Email styles need to be inline */</style>
</head>
<body>
<h2>Nome do contato: <%= @contact.name %></h1>
<h2>Email do contato: <%= @contact.email %></h1>
<h2>Mensagem: <%= @contact.message %></h1>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>/* Email styles need to be inline */</style>
</head>
<body>
<h2>Nome: <%= @suggestion.name %></h1>
<h2>Link: <%= @suggestion.link %></h1>
<h2>Descrição: <%= @suggestion.description %></h1>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>/* Email styles need to be inline */</style>
</head>
<body>
<h2>Nome: <%= @suggestion.name %></h1>
<h2>Link: <%= @suggestion.link %></h1>
<h2>Descrição: <%= @suggestion.description %></h1>
</body>
</html>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment