2008-04-18 18:10:58 -04:00
|
|
|
require 'generators/generator_test_helper'
|
|
|
|
|
|
|
|
class RailsMailerGeneratorTest < GeneratorTestCase
|
|
|
|
|
|
|
|
def test_generates_mailer
|
|
|
|
run_generator('mailer', %w(Notifier reset_password))
|
|
|
|
|
|
|
|
assert_generated_model_for :notifier, 'ActionMailer::Base' do |model|
|
|
|
|
assert_has_method model, :reset_password do |name, body|
|
|
|
|
assert_equal [
|
2008-04-18 18:13:15 -04:00
|
|
|
"subject 'Notifier#reset_password'",
|
|
|
|
"recipients ''",
|
|
|
|
"from ''",
|
|
|
|
"sent_on sent_at",
|
|
|
|
"",
|
2008-04-18 18:19:28 -04:00
|
|
|
"body :greeting => 'Hi,'"
|
2008-04-18 18:10:58 -04:00
|
|
|
],
|
|
|
|
body.split("\n").map{|line| line.sub(' '*4, '') }
|
|
|
|
end
|
2008-04-21 15:31:54 -04:00
|
|
|
|
|
|
|
assert_no_match /(self.default_url_options =|default_url_options\[.*\] =)/, model,
|
|
|
|
'individual mailer models should not set default_url_options because the options are shared by all mailers'
|
2008-04-18 18:10:58 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
assert_generated_views_for :notifier, 'reset_password.erb'
|
|
|
|
assert_generated_unit_test_for :notifier, 'ActionMailer::TestCase'
|
|
|
|
assert_generated_file "test/fixtures/notifier/reset_password"
|
|
|
|
end
|
|
|
|
end
|