Permalink
Browse files

Merge pull request #14325 from robin850/issue-12133

Make the rails:template rake task load initializers
  • Loading branch information...
2 parents 18c6516 + 9c53b8b commit 1fbb9056ef9d9c1718d88fb19ae54d17806ca4ce @spastorino spastorino committed Mar 8, 2014
Showing with 18 additions and 1 deletion.
  1. +6 −0 railties/CHANGELOG.md
  2. +1 −1 railties/lib/rails/tasks/framework.rake
  3. +11 −0 railties/test/application/rake_test.rb
View
@@ -1,3 +1,9 @@
+* Make the `rails:template` rake task load the application's initializers.
+
+ Fixes #12133.
+
+ *Robin Dupret*
+
* Introduce `Rails.gem_version` as a convenience method to return
`Gem::Version.new(Rails.version)`, suggesting a more reliable way to perform
version comparison.
@@ -3,7 +3,7 @@ namespace :rails do
task update: [ "update:configs", "update:bin" ]
desc "Applies the template supplied by LOCATION=(/path/to/template) or URL"
- task :template do
+ task template: :environment do
template = ENV["LOCATION"]
raise "No LOCATION value given. Please set LOCATION either as path to a file or a URL" if template.blank?
template = File.expand_path(template) if template !~ %r{\A[A-Za-z][A-Za-z0-9+\-\.]*://}
@@ -271,5 +271,16 @@ def test_copy_templates
end
end
end
+
+ def test_template_load_initializers
+ app_file "config/initializers/dummy.rb", "puts 'Hello, World!'"
+ app_file "template.rb", ""
+
+ output = Dir.chdir(app_path) do
+ `bundle exec rake rails:template LOCATION=template.rb`
+ end
+
+ assert_match(/Hello, World!/, output)
+ end
end
end

0 comments on commit 1fbb905

Please sign in to comment.