diff --git a/app/assets/javascripts/autocomplete.js b/app/assets/javascripts/autocomplete.js index 40df641..d5e2c57 100644 --- a/app/assets/javascripts/autocomplete.js +++ b/app/assets/javascripts/autocomplete.js @@ -223,7 +223,9 @@ "overflow-x" : "hidden", "line-height" : $(data.ta).css("line-height"), "overflow-y" : "hidden", - "z-index" : -10 + "z-index" : -10, + "color" : "transparent", + "visibility" : "hidden" }); //console.log("createClone: ta width=",$(data.ta).css("width")," ta clientWidth=",data.ta.clientWidth, "scrollWidth=",data.ta.scrollWidth," offsetWidth=",data.ta.offsetWidth," jquery.width=",$(data.ta).width()); diff --git a/app/controllers/blogposts_controller.rb b/app/controllers/blogposts_controller.rb index 6d754de..af0aa7f 100644 --- a/app/controllers/blogposts_controller.rb +++ b/app/controllers/blogposts_controller.rb @@ -22,6 +22,7 @@ class BlogpostsController < ApplicationController @post = Blogpost.new(post_params) @post.user_author = current_user if @post.save + @post.send_new_mention_mail redirect_to @post, notice: 'Post has been created.' else flash[:alert] = "Error creating blogpost" @@ -32,7 +33,9 @@ class BlogpostsController < ApplicationController def update @post.user_editor = current_user @post.attributes = post_params([:user_editor]) + old_content = @post.content_was if @post.save + @post.send_new_mention_mail(old_content) redirect_to @post, notice: 'Post has been updated.' else flash[:alert] = "There was a problem while updating the post" diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index f6e6747..9a874b5 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -18,6 +18,7 @@ class CommentsController < ApplicationController @comment.blogpost = Blogpost.find(params[:blogpost_id]) if @comment.save @comment.send_new_comment_mail + @comment.send_new_mention_mail redirect_to blogpost_path(@comment.blogpost) + "#comment-#{@comment.id}", notice: 'Comment created!' else flash[:alert] = "Could not create comment." @@ -34,7 +35,9 @@ class CommentsController < ApplicationController if mod? || @comment.author.is?(current_user) @comment.user_editor = current_user @comment.attributes = comment_params + old_content = @comment.content_was if @comment.save + @comment.send_new_mention_mail(old_content) flash[:notice] = "Comment updated!" redirect_to blogpost_path(@comment.blogpost) + "#comment-#{@comment.id}" else diff --git a/app/controllers/forumthreads_controller.rb b/app/controllers/forumthreads_controller.rb index 209a49c..3f18ffa 100644 --- a/app/controllers/forumthreads_controller.rb +++ b/app/controllers/forumthreads_controller.rb @@ -9,22 +9,6 @@ class ForumthreadsController < ApplicationController def show end - def update - if mod? || @thread.author.is?(current_user) - @thread.user_editor = current_user - @thread.attributes = (mod? ? thread_params([:sticky, :locked, :forum_id]) : thread_params) - if @thread.save - redirect_to @thread, notice: 'Post has been updated.' - else - flash[:alert] = "There was a problem while updating the post" - render action: "edit" - end - else - flash[:alert] = "You are not allowed to edit this thread!" - redirect_to @thread - end - end - def edit end @@ -41,6 +25,7 @@ class ForumthreadsController < ApplicationController if @thread.can_write?(current_user) @thread.user_author = current_user if @thread.save + @thread.send_new_mention_mail flash[:notice] = "Thread created!" redirect_to forumthread_path( @thread) return @@ -55,6 +40,23 @@ class ForumthreadsController < ApplicationController end end + def update + if mod? || @thread.author.is?(current_user) + @thread.user_editor = current_user + @thread.attributes = (mod? ? thread_params([:sticky, :locked, :forum_id]) : thread_params) + old_content = @thread.content_was + if @thread.save + @thread.send_new_mention_mail(old_content) + redirect_to @thread, notice: 'Post has been updated.' + else + flash[:alert] = "There was a problem while updating the post" + render action: "edit" + end + else + flash[:alert] = "You are not allowed to edit this thread!" + redirect_to @thread + end + end def destroy if mod? || @thread.author.is?(current_user) diff --git a/app/controllers/threadreplies_controller.rb b/app/controllers/threadreplies_controller.rb index 1709d0c..7df8aef 100644 --- a/app/controllers/threadreplies_controller.rb +++ b/app/controllers/threadreplies_controller.rb @@ -17,6 +17,7 @@ class ThreadrepliesController < ApplicationController @reply.forumthread = thread if @reply.save @reply.send_new_reply_mail + @reply.send_new_mention_mail redirect_to forumthread_path(@reply.thread) + "#reply-#{@reply.id}", notice: 'Reply created!' else flash[:alert] = "Could not create reply." @@ -31,7 +32,9 @@ class ThreadrepliesController < ApplicationController def update @reply = Threadreply.find(params[:id]) if mod? || @reply.author.is?(current_user) + old_content = @reply.content_was if @reply.update_attributes(reply_params) + @reply.send_new_mention_mail(old_content) flash[:notice] = "Reply updated!" redirect_to forumthread_path(@reply.thread) + "#reply-#{@reply.id}" else diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index f0f5475..c4fd422 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -1,6 +1,14 @@ module UsersHelper require "open-uri" + def mentions(content) + words = content.scan(/@[a-zA-Z0-9_]{1,16}/) + words.map! do |w| + w[0] = "" + w + end + User.where(ign: words).uniq! + end def get_youtube(yt_name) yt = {channel: yt_name} diff --git a/app/mailers/redstoner_mailer.rb b/app/mailers/redstoner_mailer.rb index aa0ff26..401ad96 100644 --- a/app/mailers/redstoner_mailer.rb +++ b/app/mailers/redstoner_mailer.rb @@ -16,18 +16,42 @@ class RedstonerMailer < ActionMailer::Base mail(to: "redstonerserver@gmail.com", subject: "#{@user.name} registered on Redstoner") end + def new_thread_mention_mail(user, thread) + @user = user + @thread = thread + mail(to: @user.email, subject: "#{thread.author.name} mentioned you in '#{thread.title}' on Redstoner") + end + def new_thread_reply_mail(user, reply) @user = user @reply = reply mail(to: @user.email, subject: "#{reply.author.name} replied to '#{reply.thread.title}' on Redstoner") end + def new_thread_reply_mention_mail(user, reply) + @user = user + @reply = reply + mail(to: @user.email, subject: "#{reply.author.name} mentioned you in '#{reply.thread.title}' on Redstoner") + end + + def new_post_mention_mail(user, post) + @user = user + @post = post + mail(to: @user.email, subject: "#{post.author.name} mentioned you in '#{post.title}' on Redstoner") + end + def new_post_comment_mail(user, comment) @user = user @comment = comment mail(to: @user.email, subject: "#{comment.author.name} replied to '#{comment.blogpost.title}' on Redstoner") end + def new_post_comment_mention_mail(user, comment) + @user = user + @comment = comment + mail(to: @user.email, subject: "#{comment.author.name} mentioned you in '#{comment.blogpost.title}' on Redstoner") + end + def email_change_confirm_mail(user) @user = user mail(to: @user.email, subject: "Email change on Redstoner.com") diff --git a/app/models/blogpost.rb b/app/models/blogpost.rb index 0aefbdb..c1771db 100644 --- a/app/models/blogpost.rb +++ b/app/models/blogpost.rb @@ -1,5 +1,8 @@ class Blogpost < ActiveRecord::Base + include MailerHelper + include UsersHelper + validates_presence_of :title, :content, :author belongs_to :user_author, class_name: "User", foreign_key: "user_author_id" belongs_to :user_editor, class_name: "User", foreign_key: "user_editor_id" @@ -23,4 +26,20 @@ class Blogpost < ActiveRecord::Base !!user_editor_id end + def send_new_mention_mail(old_content = "") + new_mentions = mentions(content) - mentions(old_content) + mails = [] + new_mentions.each do |user| + begin + mails << RedstonerMailer.new_post_mention_mail(user, self) + rescue => e + Rails.logger.error "---" + Rails.logger.error "WARNING: Failed to create new_post_mention_mail (view) for post#: #{@self.id}, user: #{@user.name}, #{@user.email}" + Rails.logger.error e.message + Rails.logger.error "---" + end + end + background_mailer(mails) + end + end diff --git a/app/models/comment.rb b/app/models/comment.rb index e56dc9d..2c092f4 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -1,6 +1,7 @@ class Comment < ActiveRecord::Base include MailerHelper + include UsersHelper belongs_to :user_author, class_name: "User", foreign_key: "user_author_id" belongs_to :user_editor, class_name: "User", foreign_key: "user_editor_id" @@ -49,7 +50,23 @@ class Comment < ActiveRecord::Base mails << RedstonerMailer.new_post_comment_mail(User.find(uid), self) rescue => e Rails.logger.error "---" - Rails.logger.error "WARNING: Failed to create thread_reply mail (view) for reply#: #{@self.id}, user: #{@user.name}, #{@user.email}" + Rails.logger.error "WARNING: Failed to create post_reply mail (view) for reply#: #{@self.id}, user: #{@user.name}, #{@user.email}" + Rails.logger.error e.message + Rails.logger.error "---" + end + end + background_mailer(mails) + end + + def send_new_mention_mail(old_content = "") + new_mentions = mentions(content) - mentions(old_content) + mails = [] + new_mentions.each do |user| + begin + mails << RedstonerMailer.new_post_comment_mention_mail(user, self) + rescue => e + Rails.logger.error "---" + Rails.logger.error "WARNING: Failed to create new_post_comment_mention_mail (view) for reply#: #{@self.id}, user: #{@user.name}, #{@user.email}" Rails.logger.error e.message Rails.logger.error "---" end diff --git a/app/models/forumthread.rb b/app/models/forumthread.rb index 7937a02..54cfbca 100644 --- a/app/models/forumthread.rb +++ b/app/models/forumthread.rb @@ -1,4 +1,8 @@ class Forumthread < ActiveRecord::Base + + include MailerHelper + include UsersHelper + belongs_to :forum belongs_to :user_author, class_name: "User", foreign_key: "user_author_id" belongs_to :user_editor, class_name: "User", foreign_key: "user_editor_id" @@ -37,4 +41,20 @@ class Forumthread < ActiveRecord::Base def can_write?(user) forum.can_write?(user) && (!locked? || user.mod?) end + + def send_new_mention_mail(old_content = "") + new_mentions = mentions(content) - mentions(old_content) + mails = [] + new_mentions.each do |user| + begin + mails << RedstonerMailer.new_thread_mention_mail(user, self) + rescue => e + Rails.logger.error "---" + Rails.logger.error "WARNING: Failed to create new_thread_mention_mail (view) for reply#: #{@self.id}, user: #{@user.name}, #{@user.email}" + Rails.logger.error e.message + Rails.logger.error "---" + end + end + background_mailer(mails) + end end \ No newline at end of file diff --git a/app/models/threadreply.rb b/app/models/threadreply.rb index d9a2fd0..996a673 100644 --- a/app/models/threadreply.rb +++ b/app/models/threadreply.rb @@ -1,6 +1,7 @@ class Threadreply < ActiveRecord::Base include MailerHelper + include UsersHelper belongs_to :forumthread belongs_to :user_author, class_name: "User", foreign_key: "user_author_id" @@ -32,6 +33,22 @@ class Threadreply < ActiveRecord::Base !!user_editor_id end + def send_new_mention_mail(old_content = "") + new_mentions = mentions(content) - mentions(old_content) + mails = [] + new_mentions.each do |user| + begin + mails << RedstonerMailer.new_thread_reply_mention_mail(user, self) + rescue => e + Rails.logger.error "---" + Rails.logger.error "WARNING: Failed to create new_thread_reply_mention_mail (view) for reply#: #{@self.id}, user: #{@user.name}, #{@user.email}" + Rails.logger.error e.message + Rails.logger.error "---" + end + end + background_mailer(mails) + end + def send_new_reply_mail userids = [] @@ -53,7 +70,7 @@ class Threadreply < ActiveRecord::Base mails << RedstonerMailer.new_thread_reply_mail(User.find(uid), self) rescue => e Rails.logger.error "---" - Rails.logger.error "WARNING: Failed to create thread_reply mail (view) for reply#: #{@self.id}, user: #{@user.name}, #{@user.email}" + Rails.logger.error "WARNING: Failed to create new_thread_reply_mail (view) for reply#: #{@self.id}, user: #{@user.name}, #{@user.email}" Rails.logger.error e.message Rails.logger.error "---" end diff --git a/app/views/redstoner_mailer/email_change_confirm_mail.html.erb b/app/views/redstoner_mailer/email_change_confirm_mail.html.erb index b4193d0..33e853a 100644 --- a/app/views/redstoner_mailer/email_change_confirm_mail.html.erb +++ b/app/views/redstoner_mailer/email_change_confirm_mail.html.erb @@ -1,5 +1,5 @@
-
+
Hi <%= @user.name %>!

