मेरे पास एक एक्शनमेलर क्लास और संबंधित ओवरहेड है, यह पूरी तरह से काम करता है। मेरे यूनिट टेस्ट में (रेल न्यूनतम डिफ़ॉल्ट) हालांकि, ईमेल निकाय खाली है। ऐसा क्यों है?रेल में मेरा मेल निकाय केवल मेरे परीक्षण में क्यों खाली है?
मेरी मेलर वर्ग:
class TermsMailer < ApplicationMailer
default from: "[email protected]"
def notice_email(user,filename)
@user = user
@file = filename
mail(to: "[email protected]", subject: 'Data downloaded')
end
end
अपने परीक्षण:
require 'test_helper'
class TermsMailerTest < ActionMailer::TestCase
test "notice" do
email = TermsMailer.notice_email(users(:me),'file.ext').deliver_now
assert_not ActionMailer::Base.deliveries.empty?
assert_equal ['[email protected]'], email.from
assert_equal ['[email protected]'], email.to
assert_equal 'Data downloaded', email.subject
assert_equal 'arbitrary garbage for comparison', email.body.to_s
end
end
इस मेलर के लिए विचारों खाली नहीं कर रहे हैं, और सही सामग्री वास्तव में ईमेल में भेजा जाता है। तो मेरे परीक्षण में ईमेल निकाय खाली क्यों है?
'email.body.encoded' का उपयोग करें। मैं इसे एक उत्तर के रूप में पोस्ट करूंगा, लेकिन मुझे याद नहीं है कि मुझे यह परिवर्तन क्यों करना पड़ा। – messanjah