Split up mailers (#260)

* Fix lint

* Split up mailers WIP

* Create spec for ScholarshipMailer

* Create spec for MembershipMailer

* Update to new mail classes

* Remove if/else development cases

* Fix lint
This commit is contained in:
Mac Siri 2018-05-01 18:12:26 -04:00 committed by Ben Halpern
parent c59a4f10be
commit f810b9a778
34 changed files with 356 additions and 388 deletions

View file

View file

@ -1,6 +1,7 @@
class ApplicationMailer < ActionMailer::Base
default from: "The DEV Community <yo@dev.to>"
layout "mailer"
default template_path: ->(mailer) { "mailers/#{mailer.class.name.underscore}" }
def generate_unsubscribe_token(id, email_type)
Rails.application.message_verifier(:unsubscribe).generate(

View file

@ -1,16 +1,16 @@
class DigestMailer < ApplicationMailer
default from: "DEV Digest <yo@dev.to>"
def digest_email(user, articles)
@user = if Rails.env.development?
User.first
else
user
end
@user = user
@articles = articles.first(6)
@unsubscribe = generate_unsubscribe_token(@user.id, :email_digest_periodic)
@digest_email = true
mail(from: "DEV Digest <yo@dev.to>", to: @user.email, subject: "#{adjusted_title(@articles.first)} + #{@articles.size - 1} #{email_end_phrase} #{random_emoji}") do |format|
format.html { render "layouts/mailer" }
end
subject = generate_title(@articles)
mail(to: @user.email, subject: subject)
end
def generate_title(articles)
"#{adjusted_title(articles.first)} + #{articles.size - 1} #{email_end_phrase} #{random_emoji}"
end
def adjusted_title(article)

View file

@ -0,0 +1,19 @@
class MembershipMailer < ApplicationMailer
default from: "DEV Members <members@dev.to>"
def new_membership_subscription_email(user, subscription_type)
@user = user
@subscription_type = subscription_type
mail(to: @user.email, subject: "Thanks for subscribing!")
end
def subscription_update_confirm_email(user)
@user = user
mail(to: @user.email, subject: "Your subscription has been updated.")
end
def subscription_cancellation_email(user)
@user = user
mail(to: @user.email, subject: "Sorry to lose you.")
end
end

View file

@ -1,34 +1,19 @@
class NotifyMailer < ApplicationMailer
def new_reply_email(comment)
@user = if Rails.env.development?
User.first
else
comment.parent_user
end
@user = comment.parent_user
return if RateLimitChecker.new.limit_by_email_recipient_address(@user.email)
@unsubscribe = generate_unsubscribe_token(@user.id, :email_comment_notifications)
@comment = comment
mail(to: @user.email, subject: "#{@comment.user.name} replied to your #{@comment.parent_type}") do |format|
format.html { render "layouts/mailer" }
format.text { render plain: "#{@comment.user.name} replied to your #{@comment.parent_type}:\n\n#{ActionController::Base.helpers.strip_tags(comment.processed_html.html_safe)}\n\nView now: https://dev.to#{comment.path}" }
end
mail(to: @user.email, subject: "#{@comment.user.name} replied to your #{@comment.parent_type}")
end
def new_follower_email(follow)
@user = if Rails.env.development?
User.first
else
follow.followable
end
@user = follow.followable
return if RateLimitChecker.new.limit_by_email_recipient_address(@user.email)
@follower = follow.follower
@unsubscribe = generate_unsubscribe_token(@user.id, :email_follower_notifications)
mail(to: @user.email, subject: "#{@follower.name} just followed you on dev.to") do |format|
format.html { render 'layouts/mailer' }
format.text { render plain: "#{@follower.name} just followed you. When someone follows you, your posts will be prioritized on their personalized home feed. This new feature is one step towards offering a more customized experience." }
end
mail(to: @user.email, subject: "#{@follower.name} just followed you on dev.to")
end
def new_mention_email(mention)
@ -39,76 +24,15 @@ class NotifyMailer < ApplicationMailer
@mention = mention
@unsubscribe = generate_unsubscribe_token(@user.id, :email_mention_notifications)
mail(to: @user.email, subject: "#{@mentioner.name} just mentioned you!") do |format|
format.html { render 'layouts/mailer' }
format.text { render plain: "#{@mentioner.name} just mentioned you in their #{mention.mentionable_type.downcase}\n\n#{ActionController::Base.helpers.strip_tags(@mentionable.processed_html.html_safe)}\n\nView now: https://dev.to#{mention.mentionable.path}" }
end
mail(to: @user.email, subject: "#{@mentioner.name} just mentioned you!")
end
def unread_notifications_email(user)
@user = if Rails.env.development?
User.first
else
user
end
@user = user
return if RateLimitChecker.new.limit_by_email_recipient_address(@user.email)
@unread_notifications_count = NotificationCounter.new(@user).unread_notification_count
@unsubscribe = generate_unsubscribe_token(@user.id, :email_unread_notifications)
mail(to: @user.email, subject: "🔥 You have #{@unread_notifications_count} unread notifications on dev.to") do |format|
format.html { render 'layouts/mailer' }
format.text { render plain: "Visit https://dev.to/notifications to read all of your notifications" }
end
end
def new_membership_subscription_email(user,subscription_type)
@user = if Rails.env.development?
User.first
else
user
end
@subscription_type = subscription_type
mail(from: "DEV Members <members@dev.to>", to: @user.email, subject: "Thanks for subscribing!") do |format|
format.html { render "layouts/mailer" }
format.text { render plain: "Visit https://dev.to/settings/membership for full details" }
end
end
def subscription_update_confirm_email(user)
@user = if Rails.env.development?
User.first
else
user
end
@update_subscription = true
mail(from: "DEV Members <members@dev.to>", to: @user.email, subject: "Your subscription has been updated.") do |format|
format.html { render "layouts/mailer" }
format.text { render plain: "Visit https://dev.to/settings/membership for updated details" }
end
end
def subscription_cancellation_email(user)
@user = if Rails.env.development?
User.first
else
user
end
@cancel_subscription = true
mail(from: "members@dev.to", to: @user.email, subject: "Sorry to lose you.") do |format|
format.html { render "layouts/mailer" }
format.text { render plain: " If you could send feedback to yo@dev.to to help us improve it would be much appreciated." }
end
end
def scholarship_awarded_email(user)
@user = if Rails.env.development?
User.first
else
user
end
@scholarship_awarded = true
mail(from: "members@dev.to", to: @user.email, subject: "Congrats on your DEV Scholarship!") do |format|
format.html { render "layouts/mailer" }
format.text { render plain: "Congratulations on your dev.to Scholarship! See https://dev.to/settings/misc for updated details" }
end
subject = "🔥 You have #{@unread_notifications_count} unread notifications on dev.to"
mail(to: @user.email, subject: subject)
end
end

View file

@ -0,0 +1,6 @@
class ScholarshipMailer < ApplicationMailer
def scholarship_awarded_email(user)
@user = user
mail(from: "members@dev.to", to: @user.email, subject: "Congrats on your DEV Scholarship!")
end
end

View file

@ -91,14 +91,14 @@ class MembershipService
end
def send_welcome_email
NotifyMailer.delay.new_membership_subscription_email(user, user.roles.last.name)
MembershipMailer.delay.new_membership_subscription_email(user, user.roles.last.name)
end
def send_update_email
NotifyMailer.delay.subscription_update_confirm_email(user)
MembershipMailer.delay.subscription_update_confirm_email(user)
end
def send_cancellation_email
NotifyMailer.delay.subscription_cancellation_email(user)
MembershipMailer.delay.subscription_cancellation_email(user)
end
end

View file

@ -38,7 +38,7 @@ class UserRoleService
if params[:scholar] == "1"
@user.add_role(:workshop_pass)
@user.update(workshop_expiration: params[:workshop_expiration])
NotifyMailer.delay.scholarship_awarded_email(@user) if params[:scholar_email] == "1"
ScholarshipMailer.delay.scholarship_awarded_email(@user) if params[:scholar_email] == "1"
else
@user.remove_role(:workshop_pass)
end

View file

@ -1,222 +0,0 @@
<% if @comment %>
<h2 style="font-size:25px;"><%= link_to(@comment.user.name, "https://dev.to/#{@comment.user.username}") %> replied to you on dev.to</h2>
<table><tr><td style='color:#c3c3c3;font-size:14px;padding-bottom:8px'>
<% unless @comment.is_root? %>
<%= truncate(strip_tags(@comment.parent_or_root_article.processed_html.html_safe), length: 80) %>
<% end %>
</td></tr><tr><td style='padding:20px;padding-bottom:30px;border-radius:3px;font-size:19px;background:#f4f4f4'>
<h2 style="font-size:22px;color:rgb(107, 107, 107)">re: <em><%= @comment.commentable.title %></em></h2>
<%= @comment.processed_html.html_safe %>
<a style="background:#3c7dc1;color:white;padding:5px 14px;border-radius:3px;text-decoration:none;display:inline-block;margin-top:4px;" href='https://dev.to<%=@comment.path%>'>read & reply</a> <a style="background:#1f1f1f;color:white;padding:5px 14px;border-radius:3px;text-decoration:none;display:inline-block;margin-top:4px;" href='https://dev.to<%=@comment.commentable.path%>'>read original post</a>
</td></tr></table>
<% elsif @follower %>
<% if Follow.where(followable_id: @user.id, followable_type: "User").where("created_at > ?", 24.hours.ago).size > 1 %>
<h3 style="font-weight:600;font-size:0.95em;color:#3ac1b4">You have <%= Follow.where(followable_id: @user.id, followable_type: "User").where("created_at > ?", 24.hours.ago).size %> new DEV followers in the past day!</h3>
<% end %>
<h2 style="font-size:32px;"><a href="https://dev.to/<%= @follower.username %>"><%= @follower.name %></a> just followed you 🤗</h2>
<h3 style="font-weight:600">You now have <%= pluralize(@user.followers_count, 'total follower') %>. See all of your recent followers <a href="https://dev.to/dashboard/user_followers">right here</a>.</h3>
<p>
When someone follows you on <a href="https://dev.to">dev.to</a>, your posts will be prioritized in their feed and notifications. The perks of popularity I suppose.
</p>
<% elsif @unread_notifications_count %>
<h3 style="font-weight:300">You're popular!</h3>
<p>
<a style="background:#3c7dc1;color:white;padding:5px 14px;border-radius:3px;text-decoration:none;display:inline-block;margin-top:4px;font-size:33px;" href='https://dev.to/notifications'>Read my notifications</a>
</p>
<% elsif @mentioner %>
<h2 style="font-size:25px;"><a href="https://dev.to/<%= @mentioner.username %>"><%= @mentioner.name %></a> just mentioned you in their <%= @mention.mentionable_type.downcase %>!</h2>
<table><tr><td style='color:#c3c3c3;font-size:14px;padding-bottom:8px'>
</td></tr><tr><td style='padding:20px;padding-bottom:30px;border-radius:3px;font-size:19px;background:#f4f4f4'>
<%= @mentionable.processed_html.html_safe %>
<a style="background:#3c7dc1;color:white;padding:5px 14px;border-radius:3px;text-decoration:none;display:inline-block;margin-top:4px;" href='https://dev.to<%=@mention.mentionable.path%>'>read & reply</a>
</td></tr></table>
<% elsif @subscription_type %>
<img src="https://thepracticaldev.s3.amazonaws.com/i/186bp9xbue90w504wn97.png" style="height:200px; display: block; margin-left: auto; margin-right: auto;"/>
<% if @subscription_type == "triple_unicorn_member" %>
<p>
Whoa! Youre the best, and so generous. We tip our hats to you.
</p>
<p>
As a triple-unicorn, you have full access to all dev.to workshops! Well be releasing our workshop schedule Early February.
</p>
<p>
Youll see your name at the featured position on our Wall of Patrons and Scholars within the next few days, and you can claim your swag pack now by visiting your <a href="https://dev.to/settings/membership">settings page</a>.
</p>
<p>
Well be in touch to schedule a time for all of us to chat together, and well also be putting together some additional goodies.
</p>
<p>
Thank you again for supporting The DEV Community. Your membership means a lot to us, and all the recipients of our scholarship fund. You went above and beyond on this one.
</p>
<% elsif @subscription_type == "level_4_member" %>
<p>
Thank you for becoming a DEV sustaining member. Your support means the world to us.
</p>
<p>
As part of your membership, youll have early access to beta features on the site. For instance, post analytics have now been added to your <a href="https://dev.to/dashboard/">dashboard</a>.
</p>
<p>
On your <a href="https://dev.to/settings/membership">membership settings page</a>, youll find the coupon that youll use to request your exclusive sticker pack and t-shirt combo.
</p>
<p>
Your name will appear on our “Wall of Patrons and Scholars” soon, and youll also be receiving full access to all dev.to workshops! Well be releasing our first workshop schedule in early February.
</p>
<p>
Above all, thank you for supporting The DEV Community. Your additional contribution means so much to us, and to all the recipients of our scholarship fund. You really went above and beyond on this one.
</p>
<p>
With sincere gratitude...
</p>
<p>
❤️
<br/>
PBJ
</p>
<p>
PS — feel free to reply to this email with any questions.
</p>
<% elsif @subscription_type == "level_3_member" %>
<p>
Thank you for becoming a DEV sustaining member. Your support means the world to us.
</p>
<p>
As part of your membership, youll have early access to beta features on the site. For instance, post analytics have now been added to your <a href="https://dev.to/dashboard/">dashboard</a>.
</p>
<p>
On your membership <a href="https://dev.to/settings/membership">settings page</a>, youll find the coupon that youll use to request your exclusive sticker pack and t-shirt combo.
</p>
<p>
Your name will appear on our “Wall of Patrons and Scholars” soon, and youll also be receiving full access to all dev.to workshops! Well be releasing our first workshop schedule in early February.
</p>
<p>
Feel free to reply to this email with any questions :)
</p>
<p>
Thanks again! ❤️
<br/>
PBJ
</p>
<% elsif @subscription_type == "level_2_member" %>
<p>
Thank you for becoming a DEV sustaining member. Your support means the world to us.
</p>
<p>
As part of your membership, youll have early access to beta features on the site. For instance, post analytics have now been added to your <a href="https://dev.to/dashboard/">dashboard</a>.
</p>
<p>
On your <a href="https://dev.to/settings/membership">membership settings</a> page, youll find the coupon that youll use to request your exclusive sticker pack. Within the next few days, youll be appearing on our Wall of Patrons and Scholars.
</p>
<p>
Feel free to reply to this email with any questions :)
</p>
<p>
Thanks again! ❤️
<br/>
PBJ
</p>
<% elsif @subscription_type == "level_1_member" %>
<p>
Thank you for becoming a DEV sustaining member. Your support means the world to us.
</p>
<p>
As part of your membership, youll have early access to beta features on the site. For instance, post analytics have now been added to your <a href="https://dev.to/dashboard/">dashboard</a>.
</p>
<p>
Within the next few days, youll also appear on our Wall of Patrons and Scholars.
</p>
<p>
Feel free to reply to this email with any questions :)
</p>
<p>
Thanks again! ❤️
<br/>
PBJ
</p>
<% end %>
<h2 style="font-size:25px;">Thank you so much for your support.</h2>
<p>
Visit <a href="https://dev.to/settings/membership">Your membership settings page</a> for all details.
</p>
<% elsif @update_subscription %>
<img src="<%= asset_path 'sustaining-membership.svg' %>" style="height:200px; display: block; margin-left: auto; margin-right: auto;"/>
<p>
Your DEV sustaining membership monthly contribution amount has been updated. Be sure to check your <a href="https://dev.to/settings/membership">membership settings</a> page to see the most up-to-date information.
</p>
<p>
Thank you so much for the support, and please email members@dev.to with any questions.
</p>
<% elsif @cancel_subscription %>
<p>
Your DEV sustaining membership has been cancelled. Thank you so much for your support to date.
</p>
<p>
If you have any feedback that can help us improve the membership experience, please feel free to reply to this email.
<p>
</p>
<p>
Thanks again,
<br/>
PBJ
</p>
<% elsif @scholarship_awarded %>
<img src="https://thepracticaldev.s3.amazonaws.com/i/nn3vxwwm23p1hu67wbzt.png" style="height:220px; display: block; margin-left: auto; margin-right: auto;"/>
<p>Congratulations!</p>
<p>
Weve received your DEV scholarship application and are excited to provide you with a workshop pass for
the year. Youll get full access to all DEV talks and workshops by visiting <a href="https://dev.to/live">dev.to/live</a> during an event. See <a href="https://dev.to/events">our events</a> page
to check out the latest schedule. We appreciate your dedication to programming and hope youll benefit from these additional
resources.
</p>
<p>
Thanks again for applying and if within your means, please consider <a href="https://dev.to/membership">becoming a level 1 or 2 sustaining member.</a>
</p>
<p>
Best,
<br>
PBJ
</p>
<% elsif @digest_email %>
<h1 style="text-align: center;">
DEV Digest
</h1>
<h4 style="text-align: center;">Recent posts you might find valuable based on your interests ❤️</h4>
<% @articles.each do |article| %>
<ul>
<li>
<a href="https://dev.to<%= article.path %>" style="font-weight: bold;color:#0045ff;font-size:1.06em;"><%= article.title.strip %></a> <%= truncate(article.description, length: 80) %>
</li>
</ul>
<% end %>
<center style="margin-top:50px;">
<em>
<% if @user.follows.size == 0 %>
<b>
DEV Digest is a new periodic email featuring the best posts from our community of developers.
</b>
<br/><br/>
Your digest is not yet customized. Follow the people and technologies on <a href="https://dev.to" style="text-decoration: none;">dev.to</a> that interest you in order to receive the most relevant posts in your inbox.
<% else %>
<% tip_rand = rand(5) %>
<% if tip_rand == 0 %>
Thanks for being a valued member of the community.
<% elsif tip_rand == 1 %>
Follow the authors you want to see more of!
<% elsif tip_rand == 2 %>
And there's so much more dev goodness to discover.
<% elsif tip_rand == 3 %>
You're a better dev today than you were yesterday.
<% elsif tip_rand == 4 %>
<% if @user.articles.where(published: true).any? %>
Can't wait to see <b>your</b> next DEV post!
<% else %>
Can't wait to see <b>your</b> first DEV post!
<% end %>
<% end %>
<% end %>
</em>
</center>
<% end %>