You changed your email on Redstoner.com!

diff --git a/app/views/redstoner_mailer/new_post_comment_mail.html.erb b/app/views/redstoner_mailer/new_post_comment_mail.html.erb index 6ec28e5..9728427 100644 --- a/app/views/redstoner_mailer/new_post_comment_mail.html.erb +++ b/app/views/redstoner_mailer/new_post_comment_mail.html.erb @@ -1,5 +1,5 @@
-
+
Hi <%= @user.name %>!

<%= link_to @comment.author.name, user_url(@comment.author), style: "text-decoration: none; color: #4096EE;" %> has replied to '<%= @comment.blogpost.title %>' on the Redstoner blog!

diff --git a/app/views/redstoner_mailer/new_post_comment_mention_mail.html.erb b/app/views/redstoner_mailer/new_post_comment_mention_mail.html.erb new file mode 100644 index 0000000..a923c0e --- /dev/null +++ b/app/views/redstoner_mailer/new_post_comment_mention_mail.html.erb @@ -0,0 +1,30 @@ +
+
+ Hi <%= @user.name %>! + +

<%= link_to @comment.author.name, user_url(@comment.author), style: "text-decoration: none; color: #4096EE;" %> has mentioned you in '<%= @comment.blogpost.title %>' on the Redstoner blog!

