0
我正在編寫郵件發送多個郵件的一些規格。 郵寄包裝的控制器:DRY在規格郵寄
def create
@message = Message.new(params[:message])
if @message.valid?
@message.email.each do |email|
MessageMailer.new_message(@message, email).deliver
end
redirect_to users_index_path, :notice => "Email sent correctly"
else
notice = "There was an error"
render :new
end
end
和規範:
describe "POST 'create' for a diffusion" do
it "returns http success" do
@diffusion = Fabricate.build(:diffusion)
post 'create', message: @diffusion
response.should be_success
@before_send = ActionMailer::Base.deliveries.size
@diffusion.email.each do |email|
MessageMailer.new_message(@diffusion, email).deliver
end
ActionMailer::Base.deliveries.size.should eq @before_send + @diffusion.email.size
end
end
的問題是,當我創建一個POST請求,由於某種原因,它不發送電子郵件,所以我必須強迫它。
當我創建發佈請求時,是否有強制發送電子郵件的方法?重複自己是否是強制性的?
在此先感謝!