View file

@ -3,7 +3,7 @@
<table style="width:100%;max-width:700px;margin:auto;font-size:18px">
<tr>
<td style="padding:4%;">
<%= render "layouts/mailer_content" %>
<%= yield %>
</td>
</tr>
<tr>

View file

@ -1 +1,2 @@
<%= strip_tags @body %>
<%= yield %>

View file

@ -0,0 +1,40 @@
<h1 style="text-align: center;">
DEV Digest
</h1>
<h4 style="text-align: center;">Recent posts you might find valuable based on your interests ❤️</h4>
<% @articles.each do |article| %>
<ul>
<li>
<a href="https://dev.to<%= article.path %>" style="font-weight: bold;color:#0045ff;font-size:1.06em;"><%= article.title.strip %></a> <%= truncate(article.description, length: 80) %>
</li>
</ul>
<% end %>
<center style="margin-top:50px;">
<em>
<% if @user.follows.size == 0 %>
<b>
DEV Digest is a new periodic email featuring the best posts from our community of developers.
</b>
<br/><br/>
Your digest is not yet customized. Follow the people and technologies on <a href="https://dev.to" style="text-decoration: none;">dev.to</a> that interest you in order to receive the most relevant posts in your inbox.
<% else %>
<% tip_rand = rand(5) %>
<% if tip_rand == 0 %>
Thanks for being a valued member of the community.
<% elsif tip_rand == 1 %>
Follow the authors you want to see more of!
<% elsif tip_rand == 2 %>
And there's so much more dev goodness to discover.
<% elsif tip_rand == 3 %>
You're a better dev today than you were yesterday.
<% elsif tip_rand == 4 %>
<% if @user.articles.where(published: true).any? %>
Can't wait to see <b>your</b> next DEV post!
<% else %>
Can't wait to see <b>your</b> first DEV post!
<% end %>
<% end %>
<% end %>
</em>
</center>