+ +
+ <%# TODO: fix relative links + iframes %> + <%= render_mini_md(@comment.content).html_safe %> +
+ +

<%= link_to "Click here", blogpost_url(@comment.blogpost) + "#comment-#{@comment.id}", style: "text-decoration: none; color: #4096EE;" %> to view the blog post.

+ +

If you have any questions or problems, just ask one of our <%= link_to "Staff", users_url(role: "staff"), style: "text-decoration: none; color: #4096EE;" %> in-game or on the forums!

+

Your Redstoner team

+ +
+
+
+
+

Too much spam? Change <%= link_to "your notification settings", edit_notifications_user_url(@user), style: "text-decoration: none; color: #4096EE;" %>!

+

You can contact us via: + <%= link_to "Website", root_url, style: "text-decoration: none; color: #4096EE;" %> | + <%= link_to "Twitter", "https://twitter.com/RedstonerServer", style: "text-decoration: none; color: #4096EE;" %> | + <%= link_to "Google+", "https://google.com/+Redstoner", style: "text-decoration: none; color: #4096EE;" %> | + <%= link_to "Email", "mailto:redstonerserver+website@gmail.com", style: "text-decoration: none; color: #4096EE;" %> +

+
+
+
\ No newline at end of file diff --git a/app/views/redstoner_mailer/new_post_mention_mail.html.erb b/app/views/redstoner_mailer/new_post_mention_mail.html.erb new file mode 100644 index 0000000..9efae11 --- /dev/null +++ b/app/views/redstoner_mailer/new_post_mention_mail.html.erb @@ -0,0 +1,30 @@ +
+
+ Hi <%= @user.name %>! + +

