aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/application
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2011-10-02 12:14:31 +0200
committerJosé Valim <jose.valim@gmail.com>2011-10-02 12:15:21 +0200
commit753424079e497d8ab7bc611093a34194200e3c7c (patch)
tree120e1b753e24a52d326829c55de6d40bf7937281 /railties/test/application
parent1efe41dc366d21123842dea34ba95ddf1ab284d4 (diff)
downloadrails-753424079e497d8ab7bc611093a34194200e3c7c.tar.gz
rails-753424079e497d8ab7bc611093a34194200e3c7c.tar.bz2
rails-753424079e497d8ab7bc611093a34194200e3c7c.zip
Provide initialize_on_precompile which, when set to false, does not initialize the app for precompilation. Defaults to true.
Diffstat (limited to 'railties/test/application')
-rw-r--r--railties/test/application/assets_test.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/railties/test/application/assets_test.rb b/railties/test/application/assets_test.rb
index 118ffff44b..7bace25fef 100644
--- a/railties/test/application/assets_test.rb
+++ b/railties/test/application/assets_test.rb
@@ -395,7 +395,30 @@ module ApplicationTests
assert_match(/<script src="\/assets\/xmlhr-([0-z]+)\.js\?body=1" type="text\/javascript"><\/script>/, last_response.body)
end
+ test "assets can access model information when precompiling" do
+ app_file "app/models/post.rb", "class Post; end"
+ app_file "app/assets/javascripts/application.js", "//= require_tree ."
+ app_file "app/assets/javascripts/xmlhr.js.erb", "<%= Post.name %>"
+
+ add_to_config "config.assets.digest = false"
+ precompile!
+ assert_equal "Post;\n", File.read("#{app_path}/public/assets/application.js")
+ end
+
+ test "assets can't access model information when precompiling if not initializing the app" do
+ app_file "app/models/post.rb", "class Post; end"
+ app_file "app/assets/javascripts/application.js", "//= require_tree ."
+ app_file "app/assets/javascripts/xmlhr.js.erb", "<%= defined?(Post) || :NoPost %>"
+
+ add_to_config "config.assets.digest = false"
+ add_to_config "config.assets.initialize_on_precompile = false"
+
+ precompile!
+ assert_equal "NoPost;\n", File.read("#{app_path}/public/assets/application.js")
+ end
+
private
+
def app_with_assets_in_view
app_file "app/assets/javascripts/application.js", "//= require_tree ."
app_file "app/assets/javascripts/xmlhr.js", "function f1() { alert(); }"