質問

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