diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-01-28 13:55:39 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-01-28 13:55:39 +0000 |
commit | 5224b62ae360d35891e562918a438ab4761ecf1f (patch) | |
tree | ed5ce4c2ad45fdd6dc4c95ba28d6fa5db6d92925 /railties/lib | |
parent | 7ce675352653dfd1a538bee82d67af99b442047a (diff) | |
download | rails-5224b62ae360d35891e562918a438ab4761ecf1f.tar.gz rails-5224b62ae360d35891e562918a438ab4761ecf1f.tar.bz2 rails-5224b62ae360d35891e562918a438ab4761ecf1f.zip |
Resource generator depends on the model generator rather than duplicating it. Closes #7269.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6069 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties/lib')
5 files changed, 1 insertions, 50 deletions
diff --git a/railties/lib/rails_generator/generators/components/resource/resource_generator.rb b/railties/lib/rails_generator/generators/components/resource/resource_generator.rb index fd834bb149..5d9eefb5b2 100644 --- a/railties/lib/rails_generator/generators/components/resource/resource_generator.rb +++ b/railties/lib/rails_generator/generators/components/resource/resource_generator.rb @@ -39,7 +39,7 @@ class ResourceGenerator < Rails::Generator::NamedBase m.directory(File.join('test/functional', controller_class_path)) m.directory(File.join('test/unit', class_path)) - m.template('model.rb', File.join('app/models', class_path, "#{file_name}.rb")) + m.dependency 'model', [singular_name] + @args, :collision => :skip m.template( 'controller.rb', File.join('app/controllers', controller_class_path, "#{controller_file_name}_controller.rb") @@ -47,19 +47,6 @@ class ResourceGenerator < Rails::Generator::NamedBase m.template('functional_test.rb', File.join('test/functional', controller_class_path, "#{controller_file_name}_controller_test.rb")) m.template('helper.rb', File.join('app/helpers', controller_class_path, "#{controller_file_name}_helper.rb")) - m.template('unit_test.rb', File.join('test/unit', class_path, "#{file_name}_test.rb")) - m.template('fixtures.yml', File.join('test/fixtures', "#{table_name}.yml")) - - unless options[:skip_migration] - m.migration_template( - 'migration.rb', 'db/migrate', - :assigns => { - :migration_name => "Create#{class_name.pluralize.gsub(/::/, '')}", - :attributes => attributes - }, - :migration_file_name => "create_#{file_path.gsub(/\//, '_').pluralize}" - ) - end m.route_resources controller_file_name end diff --git a/railties/lib/rails_generator/generators/components/resource/templates/fixtures.yml b/railties/lib/rails_generator/generators/components/resource/templates/fixtures.yml index 9f5ae29a81..e69de29bb2 100644 --- a/railties/lib/rails_generator/generators/components/resource/templates/fixtures.yml +++ b/railties/lib/rails_generator/generators/components/resource/templates/fixtures.yml @@ -1,11 +0,0 @@ -# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html -one: - id: 1 -<% for attribute in attributes -%> - <%= attribute.name %>: <%= attribute.default %> -<% end -%> -two: - id: 2 -<% for attribute in attributes -%> - <%= attribute.name %>: <%= attribute.default %> -<% end -%>
\ No newline at end of file diff --git a/railties/lib/rails_generator/generators/components/resource/templates/migration.rb b/railties/lib/rails_generator/generators/components/resource/templates/migration.rb index 2a305a6a9d..e69de29bb2 100644 --- a/railties/lib/rails_generator/generators/components/resource/templates/migration.rb +++ b/railties/lib/rails_generator/generators/components/resource/templates/migration.rb @@ -1,13 +0,0 @@ -class <%= migration_name %> < ActiveRecord::Migration - def self.up - create_table :<%= table_name %> do |t| -<% for attribute in attributes -%> - t.column :<%= attribute.name %>, :<%= attribute.type %> -<% end -%> - end - end - - def self.down - drop_table :<%= table_name %> - end -end diff --git a/railties/lib/rails_generator/generators/components/resource/templates/model.rb b/railties/lib/rails_generator/generators/components/resource/templates/model.rb index 8d4c89e912..e69de29bb2 100644 --- a/railties/lib/rails_generator/generators/components/resource/templates/model.rb +++ b/railties/lib/rails_generator/generators/components/resource/templates/model.rb @@ -1,2 +0,0 @@ -class <%= class_name %> < ActiveRecord::Base -end diff --git a/railties/lib/rails_generator/generators/components/resource/templates/unit_test.rb b/railties/lib/rails_generator/generators/components/resource/templates/unit_test.rb index b464de47a2..e69de29bb2 100644 --- a/railties/lib/rails_generator/generators/components/resource/templates/unit_test.rb +++ b/railties/lib/rails_generator/generators/components/resource/templates/unit_test.rb @@ -1,10 +0,0 @@ -require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../test_helper' - -class <%= class_name %>Test < Test::Unit::TestCase - fixtures :<%= table_name %> - - # Replace this with your real tests. - def test_truth - assert true - end -end |