class ReportMailer < ActionMailer::Base
  def venues
    @venues ||= Venue.find(VENUE_MAP.values)
  end
end

How can I test venues, if:

ReportMailer.new => nil

How is this behavior called? is ReportMailer an abstract class?

有帮助吗?

解决方案 2

I extracted methods to module and then, included and extended it:

class ReportMailer
  include ReportMailer::PrivateMethods
  extend  ReportMailer::PrivateMethods
...

In app/models/report_mailer/private_methods.rb:

module ReportMailer::PrivateMethods
  ...

其他提示

All the methods you define in ReportMailer can be called as class methods

ReportMailer.venues

To deliver the email

ReportMailer.venues.deliver

Read

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top