Sha256: 3e893204bb771ca8b9549e35b626463a6b1823c2d081198a6c37a07cafb92e71

Contents?: true

Size: 1.91 KB

Versions: 4

Compression:

Stored size: 1.91 KB

Contents

# Copyright (c) 2008-2013 Michael Dvorkin and contributors.
#
# Fat Free CRM is freely distributable under the terms of MIT license.
# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
#------------------------------------------------------------------------------
require 'spec_helper'

describe SubscriptionMailer do
  describe "comment notification" do
    let(:user) { FactoryGirl.create(:user, email: 'notify_me@example.com') }
    let(:commentable) { FactoryGirl.create(:opportunity, id: 47, name: 'Opportunity name') }
    let(:comment) { FactoryGirl.create(:comment, commentable: commentable) }
    let(:mail) { SubscriptionMailer.comment_notification(user, comment) }

    before :each do
      allow(Setting.email_comment_replies).to receive(:[]).with(:address).and_return("email_comment_reply@example.com")
    end

    it "uses email defined in settings as the sender" do
      expect(mail.from).to eql(["email_comment_reply@example.com"])
    end

    it "sets user 'notify_me@example.com' as recipient" do
      expect(mail.to).to eq(["notify_me@example.com"])
    end

    it "sets the subject" do
      expect(mail.subject).to eq("RE: [opportunity:47] Opportunity name")
    end

    it "includes link to opportunity in body" do
      expect(mail.body.encoded).to match('http://www.example.com/opportunities/47')
    end

    it "should set default reply-to address if email doesn't exist" do
      allow(Setting.email_comment_replies).to receive(:[]).with(:address).and_return("")
      allow(Setting).to receive(:host).and_return("fatfreecrm.com")
      expect(mail.from).to eql(["no-reply@fatfreecrm.com"])
    end

    it "should set default reply-to address if email and host don't exist" do
      allow(Setting.email_comment_replies).to receive(:[]).with(:address).and_return("")
      allow(Setting).to receive(:host).and_return("")
      expect(mail.from).to eql(["no-reply@example.com"])
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
fat_free_crm-0.14.2 spec/mailers/subscription_mailer_spec.rb
fat_free_crm-0.14.1 spec/mailers/subscription_mailer_spec.rb
fat_free_crm-0.14.0 spec/mailers/subscription_mailer_spec.rb
reduced_fat_crm-0.14.0 spec/mailers/subscription_mailer_spec.rb