View file

@ -0,0 +1,106 @@
<img src="https://thepracticaldev.s3.amazonaws.com/i/186bp9xbue90w504wn97.png" style="height:200px; display: block; margin-left: auto; margin-right: auto;"/>
<% if @subscription_type == "triple_unicorn_member" %>
<p>
Whoa! Youre the best, and so generous. We tip our hats to you.
</p>
<p>
As a triple-unicorn, you have full access to all dev.to workshops! Well be releasing our workshop schedule Early February.
</p>
<p>
Youll see your name at the featured position on our Wall of Patrons and Scholars within the next few days, and you can claim your swag pack now by visiting your <a href="https://dev.to/settings/membership">settings page</a>.
</p>
<p>
Well be in touch to schedule a time for all of us to chat together, and well also be putting together some additional goodies.
</p>
<p>
Thank you again for supporting The DEV Community. Your membership means a lot to us, and all the recipients of our scholarship fund. You went above and beyond on this one.
</p>
<% elsif @subscription_type == "level_4_member" %>
<p>
Thank you for becoming a DEV sustaining member. Your support means the world to us.
</p>
<p>
As part of your membership, youll have early access to beta features on the site. For instance, post analytics have now been added to your <a href="https://dev.to/dashboard/">dashboard</a>.
</p>
<p>
On your <a href="https://dev.to/settings/membership">membership settings page</a>, youll find the coupon that youll use to request your exclusive sticker pack and t-shirt combo.
</p>
<p>
Your name will appear on our “Wall of Patrons and Scholars” soon, and youll also be receiving full access to all dev.to workshops! Well be releasing our first workshop schedule in early February.
</p>
<p>
Above all, thank you for supporting The DEV Community. Your additional contribution means so much to us, and to all the recipients of our scholarship fund. You really went above and beyond on this one.
</p>
<p>
With sincere gratitude...
</p>
<p>
❤️
<br/>
PBJ
</p>
<p>
PS — feel free to reply to this email with any questions.
</p>
<% elsif @subscription_type == "level_3_member" %>
<p>
Thank you for becoming a DEV sustaining member. Your support means the world to us.
</p>
<p>
As part of your membership, youll have early access to beta features on the site. For instance, post analytics have now been added to your <a href="https://dev.to/dashboard/">dashboard</a>.
</p>
<p>
On your membership <a href="https://dev.to/settings/membership">settings page</a>, youll find the coupon that youll use to request your exclusive sticker pack and t-shirt combo.
</p>
<p>
Your name will appear on our “Wall of Patrons and Scholars” soon, and youll also be receiving full access to all dev.to workshops! Well be releasing our first workshop schedule in early February.
</p>
<p>
Feel free to reply to this email with any questions :)
</p>
<p>
Thanks again! ❤️
<br/>
PBJ
</p>
<% elsif @subscription_type == "level_2_member" %>
<p>
Thank you for becoming a DEV sustaining member. Your support means the world to us.
</p>
<p>
As part of your membership, youll have early access to beta features on the site. For instance, post analytics have now been added to your <a href="https://dev.to/dashboard/">dashboard</a>.
</p>
<p>
On your <a href="https://dev.to/settings/membership">membership settings</a> page, youll find the coupon that youll use to request your exclusive sticker pack. Within the next few days, youll be appearing on our Wall of Patrons and Scholars.
</p>
<p>
Feel free to reply to this email with any questions :)
</p>
<p>
Thanks again! ❤️
<br/>
PBJ
</p>
<% elsif @subscription_type == "level_1_member" %>
<p>
Thank you for becoming a DEV sustaining member. Your support means the world to us.
</p>
<p>
As part of your membership, youll have early access to beta features on the site. For instance, post analytics have now been added to your <a href="https://dev.to/dashboard/">dashboard</a>.
</p>
<p>
Within the next few days, youll also appear on our Wall of Patrons and Scholars.
</p>
<p>
Feel free to reply to this email with any questions :)
</p>
<p>
Thanks again! ❤️
<br/>
PBJ
</p>
<% end %>
<h2 style="font-size:25px;">Thank you so much for your support.</h2>
<p>
Visit <a href="https://dev.to/settings/membership">Your membership settings page</a> for all details.
</p>

