Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp Ullmann committed Apr 11, 2012
2 parents 7921818 + 34b5215 commit 314f53a
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 5 deletions.
5 changes: 3 additions & 2 deletions app/mailers/subscription_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ class SubscriptionMailer < ActionMailer::Base
def comment_notification(user, comment)
@entity = comment.commentable
@entity_type = @entity.class.to_s
@entity_name = @entity.respond_to?(:full_name) ? @entity.full_name : @entity.name

@comment = comment
@user = comment.user

# If entity has tags, join them and wrap in parantheses
entity_tags = @entity.tag_list.any? ? "(#{@entity.tag_list.join(', ')})" : ""
subject = "RE: [#{@entity_type.downcase}:#{@entity.id}] #{@entity.full_name} #{@entity_tags}"
subject = "RE: [#{@entity_type.downcase}:#{@entity.id}] #{@entity_name}"
subject << " (#{@entity.tag_list.join(', ')})" if @entity.tag_list.any?

mail :subject => subject,
:to => user.email,
Expand Down
4 changes: 2 additions & 2 deletions app/views/subscription_mailer/comment_notification.text.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<%= I18n.t('comment_notification.intro', :user_full_name => @user.full_name, :entity_type => @entity_type, :entity_name => @entity.full_name) %>
<%= I18n.t('comment_notification.intro', :user_full_name => @user.full_name, :entity_type => @entity_type, :entity_name => @entity_name) %>
<%= @comment.comment.html_safe %>


--
<%= I18n.t('comment_notification.reply_instructions', :entity => @entity_type.downcase ) %>: <%= polymorphic_url(@entity) %>
<%= I18n.t('comment_notification.reply_instructions', :entity => @entity_type.downcase) %>: <%= polymorphic_url(@entity) %>
2 changes: 1 addition & 1 deletion config/initializers/action_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
unless Rails.env.test?
# Set SMTP settings if present.
smtp_settings = Setting.smtp || {}
if smtp_settings["user_name"].present? && smtp_settings["password"].present?
if smtp_settings["address"].present?
Rails.application.config.action_mailer.delivery_method = :smtp
Rails.application.config.action_mailer.smtp_settings = smtp_settings
end
Expand Down
1 change: 1 addition & 0 deletions lib/fat_free_crm/gem_dependencies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
require 'ransack'
require 'paper_trail'
require 'cancan'
require 'squeel'

# Load redcloth if available (for textile markup in emails)
begin
Expand Down
17 changes: 17 additions & 0 deletions spec/mailers/subscription_mailer_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe SubscriptionMailer do

describe "comment notification" do
let(:user) { FactoryGirl.create(:user) }
let(:commentable) { FactoryGirl.create(:opportunity, :id => 47, :name => 'Opportunity name') }
let(:comment) { FactoryGirl.create(:comment, :commentable => commentable) }
let(:mail) { SubscriptionMailer.comment_notification(user, comment) }

it "send user password reset url" do
mail.subject.should eq("RE: [opportunity:47] Opportunity name")
mail.to.should eq([user.email])
mail.body.encoded.should match(polymorphic_url(commentable))
end
end
end

0 comments on commit 314f53a

Please sign in to comment.