<%= link_to @post.author.name, user_url(@post.author), style: "text-decoration: none; color: #4096EE;" %> has mentioned you in '<%= @post.title %>' on the Redstoner blog!

+ +
+ <%# TODO: fix relative links + iframes %> + <%= render_mini_md(@post.content).html_safe %> +
+ +

<%= link_to "Click here", blogpost_url(@post), style: "text-decoration: none; color: #4096EE;" %> to view the blog post.

+ +

If you have any questions or problems, just ask one of our <%= link_to "Staff", users_url(role: "staff"), style: "text-decoration: none; color: #4096EE;" %> in-game or on the forums!

+

Your Redstoner team

+ +
+
+
+
+

Too much spam? Change <%= link_to "your notification settings", edit_notifications_user_url(@user), style: "text-decoration: none; color: #4096EE;" %>!

+

You can contact us via: + <%= link_to "Website", root_url, style: "text-decoration: none; color: #4096EE;" %> | + <%= link_to "Twitter", "https://twitter.com/RedstonerServer", style: "text-decoration: none; color: #4096EE;" %> | + <%= link_to "Google+", "https://google.com/+Redstoner", style: "text-decoration: none; color: #4096EE;" %> | + <%= link_to "Email", "mailto:redstonerserver+website@gmail.com", style: "text-decoration: none; color: #4096EE;" %> +