View file

@ -0,0 +1 @@
Visit https://dev.to/settings/membership for full details

View file

@ -0,0 +1,12 @@
<p>
Your DEV sustaining membership has been cancelled. Thank you so much for your support to date.
</p>
<p>
If you have any feedback that can help us improve the membership experience, please feel free to reply to this email.
<p>
</p>
<p>
Thanks again,
<br/>
PBJ
</p>

View file

@ -0,0 +1 @@
If you could send feedback to yo@dev.to to help us improve it would be much appreciated.

View file

@ -0,0 +1,7 @@
<img src="<%= asset_path 'sustaining-membership.svg' %>" style="height:200px; display: block; margin-left: auto; margin-right: auto;"/>
<p>
Your DEV sustaining membership monthly contribution amount has been updated. Be sure to check your <a href="https://dev.to/settings/membership">membership settings</a> page to see the most up-to-date information.
</p>
<p>
Thank you so much for the support, and please email members@dev.to with any questions.
</p>

View file

@ -0,0 +1 @@
Visit https://dev.to/settings/membership for updated details

View file

@ -0,0 +1,9 @@
<% if Follow.where(followable_id: @user.id, followable_type: "User").where("created_at > ?", 24.hours.ago).size > 1 %>
<h3 style="font-weight:600;font-size:0.95em;color:#3ac1b4">You have <%= Follow.where(followable_id: @user.id, followable_type: "User").where("created_at > ?", 24.hours.ago).size %> new DEV followers in the past day!</h3>
<% end %>
<h2 style="font-size:32px;"><a href="https://dev.to/<%= @follower.username %>"><%= @follower.name %></a> just followed you 🤗</h2>
<h3 style="font-weight:600">You now have <%= pluralize(@user.followers_count, 'total follower') %>. See all of your recent followers <a href="https://dev.to/dashboard/user_followers">right here</a>.</h3>
<p>
When someone follows you on <a href="https://dev.to">dev.to</a>, your posts will be prioritized in their feed and notifications. The perks of popularity I suppose.
</p>

