diff options
Diffstat (limited to 'railties/test/application')
-rw-r--r-- | railties/test/application/assets_test.rb | 22 | ||||
-rw-r--r-- | railties/test/application/configuration_test.rb | 11 | ||||
-rw-r--r-- | railties/test/application/rake_test.rb | 21 |
3 files changed, 43 insertions, 11 deletions
diff --git a/railties/test/application/assets_test.rb b/railties/test/application/assets_test.rb index b76dae8e18..e1eee71a9e 100644 --- a/railties/test/application/assets_test.rb +++ b/railties/test/application/assets_test.rb @@ -35,16 +35,30 @@ module ApplicationTests assert_match "alert()", last_response.body end + test "assets do not require compressors until it is used" do + app_file "app/assets/javascripts/demo.js.erb", "<%= :alert %>();" + ENV["RAILS_ENV"] = "production" + require "#{app_path}/config/environment" + + assert !defined?(Uglifier) + get "/assets/demo.js" + assert_match "alert()", last_response.body + assert defined?(Uglifier) + end + test "assets are compiled properly" do app_file "app/assets/javascripts/application.js", "alert();" + app_file "app/assets/javascripts/foo/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_not_nil file, "Expected application.js asset to be generated, but none found" - assert_equal "alert();\n", File.read(file) + files = Dir["#{app_path}/public/assets/application-*.js"] + files << Dir["#{app_path}/public/assets/foo/application-*.js"].first + files.each do |file| + assert_not_nil file, "Expected application.js asset to be generated, but none found" + assert_equal "alert();\n", File.read(file) + end end test "assets are cleaned up properly" do diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index 2547863d12..448982f9de 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -45,7 +45,7 @@ module ApplicationTests Rails.env = "development" assert_equal [:default, "development"], Rails.groups assert_equal [:default, "development", :assets], Rails.groups(:assets => [:development]) - assert_equal [:default, "development", :assets], Rails.groups(:assets => %w(development)) + assert_equal [:default, "development", :another, :assets], Rails.groups(:another, :assets => %w(development)) Rails.env = "test" assert_equal [:default, "test"], Rails.groups(:assets => [:development]) @@ -516,5 +516,14 @@ module ApplicationTests get "/", { :format => :xml }, "HTTP_ACCEPT" => "application/xml" assert_equal 'XML', last_response.body end + + test "Rails.application#env_config exists and include some existing parameters" do + make_basic_app + + assert_respond_to app, :env_config + assert_equal app.env_config['action_dispatch.parameter_filter'], app.config.filter_parameters + assert_equal app.env_config['action_dispatch.secret_token'], app.config.secret_token + assert_equal app.env_config['action_dispatch.show_exceptions'], app.config.action_dispatch.show_exceptions + end end end diff --git a/railties/test/application/rake_test.rb b/railties/test/application/rake_test.rb index b61e2851bf..7671c129e9 100644 --- a/railties/test/application/rake_test.rb +++ b/railties/test/application/rake_test.rb @@ -61,22 +61,22 @@ module ApplicationTests def test_rake_test_error_output Dir.chdir(app_path){ `rake db:migrate` } - + app_file "config/database.yml", <<-RUBY development: RUBY - + app_file "test/unit/one_unit_test.rb", <<-RUBY RUBY - + app_file "test/functional/one_functional_test.rb", <<-RUBY raise RuntimeError RUBY - + app_file "test/integration/one_integration_test.rb", <<-RUBY raise RuntimeError RUBY - + silence_stderr do output = Dir.chdir(app_path){ `rake test` } assert_match /Errors running test:units! #<ActiveRecord::AdapterNotSpecified/, output @@ -151,5 +151,14 @@ module ApplicationTests assert_equal 2, ::AppTemplate::Application::Product.count assert_equal 0, ::AppTemplate::Application::User.count end + + def test_scaffold_tests_pass_by_default + content = Dir.chdir(app_path) do + `rails generate scaffold user username:string password:string` + `bundle exec rake db:migrate db:test:clone test` + end + + assert_match(/7 tests, 10 assertions, 0 failures, 0 errors/, content) + end end -end +end
\ No newline at end of file |