+
+
+
\ No newline at end of file diff --git a/app/views/redstoner_mailer/new_thread_mention_mail.html.erb b/app/views/redstoner_mailer/new_thread_mention_mail.html.erb new file mode 100644 index 0000000..701901e --- /dev/null +++ b/app/views/redstoner_mailer/new_thread_mention_mail.html.erb @@ -0,0 +1,31 @@ +
+
+ Hi <%= @user.name %>! + +

<%= link_to @thread.author.name, user_url(@thread.author), style: "text-decoration: none; color: #4096EE;" %> mentioned you in '<%= @thread.title %>' on the Redstoner forums!

+ +
+ <%# TODO: fix relative links + iframes %> + <%= render_md(@thread.content).html_safe %> +
+ +

<%= link_to "Click here", forumthread_url(@thread), style: "text-decoration: none; color: #4096EE;" %> to view the thread.

+ +

If you have any questions or problems, just ask one of our <%= link_to "Staff", users_url(role: "staff"), style: "text-decoration: none; color: #4096EE;" %> in-game or on the forums!

+

Your Redstoner team

+ +
+
+
+
+

Too much spam? Change <%= link_to "your notification settings", edit_notifications_user_url(@user), style: "text-decoration: none; color: #4096EE;" %>!

+

+

You can contact us via: + <%= link_to "Website", root_url, style: "text-decoration: none; color: #4096EE;" %> | + <%= link_to "Twitter", "https://twitter.com/RedstonerServer", style: "text-decoration: none; color: #4096EE;" %> | + <%= link_to "Google+", "https://google.com/+Redstoner", style: "text-decoration: none; color: #4096EE;" %> | + <%= link_to "Email", "mailto:redstonerserver+website@gmail.com", style: "text-decoration: none; color: #4096EE;" %> +

+
+
+
\ No newline at end of file diff --git a/app/views/redstoner_mailer/new_thread_reply_mail.html.erb b/app/views/redstoner_mailer/new_thread_reply_mail.html.erb index 2a8d05f..978a439 100644 --- a/app/views/redstoner_mailer/new_thread_reply_mail.html.erb +++ b/app/views/redstoner_mailer/new_thread_reply_mail.html.erb @@ -1,5 +1,5 @@
-
+
Hi <%= @user.name %>!

<%= link_to @reply.author.name, user_url(@reply.author), style: "text-decoration: none; color: #4096EE;" %> has replied to '<%= @reply.thread.title %>' on the Redstoner forums!

