문제

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