View file

@ -0,0 +1 @@
<%= @follower.name %> just followed you. When someone follows you, your posts will be prioritized on their personalized home feed. This new feature is one step towards offering a more customized experience.

View file

@ -0,0 +1,7 @@
<h2 style="font-size:25px;"><a href="https://dev.to/<%= @mentioner.username %>"><%= @mentioner.name %></a> just mentioned you in their <%= @mention.mentionable_type.downcase %>!</h2>
<table><tr><td style='color:#c3c3c3;font-size:14px;padding-bottom:8px'>
</td></tr><tr><td style='padding:20px;padding-bottom:30px;border-radius:3px;font-size:19px;background:#f4f4f4'>
<%= @mentionable.processed_html.html_safe %>
<a style="background:#3c7dc1;color:white;padding:5px 14px;border-radius:3px;text-decoration:none;display:inline-block;margin-top:4px;" href='https://dev.to<%=@mention.mentionable.path%>'>read & reply</a>
</td></tr></table>

View file

@ -0,0 +1,5 @@
<%= @mentioner.name %> just mentioned you in their <%= @mention.mentionable_type.downcase %>
<%= ActionController::Base.helpers.strip_tags(@mentionable.processed_html.html_safe) %>
View now: https://dev.to<%= @mention.mentionable.path %>

