From 16c9d0ec15a44dbc2dd087041007eb5e92ce5ab7 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Sat, 31 Dec 2011 14:51:47 +0400 Subject: [PATCH] [refs #54] Fix some bugs of issues and comments + add comment body to email --- app/controllers/comments_controller.rb | 2 +- app/mailers/user_mailer.rb | 2 +- app/models/comment.rb | 8 +++----- app/views/issues/show.html.haml | 2 +- app/views/user_mailer/new_comment_notification.haml | 2 ++ 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index e20aa3af1..4b70d8127 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -16,7 +16,7 @@ class CommentsController < ApplicationController @comment.user = current_user if @comment.save flash[:notice] = I18n.t("flash.comment.saved") - redirect_to :back + redirect_to [@commentable.project, @commentable] else flash[:error] = I18n.t("flash.comment.save_error") render :action => 'new' diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index 2c43482e1..9be195dd4 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -1,7 +1,7 @@ # coding: UTF-8 class UserMailer < ActionMailer::Base - default :from => APP_CONFIG['no-reply-email'] + default :from => APP_CONFIG['do-not-reply-email'] def new_user_notification(user) @user = user diff --git a/app/models/comment.rb b/app/models/comment.rb index 439fd0733..aceb80a7a 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -9,11 +9,9 @@ class Comment < ActiveRecord::Base protected def deliver_new_comment_notification - recipients = self.commentable.project.relations.by_role('admin').where(:object_type => 'User').map { |rel| rel.read_attribute(:object_id) } - recipients = recipients | [self.commentable.user_id] - recipients = recipients | [self.commentable.project.owner_id] if self.commentable.project.owner_type == 'User' - recipients.each do |recipient_id| - recipient = User.find(recipient_id) + subscribes = self.commentable.subscribes + subscribes.each do |subscribe| + recipient = subscribe.user UserMailer.delay.new_comment_notification(self, recipient) end end diff --git a/app/views/issues/show.html.haml b/app/views/issues/show.html.haml index 49b229b5c..2a79e66a3 100644 --- a/app/views/issues/show.html.haml +++ b/app/views/issues/show.html.haml @@ -52,5 +52,5 @@ %h2.title = t("layout.comments.new_header") .inner - = form_for :comment, :url => project_issue_comments_path(@project, @issue), :method => :post, :html => { :class => :form } do |f| + = form_for :comment, :url => project_issue_comments_path(@project, @issue.id), :method => :post, :html => { :class => :form } do |f| = render :partial => "comments/form", :locals => {:f => f} diff --git a/app/views/user_mailer/new_comment_notification.haml b/app/views/user_mailer/new_comment_notification.haml index 88692f64e..315a56b88 100644 --- a/app/views/user_mailer/new_comment_notification.haml +++ b/app/views/user_mailer/new_comment_notification.haml @@ -3,5 +3,7 @@ %p К задаче #{ link_to @comment.commentable.title, [@comment.commentable.project, @comment.commentable] } был добавлен новый комментарий. +%p "#{ @comment.body }" + %p== Команда поддержки «ROSA Build System»