Commit fc504b30 by Tan Phat Nguyen

Order mailer buider, css image , title

parent d5e3c08a
......@@ -109,4 +109,11 @@ h2 {
.alert-notice {
@extend .alert-success;
}
.prod-title {
//height: 40px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
\ No newline at end of file
......@@ -25,7 +25,7 @@ class OrdersController < ApplicationController
if @order.save
current_cart.destroy
session[:cart_id] = nil
Notifier.order_received(@order).deliver
MailOrder.confirm(@order).deliver
flash[:success] = 'Successfully. Thank you for your order.'
redirect_to root_path
else
......
class Notifier < ActionMailer::Base
class MailOrder < ActionMailer::Base
default from: 'bigforest20@gmail.com'
def order_received(order)
def confirm(order)
@order = order
mail to: order.email, subject: 'Venshop Store Order Confirmation'
end
end
\ No newline at end of file
end
......@@ -18,4 +18,4 @@
</tr>
</table>
<br/>
<div>We'll send you a separate e-mail when your order ships.</div>
<div>We'll send you a separate e-mail when your order ships.</div>
\ No newline at end of file
MailOrder#confirm
<%= @greeting %>, find me in app/views/mail_order/confirm.text.erb
Dear <%= @order.name %>
Thank you for your recent order from The Venshop Store.
You ordered the following items:
We'll send you a separate e-mail when your order ships.
......@@ -2,7 +2,7 @@
<div style='height: 234px;'>
<%= image_tag product.photo_url.to_s, width: '140', height: '140', class: 'img-thumbnail' %>
</div>
<h4><%= link_to product.name, product_path(product) %></h4>
<div class='prod-title'><h4><%= link_to product.name, product_path(product) %></h4></div>
<span class='price-col'>$<%= product.price %></span>
<%= button_to 'Add to Cart', line_items_path(product_id: product), { class: 'btn btn-default' } %>
</div>
\ No newline at end of file
......@@ -22,8 +22,8 @@ Rails.application.configure do
port: 587,
domain: 'gmail.com',
authentication: 'plain',
user_name: ENV['pusher_email_user'],
password: ENV['pusher_email_password'],
user_name: ENV['email_user'],
password: ENV['email_password'],
enable_starttls_auto: true
}
......
......@@ -73,9 +73,9 @@ namespace :db do
def build_request
@request = Vacuum.new
@request.configure(
aws_access_key_id: ENV['pusher_aws_access_key_id'],
aws_secret_access_key: ENV['pusher_aws_secret_access_key'],
associate_tag: ENV['pusher_associate_tag']
aws_access_key_id: ENV['aws_access_key_id'],
aws_secret_access_key: ENV['aws_secret_access_key'],
associate_tag: ENV['associate_tag']
)
end
......
require 'test_helper'
class NotifierTest < ActionMailer::TestCase
test "order_received" do
mail = Notifier.order_received
assert_equal "Order received", mail.subject
class MailOrderTest < ActionMailer::TestCase
test "confirm" do
mail = MailOrder.confirm
assert_equal "Confirm", mail.subject
assert_equal ["to@example.org"], mail.to
assert_equal ["from@example.com"], mail.from
assert_match "Hi", mail.body.encoded
end
end
# Preview all emails at http://localhost:3000/rails/mailers/mail_order
class MailOrderPreview < ActionMailer::Preview
# Preview this email at http://localhost:3000/rails/mailers/mail_order/confirm
def confirm
MailOrder.confirm
end
end
# Preview all emails at http://localhost:3000/rails/mailers/notifier
class NotifierPreview < ActionMailer::Preview
# Preview this email at http://localhost:3000/rails/mailers/notifier/order_received
def order_received
Notifier.order_received
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment