Skip to content
Browse files

Merge remote-tracking branch 'upstream/master'

  • Loading branch information...
2 parents 7921818 + 34b5215 commit 314f53a217d101c44e6e8a160bd83c4285d2e02f @create-philipp-ullmann create-philipp-ullmann committed Apr 11, 2012
View
5 app/mailers/subscription_mailer.rb
@@ -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,
View
4 app/views/subscription_mailer/comment_notification.text.erb
@@ -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) %>
View
2 config/initializers/action_mailer.rb
@@ -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
View
1 lib/fat_free_crm/gem_dependencies.rb
@@ -34,6 +34,7 @@
require 'ransack'
require 'paper_trail'
require 'cancan'
+require 'squeel'
# Load redcloth if available (for textile markup in emails)
begin
View
17 spec/mailers/subscription_mailer_spec.rb
@@ -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.
Something went wrong with that request. Please try again.