aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test
diff options
context:
space:
mode:
Diffstat (limited to 'railties/test')
-rw-r--r--railties/test/application/assets_test.rb22
-rw-r--r--railties/test/application/configuration_test.rb11
-rw-r--r--railties/test/application/rake_test.rb21
-rw-r--r--railties/test/generators/plugin_new_generator_test.rb8
-rw-r--r--railties/test/railties/generators_test.rb5
-rw-r--r--railties/test/railties/shared_tests.rb9
6 files changed, 63 insertions, 13 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
diff --git a/railties/test/generators/plugin_new_generator_test.rb b/railties/test/generators/plugin_new_generator_test.rb
index be72391e58..4bd77ff7e3 100644
--- a/railties/test/generators/plugin_new_generator_test.rb
+++ b/railties/test/generators/plugin_new_generator_test.rb
@@ -159,6 +159,14 @@ class PluginNewGeneratorTest < Rails::Generators::TestCase
assert_match(/1 tests, 1 assertions, 0 failures, 0 errors/, `bundle exec rake test`)
end
+ def test_ensure_that_migration_tasks_work_with_mountable_option
+ run_generator [destination_root, "--mountable"]
+ FileUtils.cd destination_root
+ quietly { system 'bundle install' }
+ `bundle exec rake db:migrate`
+ assert_equal 0, $?.exitstatus
+ end
+
def test_creating_engine_in_full_mode
run_generator [destination_root, "--full"]
assert_file "app/assets/javascripts/bukkits"
diff --git a/railties/test/railties/generators_test.rb b/railties/test/railties/generators_test.rb
index fe59dcd52b..1d4ba0e5b6 100644
--- a/railties/test/railties/generators_test.rb
+++ b/railties/test/railties/generators_test.rb
@@ -1,7 +1,8 @@
RAILS_ISOLATED_ENGINE = true
require "isolation/abstract_unit"
-require "#{RAILS_FRAMEWORK_ROOT}/railties/lib/rails/generators/test_case"
+require 'generators/generators_test_helper'
+require "rails/generators/test_case"
module RailtiesTests
class GeneratorTest < Rails::Generators::TestCase
@@ -31,8 +32,8 @@ module RailtiesTests
end
def build_engine(is_mountable=false)
+ FileUtils.rm_rf(engine_path)
FileUtils.mkdir_p(engine_path)
- FileUtils.rm_r(engine_path)
mountable = is_mountable ? "--mountable" : ""
diff --git a/railties/test/railties/shared_tests.rb b/railties/test/railties/shared_tests.rb
index 8cbc76db71..9a64b7c64e 100644
--- a/railties/test/railties/shared_tests.rb
+++ b/railties/test/railties/shared_tests.rb
@@ -84,6 +84,15 @@ module RailtiesTest
end
end
+ def test_no_rake_task_without_migrations
+ boot_rails
+ require 'rake'
+ require 'rdoc/task'
+ require 'rake/testtask'
+ Rails.application.load_tasks
+ assert !Rake::Task.task_defined?('bukkits:install:migrations')
+ end
+
def test_puts_its_lib_directory_on_load_path
boot_rails
require "another"