2012-08-08 4 views
3

app/models에 다음 우편물 번호가 있습니다.Redmine Plugin의 ActionMailer 오류

class Mailman < ActionMailer::Base 

    default :from => "xyz" 
    # Sends an Email reminder to all the users who missed a pickup date 
    def check_out_reminder(reservation) 
    recipient = reservation.user.mail 
    subject = "Checkout Reminder for '#{reservation.bookable.name}'." 
    mail(:to => recipient, :subject => subject) 
    end 

    def check_in_reminder(reservation) 
    recipient = reservation.user.mail 
    subject = "Checkin Reminder for '#{reservation.bookable.name}'." 
    mail(:to => recipient, :subject => subject) 
    end 

end 

나는 테스트에서 테스트 코드 /로 간다 단위가 있습니다

test_check_out_reminder(MailmanTest): 
NoMethodError: undefined method `mail' for nil:NilClass 
    /Users/myth/Learn/Code/redmine/plugins/redmine_asset_tracker/app/models/mailman.rb:9:in `check_out_reminder' 
    /Users/myth/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.2.3/lib/abstract_controller/base.rb:167:in `process_action' 
    /Users/myth/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.2.3/lib/abstract_controller/base.rb:121:in `process' 
    /Users/myth/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.2.3/lib/abstract_controller/rendering.rb:45:in `process' 
    /Users/myth/.rvm/gems/ruby-1.9.3-p0/gems/actionmailer-3.2.3/lib/action_mailer/base.rb:456:in `process' 
    /Users/myth/.rvm/gems/ruby-1.9.3-p0/gems/actionmailer-3.2.3/lib/action_mailer/base.rb:451:in `initialize' 
    /Users/myth/.rvm/gems/ruby-1.9.3-p0/gems/actionmailer-3.2.3/lib/action_mailer/base.rb:438:in `new' 
    /Users/myth/.rvm/gems/ruby-1.9.3-p0/gems/actionmailer-3.2.3/lib/action_mailer/base.rb:438:in `method_missing' 
    /Users/myth/Learn/Code/redmine/plugins/redmine_asset_tracker/test/unit/mailer_test.rb:9:in `test_check_out_reminder' 
    /Users/myth/.rvm/gems/ruby-1.9.3-p0/gems/mocha-0.11.4/lib/mocha/integration/mini_test/version_230_to_262.rb:28:in `run' 

왜 메일 메소드가 인식되지 않는 :

require File.expand_path('../../test_helper', __FILE__) 

class MailmanTest < ActionMailer::TestCase 
    fixtures :reservations 

    def test_check_out_reminder 
    reservation = Reservation.first 
    # Send the email, then test that it got queued 
    Mailman.check_out_reminder(reservation).deliver 
    assert !ActionMailer::Base.deliveries.empty? 
    end 

end 

이 실행에 대한 시험은 그러나 오류를 제공을 내가 올바른 수업을 물려받을 때조차도?

답변

0

문제는 누락 된 픽스쳐입니다. 라인 recipient = reservation.user.mail이 오류의 원인이 아니며 조치 메일러가 아닙니다. mail(:to => recipient, :subject => subject)

+0

조명기 문제는 어디에서 발견 했습니까? 또한 사람들이 자신의 답변을 수락하면 사람들은 그것이 해결되었다는 것을 알 수 있습니다. :) –