View file

@ -0,0 +1,10 @@
<h2 style="font-size:25px;"><%= link_to(@comment.user.name, "https://dev.to/#{@comment.user.username}") %> replied to you on dev.to</h2>
<table><tr><td style='color:#c3c3c3;font-size:14px;padding-bottom:8px'>
<% unless @comment.is_root? %>
<%= truncate(strip_tags(@comment.parent_or_root_article.processed_html.html_safe), length: 80) %>
<% end %>
</td></tr><tr><td style='padding:20px;padding-bottom:30px;border-radius:3px;font-size:19px;background:#f4f4f4'>
<h2 style="font-size:22px;color:rgb(107, 107, 107)">re: <em><%= @comment.commentable.title %></em></h2>
<%= @comment.processed_html.html_safe %>
<a style="background:#3c7dc1;color:white;padding:5px 14px;border-radius:3px;text-decoration:none;display:inline-block;margin-top:4px;" href='https://dev.to<%=@comment.path%>'>read & reply</a> <a style="background:#1f1f1f;color:white;padding:5px 14px;border-radius:3px;text-decoration:none;display:inline-block;margin-top:4px;" href='https://dev.to<%=@comment.commentable.path%>'>read original post</a>
</td></tr></table>

View file

@ -0,0 +1,5 @@
<%= @comment.user.name %> replied to your <%= @comment.parent_type %>:
<%= ActionController::Base.helpers.strip_tags(@comment.processed_html.html_safe) %>
View now: https://dev.to<%= @comment.path %>

