diff options
author | José Valim <jose.valim@gmail.com> | 2009-07-15 22:37:22 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2009-07-15 22:37:22 +0200 |
commit | 8d47078a492de9e3fca61ec6894e975d570ef449 (patch) | |
tree | 447d845fdcbbf5ae337568fa1b1c7eb37f87de00 /railties/test | |
parent | b4ef958de6b16294094de28d00ba25fe2f48accc (diff) | |
download | rails-8d47078a492de9e3fca61ec6894e975d570ef449.tar.gz rails-8d47078a492de9e3fca61ec6894e975d570ef449.tar.bz2 rails-8d47078a492de9e3fca61ec6894e975d570ef449.zip |
Added source_paths to rails generators. If a template is added to RAILS_ROOT/lib/templates/base/generator it will be used. For example, to customize edit.html.erb template on scaffold, just add a customized copy at RAILS_ROOT/lib/templates/erb/scaffold.
Diffstat (limited to 'railties/test')
-rw-r--r-- | railties/test/generators_test.rb | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/railties/test/generators_test.rb b/railties/test/generators_test.rb index 964def4158..78c05f2eb8 100644 --- a/railties/test/generators_test.rb +++ b/railties/test/generators_test.rb @@ -84,7 +84,7 @@ class GeneratorsTest < GeneratorsTestCase assert_equal "Others: active_record:fixjour, fixjour, mspec, rails:javascripts, wrong.", output end - def test_warning_is_raised_if_generator_cant_be_loaded + def test_warning_is_shown_if_generator_cant_be_loaded output = capture(:stderr){ Rails::Generators.find_by_namespace(:wrong) } assert_match /\[WARNING\] Could not load generator at/, output assert_match /Error: uninitialized constant Rails::Generator/, output @@ -96,4 +96,22 @@ class GeneratorsTest < GeneratorsTestCase ensure Thor::Base.shell = Thor::Shell::Color end + + def test_rails_root_templates + template = File.join(RAILS_ROOT, "lib", "templates", "active_record", "model", "model.rb") + + # Create template + mkdir_p(File.dirname(template)) + File.open(template, 'w'){ |f| f.write "empty" } + + output = capture(:stdout) do + Rails::Generators.invoke :model, ["user"], :destination_root => destination_root + end + + assert_file "app/models/user.rb" do |content| + assert_equal "empty", content + end + ensure + rm_rf File.dirname(template) + end end |