aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorSantiago Pastorino <santiago@wyeworks.com>2014-03-08 16:15:12 -0200
committerSantiago Pastorino <santiago@wyeworks.com>2014-03-08 16:15:12 -0200
commit1fbb9056ef9d9c1718d88fb19ae54d17806ca4ce (patch)
tree8ec12e2bdfe677b39a2c79dd165cfdc9ebb2d534 /railties
parent18c651659e4548661c385bd3c60a774ebd9bdaa2 (diff)
parent9c53b8b89f0b4aec5a2ec3611cefae8e7b6514a5 (diff)
downloadrails-1fbb9056ef9d9c1718d88fb19ae54d17806ca4ce.tar.gz
rails-1fbb9056ef9d9c1718d88fb19ae54d17806ca4ce.tar.bz2
rails-1fbb9056ef9d9c1718d88fb19ae54d17806ca4ce.zip
Merge pull request #14325 from robin850/issue-12133
Make the rails:template rake task load initializers
Diffstat (limited to 'railties')
-rw-r--r--railties/CHANGELOG.md6
-rw-r--r--railties/lib/rails/tasks/framework.rake2
-rw-r--r--railties/test/application/rake_test.rb11
3 files changed, 18 insertions, 1 deletions
diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md
index 5096f5324a..95f2c25a15 100644
--- a/railties/CHANGELOG.md
+++ b/railties/CHANGELOG.md
@@ -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.
diff --git a/railties/lib/rails/tasks/framework.rake b/railties/lib/rails/tasks/framework.rake
index e669315934..3c8f8c6b87 100644
--- a/railties/lib/rails/tasks/framework.rake
+++ b/railties/lib/rails/tasks/framework.rake
@@ -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+\-\.]*://}
diff --git a/railties/test/application/rake_test.rb b/railties/test/application/rake_test.rb
index 317e73245c..e8c8de9f73 100644
--- a/railties/test/application/rake_test.rb
+++ b/railties/test/application/rake_test.rb
@@ -271,5 +271,16 @@ module ApplicationTests
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