View file

@ -0,0 +1,4 @@
<h3 style="font-weight:300">You're popular!</h3>
<p>
<a style="background:#3c7dc1;color:white;padding:5px 14px;border-radius:3px;text-decoration:none;display:inline-block;margin-top:4px;font-size:33px;" href='https://dev.to/notifications'>Read my notifications</a>
</p>

View file

@ -0,0 +1 @@
Visit https://dev.to/notifications to read all of your notifications

View file

@ -0,0 +1,17 @@
<img src="https://thepracticaldev.s3.amazonaws.com/i/nn3vxwwm23p1hu67wbzt.png" style="height:220px; display: block; margin-left: auto; margin-right: auto;"/>
<p>Congratulations!</p>
<p>
Weve received your DEV scholarship application and are excited to provide you with a workshop pass for
the year. Youll get full access to all DEV talks and workshops by visiting <a href="https://dev.to/live">dev.to/live</a> during an event. See <a href="https://dev.to/events">our events</a> page
to check out the latest schedule. We appreciate your dedication to programming and hope youll benefit from these additional
resources.
</p>
<p>
Thanks again for applying and if within your means, please consider <a href="https://dev.to/membership">becoming a level 1 or 2 sustaining member.</a>
</p>
<p>
Best,
<br>
PBJ
</p>

View file

@ -0,0 +1 @@
Congratulations on your dev.to Scholarship! See https://dev.to/settings/misc for updated details

View file

@ -0,0 +1,31 @@
require "rails_helper"
RSpec.describe MembershipMailer, type: :mailer do
let(:user) { create(:user) }
describe "#new_membership_subscription_email" do
it "renders proper subject" do
user = create(:user)
new_membership_subscription_email = described_class.new_membership_subscription_email(user, "level_1_member")
expect(new_membership_subscription_email.subject).to include("Thanks for subscribing")
end
it "renders proper receiver" do
user = create(:user)
new_membership_subscription_email = described_class.new_membership_subscription_email(user, "level_1_member")
expect(new_membership_subscription_email.to).to eq([user.email])
end
end
describe "#subscription_cancellation_email" do
it "renders proper subject" do
user = create(:user)
subscription_cancellation_email = described_class.subscription_cancellation_email(user)
expect(subscription_cancellation_email.subject).to include("Sorry to lose you")
end
it "renders proper receiver" do
user = create(:user)
subscription_cancellation_email = described_class.subscription_cancellation_email(user)
expect(subscription_cancellation_email.to).to eq([user.email])
end
end
end

View file