diff --git a/app/views/redstoner_mailer/new_thread_reply_mention_mail.html.erb b/app/views/redstoner_mailer/new_thread_reply_mention_mail.html.erb new file mode 100644 index 0000000..caf73de --- /dev/null +++ b/app/views/redstoner_mailer/new_thread_reply_mention_mail.html.erb @@ -0,0 +1,31 @@ +
+
+ Hi <%= @user.name %>! + +

<%= link_to @reply.author.name, user_url(@reply.author), style: "text-decoration: none; color: #4096EE;" %> mentioned you in '<%= @reply.thread.title %>' on the Redstoner forums!

+ +
+ <%# TODO: fix relative links + iframes %> + <%= render_md(@reply.content).html_safe %> +
+ +

<%= link_to "Click here", forumthread_url(@reply.thread) + "#reply-#{@reply.id}", style: "text-decoration: none; color: #4096EE;" %> to view the thread.

+ +

If you have any questions or problems, just ask one of our <%= link_to "Staff", users_url(role: "staff"), style: "text-decoration: none; color: #4096EE;" %> in-game or on the forums!

+

Your Redstoner team

+ +
+
+
+
+

Too much spam? Change <%= link_to "your notification settings", edit_notifications_user_url(@user), style: "text-decoration: none; color: #4096EE;" %>!

+

+

You can contact us via: + <%= link_to "Website", root_url, style: "text-decoration: none; color: #4096EE;" %> | + <%= link_to "Twitter", "https://twitter.com/RedstonerServer", style: "text-decoration: none; color: #4096EE;" %> | + <%= link_to "Google+", "https://google.com/+Redstoner", style: "text-decoration: none; color: #4096EE;" %> | + <%= link_to "Email", "mailto:redstonerserver+website@gmail.com", style: "text-decoration: none; color: #4096EE;" %> +

+
+
+
\ No newline at end of file diff --git a/app/views/redstoner_mailer/register_mail.html.erb b/app/views/redstoner_mailer/register_mail.html.erb index 967d5a3..3e09a1e 100644 --- a/app/views/redstoner_mailer/register_mail.html.erb +++ b/app/views/redstoner_mailer/register_mail.html.erb @@ -1,5 +1,5 @@
-
+
Hi <%= @user.name %>!

Thank you for registering on Redstoner.com!

