From b0947bf97c0ac313799f6f1ca739b5666f5fe19f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Mon, 4 Jan 2010 00:31:53 +0100 Subject: Bring generators tests back to life. --- railties/test/generators/generators_test_helper.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'railties/test') diff --git a/railties/test/generators/generators_test_helper.rb b/railties/test/generators/generators_test_helper.rb index fcd0989fd7..35567f7929 100644 --- a/railties/test/generators/generators_test_helper.rb +++ b/railties/test/generators/generators_test_helper.rb @@ -25,4 +25,8 @@ class GeneratorsTestCase < Rails::Generators::TestCase rescue # Do nothing. end + + def test_truth + # Don't cry test/unit + end end \ No newline at end of file -- cgit v1.2.3 From cf83a6f16b730f5536d4e11af894a04b24723212 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Mon, 4 Jan 2010 15:59:23 -0600 Subject: Autoload AC and AV test case classes --- railties/test/rails_info_controller_test.rb | 1 - 1 file changed, 1 deletion(-) (limited to 'railties/test') diff --git a/railties/test/rails_info_controller_test.rb b/railties/test/rails_info_controller_test.rb index 435bd34925..edab27465e 100644 --- a/railties/test/rails_info_controller_test.rb +++ b/railties/test/rails_info_controller_test.rb @@ -1,6 +1,5 @@ require 'abstract_unit' require 'action_controller' -require 'action_controller/test_case' require 'rails/info' require 'rails/info_controller' -- cgit v1.2.3 From 2601a16ede92566c651c06942294250ea653bd85 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Mon, 4 Jan 2010 16:22:39 -0600 Subject: Autoload AS test case --- railties/test/abstract_unit.rb | 1 - 1 file changed, 1 deletion(-) (limited to 'railties/test') diff --git a/railties/test/abstract_unit.rb b/railties/test/abstract_unit.rb index 2d6983076a..77ef82856a 100644 --- a/railties/test/abstract_unit.rb +++ b/railties/test/abstract_unit.rb @@ -17,7 +17,6 @@ require 'fileutils' require 'active_support' require 'active_support/core_ext/logger' -require 'active_support/test_case' require 'action_controller' require 'rails/all' -- cgit v1.2.3 From 947bbc170efc498499911d164eccd05db19a5c63 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Mon, 4 Jan 2010 17:13:45 -0600 Subject: Smoke test for test_help --- railties/test/application/test_test.rb | 38 ++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 railties/test/application/test_test.rb (limited to 'railties/test') diff --git a/railties/test/application/test_test.rb b/railties/test/application/test_test.rb new file mode 100644 index 0000000000..ff6df93ebc --- /dev/null +++ b/railties/test/application/test_test.rb @@ -0,0 +1,38 @@ +require 'isolation/abstract_unit' + +module ApplicationTests + class TestTest < Test::Unit::TestCase + include ActiveSupport::Testing::Isolation + + def setup + build_app + boot_rails + end + + test "truth" do + app_file 'test/unit/foo_test.rb', <<-RUBY + require 'test_helper' + + class FooTest < ActiveSupport::TestCase + def test_truth + assert true + end + end + RUBY + + run_test 'unit/foo_test.rb' + end + + private + def run_test(name) + result = ruby '-Itest', "#{app_path}/test/#{name}" + assert_equal 0, $?.to_i, result + end + + def ruby(*args) + Dir.chdir(app_path) do + `RUBYLIB='#{$:.join(':')}' #{Gem.ruby} #{args.join(' ')}` + end + end + end +end -- cgit v1.2.3 From 56b28ec8d6b226414fb240d4d4f6f1bd25292dc9 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Mon, 4 Jan 2010 19:34:42 -0600 Subject: Middleware configuration tests --- railties/test/application/middleware_test.rb | 67 ++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 railties/test/application/middleware_test.rb (limited to 'railties/test') diff --git a/railties/test/application/middleware_test.rb b/railties/test/application/middleware_test.rb new file mode 100644 index 0000000000..1b9c8c30fc --- /dev/null +++ b/railties/test/application/middleware_test.rb @@ -0,0 +1,67 @@ +require 'isolation/abstract_unit' + +module ApplicationTests + class MiddlewareTest < Test::Unit::TestCase + include ActiveSupport::Testing::Isolation + + def setup + build_app + boot_rails + FileUtils.rm_rf "#{app_path}/config/environments" + end + + test "default middleware stack" do + boot! + + assert_equal [ + "ActionDispatch::Static", + "Rack::Lock", + "Rack::Runtime", + "ActionDispatch::ShowExceptions", + "ActionDispatch::Callbacks", + "ActionDispatch::Session::CookieStore", + "ActionDispatch::ParamsParser", + "Rack::MethodOverride", + "Rack::Head", + "ActionDispatch::StringCoercion", + "ActiveRecord::ConnectionAdapters::ConnectionManagement", + "ActiveRecord::QueryCache" + ], middleware + end + + test "removing activerecord omits its middleware" do + use_frameworks [] + boot! + assert !middleware.include?("ActiveRecord::ConnectionAdapters::ConnectionManagement") + assert !middleware.include?("ActiveRecord::QueryCache") + end + + test "removes lock if allow concurrency is set" do + add_to_config "config.action_controller.allow_concurrency = true" + boot! + assert !middleware.include?("Rack::Lock") + end + + test "removes static asset server if serve_static_assets is disabled" do + add_to_config "config.serve_static_assets = false" + boot! + assert !middleware.include?("ActionDispatch::Static") + end + + test "use middleware" do + use_frameworks [] + add_to_config "config.middleware.use Rack::Config" + boot! + assert_equal "Rack::Config", middleware.last + end + + private + def boot! + require "#{app_path}/config/environment" + end + + def middleware + AppTemplate::Application.instance.middleware.active.map(&:klass).map(&:name) + end + end +end -- cgit v1.2.3 From 76b5f18feba3f1d0507b4c4ec34d11d9bb1c493c Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Mon, 4 Jan 2010 19:38:56 -0600 Subject: Default middleware stack needs to be available at configuration time --- railties/test/application/middleware_test.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'railties/test') diff --git a/railties/test/application/middleware_test.rb b/railties/test/application/middleware_test.rb index 1b9c8c30fc..df564011d3 100644 --- a/railties/test/application/middleware_test.rb +++ b/railties/test/application/middleware_test.rb @@ -55,6 +55,18 @@ module ApplicationTests assert_equal "Rack::Config", middleware.last end + test "insert middleware after" do + add_to_config "config.middleware.insert_after ActionDispatch::Static, Rack::Config" + boot! + assert_equal "Rack::Config", middleware.second + end + + test "insert middleware before" do + add_to_config "config.middleware.insert_before ActionDispatch::Static, Rack::Config" + boot! + assert_equal "Rack::Config", middleware.first + end + private def boot! require "#{app_path}/config/environment" -- cgit v1.2.3 From 3f28e0bda6386ed25d07182dd39b84f6a7d330da Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Mon, 4 Jan 2010 19:46:21 -0600 Subject: Trash string coercion rack hacks --- railties/test/application/middleware_test.rb | 1 - 1 file changed, 1 deletion(-) (limited to 'railties/test') diff --git a/railties/test/application/middleware_test.rb b/railties/test/application/middleware_test.rb index df564011d3..397968a4e7 100644 --- a/railties/test/application/middleware_test.rb +++ b/railties/test/application/middleware_test.rb @@ -23,7 +23,6 @@ module ApplicationTests "ActionDispatch::ParamsParser", "Rack::MethodOverride", "Rack::Head", - "ActionDispatch::StringCoercion", "ActiveRecord::ConnectionAdapters::ConnectionManagement", "ActiveRecord::QueryCache" ], middleware -- cgit v1.2.3 From 8ff4faf66a332b24d1a82a4e62daeabc06945dcf Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Tue, 5 Jan 2010 11:47:10 -0600 Subject: assert_template depends on AV::Template monkey patches in action_view/test_case --- railties/test/application/test_test.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'railties/test') diff --git a/railties/test/application/test_test.rb b/railties/test/application/test_test.rb index ff6df93ebc..37175783d8 100644 --- a/railties/test/application/test_test.rb +++ b/railties/test/application/test_test.rb @@ -23,6 +23,31 @@ module ApplicationTests run_test 'unit/foo_test.rb' end + test "integration test" do + controller 'posts', <<-RUBY + class PostsController < ActionController::Base + end + RUBY + + app_file 'app/views/posts/index.html.erb', <<-HTML + Posts#index + HTML + + app_file 'test/integration/posts_test.rb', <<-RUBY + require 'test_helper' + + class PostsTest < ActionController::IntegrationTest + def test_index + get '/posts' + assert_response :success + assert_template "index" + end + end + RUBY + + run_test 'integration/posts_test.rb' + end + private def run_test(name) result = ruby '-Itest', "#{app_path}/test/#{name}" -- cgit v1.2.3 From bbe80ae6525ec0c3da22b8d3a598af4126db1a57 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Tue, 5 Jan 2010 23:37:40 -0600 Subject: config.plugins should still work with an array of strings --- railties/test/plugins/vendored_test.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'railties/test') diff --git a/railties/test/plugins/vendored_test.rb b/railties/test/plugins/vendored_test.rb index 9a2d40cad8..b3b85891b2 100644 --- a/railties/test/plugins/vendored_test.rb +++ b/railties/test/plugins/vendored_test.rb @@ -191,5 +191,11 @@ module PluginsTest boot_rails assert_equal [:a, :c, :b], $arr end + + test "plugin order array is strings" do + add_to_config "config.plugins = %w( c_plugin all )" + boot_rails + assert_equal [:c, :a, :b], $arr + end end -end \ No newline at end of file +end -- cgit v1.2.3 From cfe0fcae0680418f0398c41ca262407bb1aa2a28 Mon Sep 17 00:00:00 2001 From: Jeffrey Hardy Date: Wed, 6 Jan 2010 14:22:51 -0500 Subject: Fix failing app generator test when using the --dev option --- railties/test/generators/app_generator_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/test') diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index 7dd798db75..27537f39b2 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -164,7 +164,7 @@ class AppGeneratorTest < GeneratorsTestCase def test_dev_option run_generator [destination_root, "--dev"] rails_path = File.expand_path('../../..', Rails.root) - dev_gem = %(gem "rails", :path => #{rails_path.inspect}) + dev_gem = %(directory #{rails_path.inspect}, :glob => "{*/,}*.gemspec") assert_file 'Gemfile', /^#{Regexp.escape(dev_gem)}$/ end -- cgit v1.2.3 From 19e7c524d2831726a51a973b0dc211725496e9d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Thu, 7 Jan 2010 20:59:26 +0100 Subject: Ensure config/application.rb also uses app_const instead of app_name.classify. --- railties/test/generators/app_generator_test.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'railties/test') diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index 27537f39b2..85081609de 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -61,7 +61,8 @@ class AppGeneratorTest < GeneratorsTestCase def test_invalid_application_name_is_fixed silence(:stdout){ Rails::Generators::AppGenerator.start [File.join(destination_root, "things-43")] } - assert_file "things-43/config/environment.rb", /Things43::Application/ + assert_file "things-43/config/environment.rb", /Things43::Application\.initialize!/ + assert_file "things-43/config/application.rb", /^module Things43$/ end def test_config_database_is_added_by_default -- cgit v1.2.3 From 8fe66f1af01a744751344b83a9952e0cd91a1692 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Thu, 7 Jan 2010 14:00:35 -0600 Subject: Run railtie and plugin initializers before app specific ones --- railties/test/application/initializer_test.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'railties/test') diff --git a/railties/test/application/initializer_test.rb b/railties/test/application/initializer_test.rb index 3fd0b0e5df..754c0f1839 100644 --- a/railties/test/application/initializer_test.rb +++ b/railties/test/application/initializer_test.rb @@ -83,6 +83,17 @@ module ApplicationTests assert_equal "congratulations", $test_after_initialize_block2 end + test "after_initialize runs after frameworks have been initialized" do + $activerecord_configurations = nil + add_to_config <<-RUBY + config.after_initialize { $activerecord_configurations = ActiveRecord::Base.configurations } + RUBY + + require "#{app_path}/config/environment" + assert $activerecord_configurations + assert $activerecord_configurations['development'] + end + # i18n test "setting another default locale" do add_to_config <<-RUBY -- cgit v1.2.3 From ccc9f0b7de02158a42e5f654cf00ed8b40e79781 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Thu, 7 Jan 2010 21:09:32 +0100 Subject: Ensure application names are not singularized. --- railties/test/generators/app_generator_test.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'railties/test') diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index 85081609de..3e3cd90bed 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -55,16 +55,21 @@ class AppGeneratorTest < GeneratorsTestCase end def test_invalid_application_name_raises_an_error - content = capture(:stderr){ Rails::Generators::AppGenerator.start [File.join(destination_root, "43-things")] } + content = capture(:stderr){ run_generator [File.join(destination_root, "43-things")] } assert_equal "Invalid application name 43-things. Please give a name which does not start with numbers.\n", content end def test_invalid_application_name_is_fixed - silence(:stdout){ Rails::Generators::AppGenerator.start [File.join(destination_root, "things-43")] } + run_generator [File.join(destination_root, "things-43")] assert_file "things-43/config/environment.rb", /Things43::Application\.initialize!/ assert_file "things-43/config/application.rb", /^module Things43$/ end + def test_application_names_are_not_singularized + run_generator [File.join(destination_root, "hats")] + assert_file "hats/config/environment.rb", /Hats::Application\.initialize!/ + end + def test_config_database_is_added_by_default run_generator assert_file "config/database.yml", /sqlite3/ -- cgit v1.2.3 From 8665c754cb61c947cd55f8886c28188050aed78d Mon Sep 17 00:00:00 2001 From: Yehuda Katz Date: Sat, 9 Jan 2010 11:01:54 -0600 Subject: Add a generator_paths config option --- railties/test/plugins/configuration_test.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'railties/test') diff --git a/railties/test/plugins/configuration_test.rb b/railties/test/plugins/configuration_test.rb index 25bf24eb3b..03c738971f 100644 --- a/railties/test/plugins/configuration_test.rb +++ b/railties/test/plugins/configuration_test.rb @@ -24,6 +24,12 @@ module PluginsTest assert_equal "hello", AppTemplate::Application.config.foo.greetings end + test "plugins can provide generators" do + class Foo < Rails::Railtie ; config.generator_paths << "/foo" ; end + require "#{app_path}/config/application" + assert_eqaul ["/foo"], AppTemplate::Application.config.generator_paths + end + test "plugin config merges are deep" do class Foo < Rails::Railtie ; config.foo.greetings = 'hello' ; end class MyApp < Rails::Application -- cgit v1.2.3 From 39215860912e4a29def2973b684d0830fc8b9904 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Sun, 10 Jan 2010 22:33:34 -0600 Subject: Rewrite Metal tests --- railties/test/application/metal_test.rb | 86 ++++++++++++++++++ .../metal/multiplemetals/app/metal/metal_a.rb | 5 - .../metal/multiplemetals/app/metal/metal_b.rb | 5 - .../metal/pluralmetal/app/metal/legacy_routes.rb | 5 - .../metal/singlemetal/app/metal/foo_metal.rb | 5 - .../metal/subfolders/app/metal/Folder/metal_a.rb | 7 -- .../metal/subfolders/app/metal/Folder/metal_b.rb | 7 -- railties/test/metal_test.rb | 101 --------------------- 8 files changed, 86 insertions(+), 135 deletions(-) create mode 100644 railties/test/application/metal_test.rb delete mode 100644 railties/test/fixtures/metal/multiplemetals/app/metal/metal_a.rb delete mode 100644 railties/test/fixtures/metal/multiplemetals/app/metal/metal_b.rb delete mode 100644 railties/test/fixtures/metal/pluralmetal/app/metal/legacy_routes.rb delete mode 100644 railties/test/fixtures/metal/singlemetal/app/metal/foo_metal.rb delete mode 100644 railties/test/fixtures/metal/subfolders/app/metal/Folder/metal_a.rb delete mode 100644 railties/test/fixtures/metal/subfolders/app/metal/Folder/metal_b.rb delete mode 100644 railties/test/metal_test.rb (limited to 'railties/test') diff --git a/railties/test/application/metal_test.rb b/railties/test/application/metal_test.rb new file mode 100644 index 0000000000..d3dfb79e8a --- /dev/null +++ b/railties/test/application/metal_test.rb @@ -0,0 +1,86 @@ +require 'isolation/abstract_unit' + +module ApplicationTests + class MetalTest < Test::Unit::TestCase + include ActiveSupport::Testing::Isolation + + def setup + build_app + boot_rails + + require 'rack/test' + extend Rack::Test::Methods + end + + def app + @app ||= begin + require "#{app_path}/config/environment" + Rails.application + end + end + + test "single metal endpoint" do + app_file 'app/metal/foo_metal.rb', <<-RUBY + class FooMetal + def self.call(env) + [200, { "Content-Type" => "text/html"}, ["FooMetal"]] + end + end + RUBY + + get "/" + assert_equal 200, last_response.status + assert_equal "FooMetal", last_response.body + end + + test "multiple metal endpoints" do + app_file 'app/metal/metal_a.rb', <<-RUBY + class MetalA + def self.call(env) + [404, { "Content-Type" => "text/html"}, ["Metal A"]] + end + end + RUBY + + app_file 'app/metal/metal_b.rb', <<-RUBY + class MetalB + def self.call(env) + [200, { "Content-Type" => "text/html"}, ["Metal B"]] + end + end + RUBY + + get "/" + assert_equal 200, last_response.status + assert_equal "Metal B", last_response.body + end + + test "pass through to application" do + app_file 'app/metal/foo_metal.rb', <<-RUBY + class FooMetal + def self.call(env) + [404, { "Content-Type" => "text/html"}, ["Not Found"]] + end + end + RUBY + + controller :foo, <<-RUBY + class FooController < ActionController::Base + def index + render :text => "foo" + end + end + RUBY + + app_file 'config/routes.rb', <<-RUBY + AppTemplate::Application.routes.draw do |map| + match ':controller(/:action)' + end + RUBY + + get "/foo" + assert_equal 200, last_response.status + assert_equal "foo", last_response.body + end + end +end diff --git a/railties/test/fixtures/metal/multiplemetals/app/metal/metal_a.rb b/railties/test/fixtures/metal/multiplemetals/app/metal/metal_a.rb deleted file mode 100644 index 4ca4ddd447..0000000000 --- a/railties/test/fixtures/metal/multiplemetals/app/metal/metal_a.rb +++ /dev/null @@ -1,5 +0,0 @@ -class MetalA - def self.call(env) - [404, { "Content-Type" => "text/html"}, ["Metal A"]] - end -end diff --git a/railties/test/fixtures/metal/multiplemetals/app/metal/metal_b.rb b/railties/test/fixtures/metal/multiplemetals/app/metal/metal_b.rb deleted file mode 100644 index 80e69fe0b0..0000000000 --- a/railties/test/fixtures/metal/multiplemetals/app/metal/metal_b.rb +++ /dev/null @@ -1,5 +0,0 @@ -class MetalB - def self.call(env) - [200, { "Content-Type" => "text/html"}, ["Metal B"]] - end -end diff --git a/railties/test/fixtures/metal/pluralmetal/app/metal/legacy_routes.rb b/railties/test/fixtures/metal/pluralmetal/app/metal/legacy_routes.rb deleted file mode 100644 index 0cd3737c32..0000000000 --- a/railties/test/fixtures/metal/pluralmetal/app/metal/legacy_routes.rb +++ /dev/null @@ -1,5 +0,0 @@ -class LegacyRoutes < Rails::Rack::Metal - def self.call(env) - [301, { "Location" => "http://example.com"}, []] - end -end diff --git a/railties/test/fixtures/metal/singlemetal/app/metal/foo_metal.rb b/railties/test/fixtures/metal/singlemetal/app/metal/foo_metal.rb deleted file mode 100644 index 5f5b087592..0000000000 --- a/railties/test/fixtures/metal/singlemetal/app/metal/foo_metal.rb +++ /dev/null @@ -1,5 +0,0 @@ -class FooMetal < Rails::Rack::Metal - def self.call(env) - [200, { "Content-Type" => "text/html"}, ["Hi"]] - end -end diff --git a/railties/test/fixtures/metal/subfolders/app/metal/Folder/metal_a.rb b/railties/test/fixtures/metal/subfolders/app/metal/Folder/metal_a.rb deleted file mode 100644 index 25b3bb0abc..0000000000 --- a/railties/test/fixtures/metal/subfolders/app/metal/Folder/metal_a.rb +++ /dev/null @@ -1,7 +0,0 @@ -module Folder - class MetalA < Rails::Rack::Metal - def self.call(env) - [200, { "Content-Type" => "text/html"}, ["Hi"]] - end - end -end diff --git a/railties/test/fixtures/metal/subfolders/app/metal/Folder/metal_b.rb b/railties/test/fixtures/metal/subfolders/app/metal/Folder/metal_b.rb deleted file mode 100644 index 7583363f71..0000000000 --- a/railties/test/fixtures/metal/subfolders/app/metal/Folder/metal_b.rb +++ /dev/null @@ -1,7 +0,0 @@ -module Folder - class MetalB < Rails::Rack::Metal - def self.call(env) - [200, { "Content-Type" => "text/html"}, ["Hi"]] - end - end -end diff --git a/railties/test/metal_test.rb b/railties/test/metal_test.rb deleted file mode 100644 index 91f55c2b5e..0000000000 --- a/railties/test/metal_test.rb +++ /dev/null @@ -1,101 +0,0 @@ -require 'abstract_unit' - -class MetalTest < Test::Unit::TestCase - def test_metals_should_return_list_of_found_metal_apps - use_appdir("singlemetal") do - assert_equal(["FooMetal"], found_metals_as_string_array) - end - end - - def test_metals_should_respect_class_name_conventions - use_appdir("pluralmetal") do - assert_equal(["LegacyRoutes"], found_metals_as_string_array) - end - end - - def test_metals_should_return_alphabetical_list_of_found_metal_apps - use_appdir("multiplemetals") do - assert_equal(["MetalA", "MetalB"], found_metals_as_string_array) - end - end - - def test_metals_load_order_should_be_overriden_by_requested_metals - use_appdir("multiplemetals") do - Rails::Rack::Metal.requested_metals = ["MetalB", "MetalA"] - assert_equal(["MetalB", "MetalA"], found_metals_as_string_array) - end - end - - def test_metals_not_listed_should_not_load - use_appdir("multiplemetals") do - Rails::Rack::Metal.requested_metals = ["MetalB"] - assert_equal(["MetalB"], found_metals_as_string_array) - end - end - - def test_metal_finding_should_work_with_subfolders - use_appdir("subfolders") do - assert_equal(["Folder::MetalA", "Folder::MetalB"], found_metals_as_string_array) - end - end - - def test_metal_finding_with_requested_metals_should_work_with_subfolders - use_appdir("subfolders") do - Rails::Rack::Metal.requested_metals = ["Folder::MetalB"] - assert_equal(["Folder::MetalB"], found_metals_as_string_array) - end - end - - def test_metal_finding_should_work_with_multiple_metal_paths_in_185_and_below - use_appdir("singlemetal") do - engine_metal_path = "#{File.dirname(__FILE__)}/fixtures/plugins/engines/engine/app/metal" - Rails::Rack::Metal.metal_paths << engine_metal_path - $LOAD_PATH << engine_metal_path - assert_equal(["FooMetal", "EngineMetal"], found_metals_as_string_array) - end - end - - def test_metal_default_pass_through_on_404 - use_appdir("multiplemetals") do - result = Rails::Rack::Metal.new(app).call({}) - assert_equal 200, result.first - assert_equal ["Metal B"], result.last - end - end - - def test_metal_pass_through_on_417 - use_appdir("multiplemetals") do - Rails::Rack::Metal.pass_through_on = 417 - result = Rails::Rack::Metal.new(app).call({}) - assert_equal 404, result.first - assert_equal ["Metal A"], result.last - end - end - - def test_metal_pass_through_on_404_and_200 - use_appdir("multiplemetals") do - Rails::Rack::Metal.pass_through_on = [404, 200] - result = Rails::Rack::Metal.new(app).call({}) - assert_equal 402, result.first - assert_equal ["End of the Line"], result.last - end - end - - private - - def app - lambda{|env|[402,{},["End of the Line"]]} - end - - def use_appdir(root) - dir = "#{File.dirname(__FILE__)}/fixtures/metal/#{root}" - Rails::Rack::Metal.metal_paths = ["#{dir}/app/metal"] - Rails::Rack::Metal.requested_metals = nil - $LOAD_PATH << "#{dir}/app/metal" - yield - end - - def found_metals_as_string_array - Rails::Rack::Metal.metals.map { |m| m.to_s } - end -end -- cgit v1.2.3 From 02bbde4e78f958d5495c19d953aaec58bb8ef998 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Sun, 10 Jan 2010 23:09:10 -0600 Subject: Cleanup junk metal and revise API API Change: Returning a "X-Cascade: pass" header triggers the cascade instead of a 404 response. --- railties/test/application/metal_test.rb | 4 ++-- railties/test/application/middleware_test.rb | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'railties/test') diff --git a/railties/test/application/metal_test.rb b/railties/test/application/metal_test.rb index d3dfb79e8a..225bede117 100644 --- a/railties/test/application/metal_test.rb +++ b/railties/test/application/metal_test.rb @@ -37,7 +37,7 @@ module ApplicationTests app_file 'app/metal/metal_a.rb', <<-RUBY class MetalA def self.call(env) - [404, { "Content-Type" => "text/html"}, ["Metal A"]] + [404, { "Content-Type" => "text/html", "X-Cascade" => "pass" }, ["Metal A"]] end end RUBY @@ -59,7 +59,7 @@ module ApplicationTests app_file 'app/metal/foo_metal.rb', <<-RUBY class FooMetal def self.call(env) - [404, { "Content-Type" => "text/html"}, ["Not Found"]] + [404, { "Content-Type" => "text/html", "X-Cascade" => "pass" }, ["Not Found"]] end end RUBY diff --git a/railties/test/application/middleware_test.rb b/railties/test/application/middleware_test.rb index 397968a4e7..8ba3a7bdfc 100644 --- a/railties/test/application/middleware_test.rb +++ b/railties/test/application/middleware_test.rb @@ -20,6 +20,7 @@ module ApplicationTests "ActionDispatch::ShowExceptions", "ActionDispatch::Callbacks", "ActionDispatch::Session::CookieStore", + "ActionDispatch::Cascade", "ActionDispatch::ParamsParser", "Rack::MethodOverride", "Rack::Head", -- cgit v1.2.3 From c4e3344a26dce5d2bc15e788c75140356a40537c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Tue, 12 Jan 2010 11:23:26 +0100 Subject: Revert "Add a generator_paths config option" This reverts commit 8665c754cb61c947cd55f8886c28188050aed78d. --- railties/test/plugins/configuration_test.rb | 6 ------ 1 file changed, 6 deletions(-) (limited to 'railties/test') diff --git a/railties/test/plugins/configuration_test.rb b/railties/test/plugins/configuration_test.rb index 03c738971f..25bf24eb3b 100644 --- a/railties/test/plugins/configuration_test.rb +++ b/railties/test/plugins/configuration_test.rb @@ -24,12 +24,6 @@ module PluginsTest assert_equal "hello", AppTemplate::Application.config.foo.greetings end - test "plugins can provide generators" do - class Foo < Rails::Railtie ; config.generator_paths << "/foo" ; end - require "#{app_path}/config/application" - assert_eqaul ["/foo"], AppTemplate::Application.config.generator_paths - end - test "plugin config merges are deep" do class Foo < Rails::Railtie ; config.foo.greetings = 'hello' ; end class MyApp < Rails::Application -- cgit v1.2.3 From 1e12dc04cbd819f90eb6be5d3192784ee64cb811 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Tue, 12 Jan 2010 12:52:57 +0100 Subject: Stub initial Rails::Subscriber implementation. --- railties/test/subscriber_test.rb | 102 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 railties/test/subscriber_test.rb (limited to 'railties/test') diff --git a/railties/test/subscriber_test.rb b/railties/test/subscriber_test.rb new file mode 100644 index 0000000000..ada40e2d2b --- /dev/null +++ b/railties/test/subscriber_test.rb @@ -0,0 +1,102 @@ +require 'abstract_unit' +require 'rails/subscriber' + +Thread.abort_on_exception = true + +class MockLogger + def initialize + @logged = Hash.new { |h,k| h[k] = [] } + end + + def method_missing(level, message) + @logged[level] << message + end + + def logged(level) + @logged[level].compact.map { |l| l.to_s.strip } + end +end + +ActiveSupport::Notifications.subscribe do |*args| + Rails::Subscriber.dispatch(args) +end + +class MySubscriber < Rails::Subscriber + def some_event(event) + info event.name + end + + def foo(event) + debug "debug" + info "info" + warn "warn" + end + + def bar(event) + info "#{color("cool", :red)}, #{color("isn't it?", :blue, true)}" + end +end + +class SubscriberTest < ActiveSupport::TestCase + def setup + @logger = MockLogger.new + @previous_logger, Rails.logger = Rails.logger, @logger + @subscriber = MySubscriber.new + wait + end + + def teardown + Rails.logger = @previous_logger + Rails::Subscriber.subscribers.clear + end + + def instrument(*args, &block) + ActiveSupport::Notifications.instrument(*args, &block) + end + + def wait + ActiveSupport::Notifications.notifier.wait + end + + def test_proxies_method_to_rails_logger + @subscriber.foo(nil) + assert_equal %w(debug), @logger.logged(:debug) + assert_equal %w(info), @logger.logged(:info) + assert_equal %w(warn), @logger.logged(:warn) + end + + def test_set_color_for_messages + @subscriber.bar(nil) + assert_equal "\e[31mcool\e[0m, \e[1m\e[34misn't it?\e[0m", @logger.logged(:info).last + end + + def test_does_not_set_color_if_colorize_logging_is_set_to_false + Rails::Subscriber.colorize_logging = false + @subscriber.bar(nil) + assert_equal "cool, isn't it?", @logger.logged(:info).last + ensure + Rails::Subscriber.colorize_logging = true + end + + def test_event_is_sent_to_the_registered_class + Rails::Subscriber.add :my_subscriber, @subscriber + instrument "my_subscriber.some_event" + wait + assert_equal %w(my_subscriber.some_event), @logger.logged(:info) + end + + def test_does_not_send_the_event_if_it_doesnt_match_the_class + Rails::Subscriber.add :my_subscriber, @subscriber + instrument "my_subscriber.unknown_event" + wait + # If we get here, it means that NoMethodError was raised. + end + + def test_does_not_send_the_event_if_logger_is_nil + Rails.logger = nil + Rails::Subscriber.add :my_subscriber, @subscriber + instrument "my_subscriber.some_event" + wait + assert_equal [], @logger.logged(:info) + end +end \ No newline at end of file -- cgit v1.2.3 From 9dd4c79d6148890f49949686e709cfb035755068 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Tue, 12 Jan 2010 13:27:24 +0100 Subject: Allow to add subscribers through Railtie. --- railties/test/plugins/configuration_test.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'railties/test') diff --git a/railties/test/plugins/configuration_test.rb b/railties/test/plugins/configuration_test.rb index 25bf24eb3b..09f8943af9 100644 --- a/railties/test/plugins/configuration_test.rb +++ b/railties/test/plugins/configuration_test.rb @@ -32,5 +32,14 @@ module PluginsTest assert_equal "hello", MyApp.config.foo.greetings assert_equal "bar", MyApp.config.foo.bar end + + test "plugin can add subscribers" do + begin + class Foo < Rails::Railtie; subscriber(Rails::Subscriber.new); end + assert_kind_of Rails::Subscriber, Rails::Subscriber.subscribers[:foo] + ensure + Rails::Subscriber.subscribers.clear + end + end end end -- cgit v1.2.3 From 1a275730b290c1f06d4e8df680d22ae1b41ab585 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Tue, 12 Jan 2010 14:11:47 +0100 Subject: Set deprecation warnings for RAILS_ENV and RAILS_DEFAULT_LOGGER. --- railties/test/generators/generators_test_helper.rb | 2 -- railties/test/initializer/path_test.rb | 8 ++++---- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'railties/test') diff --git a/railties/test/generators/generators_test_helper.rb b/railties/test/generators/generators_test_helper.rb index 35567f7929..54953b76c8 100644 --- a/railties/test/generators/generators_test_helper.rb +++ b/railties/test/generators/generators_test_helper.rb @@ -1,5 +1,3 @@ -# TODO: Fix this RAILS_ENV stuff -RAILS_ENV = 'test' unless defined?(RAILS_ENV) require 'abstract_unit' module Rails diff --git a/railties/test/initializer/path_test.rb b/railties/test/initializer/path_test.rb index bfb1887d11..328dda6d2c 100644 --- a/railties/test/initializer/path_test.rb +++ b/railties/test/initializer/path_test.rb @@ -63,7 +63,7 @@ module InitializerTests end test "environments has a glob equal to the current environment" do - assert_equal "#{RAILS_ENV}.rb", @paths.config.environments.glob + assert_equal "#{Rails.env}.rb", @paths.config.environments.glob end test "load path includes each of the paths in config.paths as long as the directories exist" do @@ -85,17 +85,17 @@ module InitializerTests end test "controller paths include builtin in development mode" do - RAILS_ENV.replace "development" + Rails.env.replace "development" assert Rails::Configuration.new.paths.app.controllers.paths.any? { |p| p =~ /builtin/ } end test "controller paths does not have builtin_directories in test mode" do - RAILS_ENV.replace "test" + Rails.env.replace "test" assert !Rails::Configuration.new.paths.app.controllers.paths.any? { |p| p =~ /builtin/ } end test "controller paths does not have builtin_directories in production mode" do - RAILS_ENV.replace "production" + Rails.env.replace "production" assert !Rails::Configuration.new.paths.app.controllers.paths.any? { |p| p =~ /builtin/ } end -- cgit v1.2.3 From fe3ceabeed6bde67eb9c0e64b27e133a66e13d83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Tue, 12 Jan 2010 17:48:09 +0100 Subject: Set up subscriber on initialization. --- railties/test/application/generators_test.rb | 2 +- railties/test/application/notifications_test.rb | 46 ++++++++++++++++++++++--- railties/test/subscriber_test.rb | 10 ++++++ 3 files changed, 52 insertions(+), 6 deletions(-) (limited to 'railties/test') diff --git a/railties/test/application/generators_test.rb b/railties/test/application/generators_test.rb index 0c858d6394..e1e51c318c 100644 --- a/railties/test/application/generators_test.rb +++ b/railties/test/application/generators_test.rb @@ -52,8 +52,8 @@ module ApplicationTests config.generators.test_framework :rspec RUBY - require "#{app_path}/config/environment" # Initialize the application + require "#{app_path}/config/environment" require "rails/generators" Rails::Generators.configure! diff --git a/railties/test/application/notifications_test.rb b/railties/test/application/notifications_test.rb index b57e829cca..1eb0777db8 100644 --- a/railties/test/application/notifications_test.rb +++ b/railties/test/application/notifications_test.rb @@ -12,28 +12,64 @@ module ApplicationTests end end + class MockLogger + def method_missing(*args) + @logged ||= [] + @logged << args.last + end + + def logged + @logged.compact.map { |l| l.to_s.strip } + end + end + class NotificationsTest < Test::Unit::TestCase include ActiveSupport::Testing::Isolation def setup build_app boot_rails + end + + def instrument(*args, &block) + ActiveSupport::Notifications.instrument(*args, &block) + end + + def wait + ActiveSupport::Notifications.notifier.wait + end + + test "new queue is set" do + # We don't want to load all frameworks, so remove them and clean up environments. + use_frameworks [] FileUtils.rm_rf("#{app_path}/config/environments") - require "active_support/notifications" - @events = [] add_to_config <<-RUBY config.notifications.notifier = ActiveSupport::Notifications::Notifier.new(ApplicationTests::MyQueue.new) RUBY - end - test "new queue is set" do - use_frameworks [] require "#{app_path}/config/environment" assert_raise RuntimeError do ActiveSupport::Notifications.publish('foo') end end + + test "rails subscribers are added" do + add_to_config <<-RUBY + config.colorize_logging = false + RUBY + + require "#{app_path}/config/environment" + + ActiveRecord::Base.logger = logger = MockLogger.new + + # Mimic an ActiveRecord notifications + instrument "active_record.sql", :name => "SQL", :sql => "SHOW tables" + wait + + assert_equal 1, logger.logged.size + assert_match /SHOW tables/, logger.logged.last + end end end diff --git a/railties/test/subscriber_test.rb b/railties/test/subscriber_test.rb index ada40e2d2b..0d8793abab 100644 --- a/railties/test/subscriber_test.rb +++ b/railties/test/subscriber_test.rb @@ -22,7 +22,10 @@ ActiveSupport::Notifications.subscribe do |*args| end class MySubscriber < Rails::Subscriber + attr_reader :event + def some_event(event) + @event = event info event.name end @@ -85,6 +88,13 @@ class SubscriberTest < ActiveSupport::TestCase assert_equal %w(my_subscriber.some_event), @logger.logged(:info) end + def test_event_is_an_active_support_notifications_event + Rails::Subscriber.add :my_subscriber, @subscriber + instrument "my_subscriber.some_event" + wait + assert_kind_of ActiveSupport::Notifications::Event, @subscriber.event + end + def test_does_not_send_the_event_if_it_doesnt_match_the_class Rails::Subscriber.add :my_subscriber, @subscriber instrument "my_subscriber.unknown_event" -- cgit v1.2.3 From 743cafb7f4a54d162a432c43974a5e5be55fd0b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Tue, 12 Jan 2010 20:00:53 +0100 Subject: Create Rails::Subscriber::TestHelper and use it to make ActiveRecord subscriber tests run in both sync and async scenarios. --- railties/test/subscriber_test.rb | 49 +++++++++++++--------------------------- 1 file changed, 16 insertions(+), 33 deletions(-) (limited to 'railties/test') diff --git a/railties/test/subscriber_test.rb b/railties/test/subscriber_test.rb index 0d8793abab..db953bb041 100644 --- a/railties/test/subscriber_test.rb +++ b/railties/test/subscriber_test.rb @@ -1,25 +1,5 @@ require 'abstract_unit' -require 'rails/subscriber' - -Thread.abort_on_exception = true - -class MockLogger - def initialize - @logged = Hash.new { |h,k| h[k] = [] } - end - - def method_missing(level, message) - @logged[level] << message - end - - def logged(level) - @logged[level].compact.map { |l| l.to_s.strip } - end -end - -ActiveSupport::Notifications.subscribe do |*args| - Rails::Subscriber.dispatch(args) -end +require 'rails/subscriber/test_helper' class MySubscriber < Rails::Subscriber attr_reader :event @@ -40,16 +20,14 @@ class MySubscriber < Rails::Subscriber end end -class SubscriberTest < ActiveSupport::TestCase +module SubscriberTest def setup - @logger = MockLogger.new - @previous_logger, Rails.logger = Rails.logger, @logger + super @subscriber = MySubscriber.new - wait end def teardown - Rails.logger = @previous_logger + super Rails::Subscriber.subscribers.clear end @@ -57,10 +35,6 @@ class SubscriberTest < ActiveSupport::TestCase ActiveSupport::Notifications.instrument(*args, &block) end - def wait - ActiveSupport::Notifications.notifier.wait - end - def test_proxies_method_to_rails_logger @subscriber.foo(nil) assert_equal %w(debug), @logger.logged(:debug) @@ -69,16 +43,14 @@ class SubscriberTest < ActiveSupport::TestCase end def test_set_color_for_messages + Rails::Subscriber.colorize_logging = true @subscriber.bar(nil) assert_equal "\e[31mcool\e[0m, \e[1m\e[34misn't it?\e[0m", @logger.logged(:info).last end def test_does_not_set_color_if_colorize_logging_is_set_to_false - Rails::Subscriber.colorize_logging = false @subscriber.bar(nil) assert_equal "cool, isn't it?", @logger.logged(:info).last - ensure - Rails::Subscriber.colorize_logging = true end def test_event_is_sent_to_the_registered_class @@ -109,4 +81,15 @@ class SubscriberTest < ActiveSupport::TestCase wait assert_equal [], @logger.logged(:info) end + + class SyncSubscriberTest < ActiveSupport::TestCase + include Rails::Subscriber::SyncTestHelper + include SubscriberTest + end + + class AsyncSubscriberTest < ActiveSupport::TestCase + include Rails::Subscriber::AsyncTestHelper + include SubscriberTest + end + end \ No newline at end of file -- cgit v1.2.3 From b4019d5080181a911f8652cabd184794963911b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Thu, 14 Jan 2010 22:03:47 +0100 Subject: Rails::Subscriber is now responsible for flushing all loggers it's responsible for. --- railties/test/subscriber_test.rb | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'railties/test') diff --git a/railties/test/subscriber_test.rb b/railties/test/subscriber_test.rb index db953bb041..7e91b7333f 100644 --- a/railties/test/subscriber_test.rb +++ b/railties/test/subscriber_test.rb @@ -76,10 +76,31 @@ module SubscriberTest def test_does_not_send_the_event_if_logger_is_nil Rails.logger = nil + @subscriber.expects(:some_event).never Rails::Subscriber.add :my_subscriber, @subscriber instrument "my_subscriber.some_event" wait - assert_equal [], @logger.logged(:info) + end + + def test_flushes_loggers + Rails::Subscriber.add :my_subscriber, @subscriber + Rails::Subscriber.flush_all! + assert_equal 1, @logger.flush_count + end + + def test_flushes_loggers_when_action_dispatch_callback_is_received + Rails::Subscriber.add :my_subscriber, @subscriber + instrument "action_dispatch.callback" + wait + assert_equal 1, @logger.flush_count + end + + def test_flushes_the_same_logger_just_once + Rails::Subscriber.add :my_subscriber, @subscriber + Rails::Subscriber.add :another, @subscriber + instrument "action_dispatch.callback" + wait + assert_equal 1, @logger.flush_count end class SyncSubscriberTest < ActiveSupport::TestCase -- cgit v1.2.3 From b0994be5bd24559f1362a636b46271de6d6a92d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Fri, 15 Jan 2010 10:46:30 +0100 Subject: LogTailer should be invoked after all logs in threads were flushed. --- railties/test/subscriber_test.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'railties/test') diff --git a/railties/test/subscriber_test.rb b/railties/test/subscriber_test.rb index 7e91b7333f..c45a68602d 100644 --- a/railties/test/subscriber_test.rb +++ b/railties/test/subscriber_test.rb @@ -24,11 +24,13 @@ module SubscriberTest def setup super @subscriber = MySubscriber.new + Rails::Subscriber.instance_variable_set(:@log_tailer, nil) end def teardown super Rails::Subscriber.subscribers.clear + Rails::Subscriber.instance_variable_set(:@log_tailer, nil) end def instrument(*args, &block) @@ -103,6 +105,19 @@ module SubscriberTest assert_equal 1, @logger.flush_count end + def test_tails_logs_when_action_dispatch_callback_is_received + log_tailer = mock() + log_tailer.expects(:tail!) + Rails::Rack::LogTailer.expects(:new).with(nil, "log/development.log").returns(log_tailer) + + Rails::Subscriber.tail_log = true + Rails::Subscriber.add :my_subscriber, @subscriber + instrument "action_dispatch.callback" + wait + ensure + Rails::Subscriber.tail_log = false + end + class SyncSubscriberTest < ActiveSupport::TestCase include Rails::Subscriber::SyncTestHelper include SubscriberTest -- cgit v1.2.3 From 6487d2871cbd44d769c483f47130e18d53e6e381 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Fri, 15 Jan 2010 12:15:49 +0100 Subject: Fix an issue where log was not being tailed in the first request. --- railties/test/subscriber_test.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'railties/test') diff --git a/railties/test/subscriber_test.rb b/railties/test/subscriber_test.rb index c45a68602d..ac34939510 100644 --- a/railties/test/subscriber_test.rb +++ b/railties/test/subscriber_test.rb @@ -108,14 +108,13 @@ module SubscriberTest def test_tails_logs_when_action_dispatch_callback_is_received log_tailer = mock() log_tailer.expects(:tail!) - Rails::Rack::LogTailer.expects(:new).with(nil, "log/development.log").returns(log_tailer) + Rails::Subscriber.log_tailer = log_tailer - Rails::Subscriber.tail_log = true Rails::Subscriber.add :my_subscriber, @subscriber instrument "action_dispatch.callback" wait ensure - Rails::Subscriber.tail_log = false + Rails::Subscriber.log_tailer = nil end class SyncSubscriberTest < ActiveSupport::TestCase -- cgit v1.2.3 From 5252f5c1c96001795d3e723ad8e48117e34c045b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Fri, 15 Jan 2010 13:39:56 +0100 Subject: Bundle automatically if --dev or --edge is given as option. --- railties/test/generators/app_generator_test.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'railties/test') diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index 3e3cd90bed..62ea07f14e 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -144,7 +144,7 @@ class AppGeneratorTest < GeneratorsTestCase template = %{ say "It works!" } template.instance_eval "def read; self; end" # Make the string respond to read - generator([destination_root], :template => path, :database => "sqlite3").expects(:open).with(path).returns(template) + generator([destination_root], :template => path).expects(:open).with(path).returns(template) assert_match /It works!/, silence(:stdout){ generator.invoke } end @@ -168,14 +168,16 @@ class AppGeneratorTest < GeneratorsTestCase end def test_dev_option - run_generator [destination_root, "--dev"] + generator([destination_root], :dev => true).expects(:run).with("gem bundle") + silence(:stdout){ generator.invoke } rails_path = File.expand_path('../../..', Rails.root) dev_gem = %(directory #{rails_path.inspect}, :glob => "{*/,}*.gemspec") assert_file 'Gemfile', /^#{Regexp.escape(dev_gem)}$/ end def test_edge_option - run_generator [destination_root, "--edge"] + generator([destination_root], :edge => true).expects(:run).with("gem bundle") + silence(:stdout){ generator.invoke } edge_gem = %(gem "rails", :git => "git://github.com/rails/rails.git") assert_file 'Gemfile', /^#{Regexp.escape(edge_gem)}$/ end -- cgit v1.2.3 From 3eaf525213ccef5c63c9e296fa643ad416a3f84c Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Fri, 15 Jan 2010 12:35:18 -0600 Subject: Make HEAD method masquerade as GET so requests are routed correctly --- railties/test/application/middleware_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/test') diff --git a/railties/test/application/middleware_test.rb b/railties/test/application/middleware_test.rb index 8ba3a7bdfc..c2b8db495f 100644 --- a/railties/test/application/middleware_test.rb +++ b/railties/test/application/middleware_test.rb @@ -23,7 +23,7 @@ module ApplicationTests "ActionDispatch::Cascade", "ActionDispatch::ParamsParser", "Rack::MethodOverride", - "Rack::Head", + "ActionDispatch::Head", "ActiveRecord::ConnectionAdapters::ConnectionManagement", "ActiveRecord::QueryCache" ], middleware -- cgit v1.2.3 From ead93c5be5b0f1945b7d0302f1aae4685ee3f2fb Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Fri, 15 Jan 2010 14:44:27 -0600 Subject: Move Flash into middleware --- railties/test/application/middleware_test.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'railties/test') diff --git a/railties/test/application/middleware_test.rb b/railties/test/application/middleware_test.rb index c2b8db495f..7b3077bb6e 100644 --- a/railties/test/application/middleware_test.rb +++ b/railties/test/application/middleware_test.rb @@ -20,6 +20,7 @@ module ApplicationTests "ActionDispatch::ShowExceptions", "ActionDispatch::Callbacks", "ActionDispatch::Session::CookieStore", + "ActionDispatch::Flash", "ActionDispatch::Cascade", "ActionDispatch::ParamsParser", "Rack::MethodOverride", -- cgit v1.2.3