English 中文(简体)
邮递:没有有人居住的地方
原标题:ActionMailer::Base.deliveries array not being populated

I m trying to run an rspec test. You can see most of that code here.

Maybe it s relevant: CoRegEmailWorker.perform contains this:

ProvisionalUser.where("unsubscribed = false AND disabled = false AND (email_sent_count < ? OR email_sent_count is NULL) AND (last_email_sent <= ? OR last_email_sent IS NULL) AND sign_up_date IS NULL",
                      ProvisionalUser::EMAIL_COUNT_LIMIT, email_sending_interval.hours.ago).
                each{ |user|
  begin
    user.send_email
  rescue Exception => ex
    logger.error ex
  end
}

临时 用户有这种方法:

  def send_email
    self.email_sent_count = self.email_sent_count.nil? ? 1 : self.email_sent_count + 1
    self.last_email_sent = DateTime.now
    self.disabled = true if self.email_sent_count == EMAIL_COUNT_LIMIT
    self.save!

    ProvisionalUserNotifier.send_registration_invite(self.id).deliver
  end

最后,ProvisionalUser Notifiermains from mailGunNotifier/code>, 继承Actionmail

问题一是,交付阵列没有有人居住。 在我的“会议/环境/测试”。 我有:

config.action_mailer.perform_deliveries = true
config.action_mailer.delivery_method = :test

我不认为这里还需要什么。

i 甚至如此:

require "spec_helper"
require "action_mailer"

describe "unsubscribe functionality" do

  pu1 = ProvisionalUser.new
  pu1.email =  [email protected] 
  pu1.partner =  partner 
  pu1.first_name =  joe 
  pu1.save!

  before(:each) do
    ActionMailer::Base.delivery_method = :test
    ActionMailer::Base.perform_deliveries = true
    ActionMailer::Base.deliveries = []
  end

  it "should send emails to subscribed users only" do
    unsubscribed_user = FactoryGirl.build(:unsubscribed_user)
    unsubscribed_user.save!

    subscribed_user = FactoryGirl.create(:subscribed_user)
    CoRegEmailWorker.perform
    ActionMailer::Base.deliveries.length.should == 1
    ActionMailer::Base.deliveries.first.email.should =~ subscribed_user.email
    #sent.first.email.should_not =~ unsubscribed_user.email
    #sent.first.email.should =~ subscribed_user.email
  end

  def sent
    ActionMailer::Base.deliveries
  end

end
最佳回答

wow. that was really annoying. because the exception was being eaten, i wasn t seeing that I was missing a neccessary value for the subject of the email to work.

问题回答

暂无回答




相关问题
rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

SSL slowness in EC2

We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...

Auth-code with A-Za-z0-9 to use in an URL parameter

As part of a web application I need an auth-code to pass as a URL parameter. I am currently using (in Rails) : Digest::SHA1.hexdigest((object_id + rand(255)).to_s) Which provides long strings like : ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

activerecord has_many :through find with one sql call

I have a these 3 models: class User < ActiveRecord::Base has_many :permissions, :dependent => :destroy has_many :roles, :through => :permissions end class Permission < ActiveRecord::...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...