diff --git a/test/mailers/previews/all_preview.rb b/test/mailers/previews/all_preview.rb new file mode 100644 index 0000000..d71268e --- /dev/null +++ b/test/mailers/previews/all_preview.rb @@ -0,0 +1,63 @@ +class AllPreview < ActionMailer::Preview + @@user = User.new(id: 123, uuid: "aabbccddeeff11223344556677889900", ign: "fancy_user", name: "fancy_user", email_token: "abcdefg", email: "fancymail@example.com", created_at: Time.now, last_ip: "1.2.3.4") + + def register_mail_normal + RedstonerMailer.register_mail(@@user, false) + end + + def register_mail_idiot + RedstonerMailer.register_mail(@@user, true) + end + + def register_info_mail_normal + RedstonerMailer.register_info_mail(@@user, false) + end + + def register_info_mail_idiot + RedstonerMailer.register_info_mail(@@user, true) + end + + def new_thread_mention_mail + op = User.new(id: 32, name: "TheOP", email: "theopuser@example.com") + thread = Forumthread.new(id: 123, user_author: op, title: "Wow, test thread!", content: "# Markdown!\n\n@mention\n`incline code`\n\nhtml?\n\n[yt:abcd1234]\n\n[link](/forums)") + RedstonerMailer.new_thread_mention_mail(@@user, thread) + end + + def new_thread_reply_mail + op = User.new(id: 32, name: "TheOP", email: "theopuser@example.com") + thread = Forumthread.new(id: 123, user_author: op, title: "Wow, test thread!", content: "You should not see this...") + reply = Threadreply.new(id: 312, user_author: @@user, content: "# Markdown!\n\n`incline code`\n\nhtml?\n\n[yt:abcd1234]\n\n[link](/forums)", forumthread: thread) + RedstonerMailer.new_thread_reply_mail(@@user, reply) + end + + def new_thread_reply_mention_mail + op = User.new(id: 32, name: "TheOP", email: "theopuser@example.com") + thread = Forumthread.new(id: 123, user_author: op, title: "Wow, test thread!", content: "You should not see this...") + reply = Threadreply.new(id: 312, user_author: @@user, content: "# Markdown!\n\n@mention\n`incline code`\n\nhtml?\n\n[yt:abcd1234]\n\n[link](/forums)", forumthread: thread) + RedstonerMailer.new_thread_reply_mention_mail(@@user, reply) + end + + def new_post_mention_mail + op = User.new(id: 32, name: "TheOP", email: "theopuser@example.com") + post = Blogpost.new(id: 123, user_author: op, title: "Wow, test post!", content: "@mention Wow, that is **cool**!") + RedstonerMailer.new_post_mention_mail(@@user, post) + end + + def new_post_comment_mail + op = User.new(id: 32, name: "TheOP", email: "theopuser@example.com") + post = Blogpost.new(id: 123, user_author: op, title: "Wow, test post!", content: "You should not see this...") + comment = Comment.new(id: 312, user_author: @@user, content: "Wow, that is **cool**!", blogpost: post) + RedstonerMailer.new_post_comment_mail(@@user, comment) + end + + def new_post_comment_mention_mail + op = User.new(id: 32, name: "TheOP", email: "theopuser@example.com") + post = Blogpost.new(id: 123, user_author: op, title: "Wow, test post!", content: "You should not see this...") + comment = Comment.new(id: 312, user_author: @@user, content: "@mention Wow, that is **cool**!", blogpost: post) + RedstonerMailer.new_post_comment_mail(@@user, comment) + end + + def email_change_confirm_mail + RedstonerMailer.email_change_confirm_mail(@@user) + end +end \ No newline at end of file diff --git a/test/mailers/previews/registration_preview.rb b/test/mailers/previews/registration_preview.rb deleted file mode 100644 index a7e9443..0000000 --- a/test/mailers/previews/registration_preview.rb +++ /dev/null @@ -1,37 +0,0 @@ -class RegistrationPreview < ActionMailer::Preview - @@user = User.new(id: 123, uuid: "aabbccddeeff11223344556677889900", ign: "fancy_user", name: "fancy_user", email_token: "abcdefg", email: "fancymail@example.com", created_at: Time.now, last_ip: "1.2.3.4") - - def register_mail_normal - RedstonerMailer.register_mail(@@user, false) - end - - def register_mail_idiot - RedstonerMailer.register_mail(@@user, true) - end - - def register_info_mail_normal - RedstonerMailer.register_info_mail(@@user, false) - end - - def register_info_mail_idiot - RedstonerMailer.register_info_mail(@@user, true) - end - - def new_thread_reply_mail - op = User.new(id: 32, name: "TheOP", email: "theopuser@example.com") - thread = Forumthread.new(id: 123, user_author: op, title: "Wow, test thread!", content: "You should not see this...") - reply = Threadreply.new(id: 312, user_author: @@user, content: "# Markdown!\n\n`incline code`\n\nhtml?\n\n[yt:abcd1234]\n\n[link](/forums)", forumthread: thread) - RedstonerMailer.new_thread_reply_mail(@@user, reply) - end - - def new_post_comment_mail - op = User.new(id: 32, name: "TheOP", email: "theopuser@example.com") - post = Blogpost.new(id: 123, user_author: op, title: "Wow, test post!", content: "You should not see this...") - comment = Comment.new(id: 312, user_author: @@user, content: "Wow, that is **cool**!", blogpost: post) - RedstonerMailer.new_post_comment_mail(@@user, comment) - end - - def email_change_confirm_mail - RedstonerMailer.email_change_confirm_mail(@@user) - end -end \ No newline at end of file