aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2011-06-21 11:18:50 -0300
committerJosé Valim <jose.valim@gmail.com>2011-06-21 11:24:06 -0300
commit5a26b886455a9fda846109dbcf4595b107e392bc (patch)
treefd9ada2b21b433ab7901dc51dc30c409bb98f37c /railties/test
parent354709fe89a4cb9b26a6c19d377408bab2a07590 (diff)
downloadrails-5a26b886455a9fda846109dbcf4595b107e392bc.tar.gz
rails-5a26b886455a9fda846109dbcf4595b107e392bc.tar.bz2
rails-5a26b886455a9fda846109dbcf4595b107e392bc.zip
Create an :assets group in the Gemfile.
This group is required by default only on development and test (you can change it on config/application.rb). `rake assets:precompile` will automatically add the assets group to Rails.groups (and consequently Bundler.require) and should work transparently.
Diffstat (limited to 'railties/test')
-rw-r--r--railties/test/application/assets_test.rb14
-rw-r--r--railties/test/isolation/abstract_unit.rb4
2 files changed, 17 insertions, 1 deletions
diff --git a/railties/test/application/assets_test.rb b/railties/test/application/assets_test.rb
index 2b593005a2..a93786becd 100644
--- a/railties/test/application/assets_test.rb
+++ b/railties/test/application/assets_test.rb
@@ -1,8 +1,9 @@
require 'isolation/abstract_unit'
+require 'active_support/core_ext/kernel/reporting'
require 'rack/test'
module ApplicationTests
- class RoutingTest < Test::Unit::TestCase
+ class AssetsTest < Test::Unit::TestCase
include ActiveSupport::Testing::Isolation
include Rack::Test::Methods
@@ -34,6 +35,17 @@ module ApplicationTests
assert_match "alert()", last_response.body
end
+ test "assets are compiled properly" do
+ app_file "app/assets/javascripts/application.js", "alert();"
+
+ capture(:stdout) do
+ Dir.chdir(app_path){ `bundle exec rake assets:precompile` }
+ end
+
+ file = Dir["#{app_path}/public/assets/application-*.js"][0]
+ assert_equal "alert();\n", File.read(file)
+ end
+
test "does not stream session cookies back" do
app_file "app/assets/javascripts/demo.js.erb", "<%= :alert %>();"
diff --git a/railties/test/isolation/abstract_unit.rb b/railties/test/isolation/abstract_unit.rb
index 0a203fd4d0..685d1b154b 100644
--- a/railties/test/isolation/abstract_unit.rb
+++ b/railties/test/isolation/abstract_unit.rb
@@ -238,6 +238,10 @@ module TestHelpers
end
end
+ def remove_file(path)
+ FileUtils.rm_rf "#{app_path}/#{path}"
+ end
+
def controller(name, contents)
app_file("app/controllers/#{name}_controller.rb", contents)
end