@ -1,84 +1,47 @@
require "rails_helper"
RSpec.describe NotifyMailer, :type => :mailer do
RSpec.describe NotifyMailer, type: :mailer do
describe "notify" do
let(:user) { create(:user) }
let(:user2) { create(:user) }
let(:article) { create(:article, user_id: user.id) }
let(:comment) { create(:comment, user_id: user.id, commentable_id: article.id) }
describe "new_reply_email" do
describe "#new_reply_email" do
it "renders proper subject" do
new_reply_email = NotifyMailer.new_reply_email(comment)
new_reply_email = described_class.new_reply_email(comment)
expect(new_reply_email.subject).to include("replied to your")
end
it "renders proper receiver" do
new_reply_email = NotifyMailer.new_reply_email(comment)
new_reply_email = described_class.new_reply_email(comment)
expect(new_reply_email.to).to eq([comment.user.email])
end
end
describe "new_follower_email" do
describe "#new_follower_email" do
it "renders proper subject" do
user2.follow(user)
new_follower_email = NotifyMailer.new_follower_email(Follow.last)
new_follower_email = described_class.new_follower_email(Follow.last)
expect(new_follower_email.subject).to eq("#{user2.name} just followed you on dev.to")
end
it "renders proper receiver" do
user2.follow(user)
new_follower_email = NotifyMailer.new_follower_email(Follow.last)
new_follower_email = described_class.new_follower_email(Follow.last)
expect(new_follower_email.to).to eq([user.email])
end
end
describe "new_mention_email" do
describe "#new_mention_email" do
it "renders proper subject" do
mention = create(:mention, user_id: user2.id, mentionable_id: comment.id)
new_mention_email = NotifyMailer.new_mention_email(mention)
new_mention_email = described_class.new_mention_email(mention)
expect(new_mention_email.subject).to include("#{comment.user.name} just mentioned you")
end
it "renders proper receiver" do
mention = create(:mention, user_id: user2.id, mentionable_id: comment.id)
new_mention_email = NotifyMailer.new_mention_email(mention)
new_mention_email = described_class.new_mention_email(mention)
expect(new_mention_email.to).to eq([user2.email])
end
end
describe "new_membership_subscription_email" do
it "renders proper subject" do
user = create(:user)
new_membership_subscription_email = NotifyMailer.new_membership_subscription_email(user,"level_1_member")
expect(new_membership_subscription_email.subject).to include("Thanks for subscribing")
end
it "renders proper receiver" do
user = create(:user)
new_membership_subscription_email = NotifyMailer.new_membership_subscription_email(user,"level_1_member")
expect(new_membership_subscription_email.to).to eq([user.email])
end
end
describe "subscription_cancellation_email" do
it "renders proper subject" do
user = create(:user)
subscription_cancellation_email = NotifyMailer.subscription_cancellation_email(user)
expect(subscription_cancellation_email.subject).to include("Sorry to lose you")
end
it "renders proper receiver" do
user = create(:user)
subscription_cancellation_email = NotifyMailer.subscription_cancellation_email(user)
expect(subscription_cancellation_email.to).to eq([user.email])
end
end
describe "scholarship_awarded_email" do
it "renders proper subject" do
user = create(:user)
scholarship_awarded_email = NotifyMailer.scholarship_awarded_email(user)
expect(scholarship_awarded_email.subject).to eq("Congrats on your DEV Scholarship!")
end
it "renders proper receiver" do
user = create(:user)
scholarship_awarded_email = NotifyMailer.scholarship_awarded_email(user)
expect(scholarship_awarded_email.to).to eq([user.email])
end
end
end
end

View file

@ -0,0 +1,13 @@
class MembershipMailerPreview < ActionMailer::Preview
def new_membership_subscription_email
MembershipMailer.new_membership_subscription_email(User.last, "level_2_member")
end
def subscription_update_confirm_email
MembershipMailer.subscription_update_confirm_email(User.last)
end
def subscription_cancellation_email
MembershipMailer.subscription_cancellation_email(User.last)
end
end

View file

@ -15,24 +15,4 @@ class NotifyMailerPreview < ActionMailer::Preview
def new_mention_email
NotifyMailer.new_mention_email(Mention.last)
end
def new_membership_subscription_email
NotifyMailer.new_membership_subscription_email(User.last, "level_2_member")
end
def subscription_update_confirm_email
NotifyMailer.subscription_update_confirm_email(User.last)
end
def subscription_cancellation_email
NotifyMailer.subscription_cancellation_email(User.last)
end
def scholarship_awarded_email
NotifyMailer.scholarship_awarded_email(User.last)
end
def digest_email
NotifyMailer.digest_email(User.last, Article.all)
end
end

View file

@ -0,0 +1,5 @@
class ScholarshipMailerPreview < ActionMailer::Preview
def scholarship_awarded_email
ScholarshipMailer.scholarship_awarded_email(User.last)
end
end

View file

@ -0,0 +1,19 @@
require "rails_helper"
RSpec.describe ScholarshipMailer, type: :mailer do
let(:user) { create(:user) }
describe "#scholarship_awarded_email" do
it "renders proper subject" do
user = create(:user)
scholarship_awarded_email = described_class.scholarship_awarded_email(user)
expect(scholarship_awarded_email.subject).to eq("Congrats on your DEV Scholarship!")
end
it "renders proper receiver" do
user = create(:user)
scholarship_awarded_email = described_class.scholarship_awarded_email(user)
expect(scholarship_awarded_email.to).to eq([user.email])
end
end
end