aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails_generator/generators/components/mailer/mailer_generator.rb
blob: 81d4599f7ffe99364c062d9721a1b68c465b5388 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
class MailerGenerator < Rails::Generator::NamedBase
  def manifest
    record do |m|
      # Check for class naming collisions.
      m.class_collisions class_name, "#{class_name}Test"

      # Mailer class and unit test.
      m.template "mailer.rb",    "app/models/#{file_name}.rb"
      m.template "unit_test.rb", "test/unit/#{file_name}_test.rb"

      # Views and fixtures directories.
      m.directory "app/views/#{file_name}"
      m.directory "test/fixtures/#{table_name}"

      # View template and fixture for each action.
      actions.each do |action|
        m.template "view.rhtml",
                   "app/views/#{file_name}/#{action}.rhtml",
                   :assigns => { :action => action }
        m.template "fixture.rhtml",
                   "test/fixtures/#{table_name}/#{action}",
                   :assigns => { :action => action }
      end
    end
  end
end