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') 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 090d12b49b80303ad521ce75b01ea89752417303 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 3 Jan 2010 21:32:02 -0500 Subject: Added that ActionController::Base now does helper :all instead of relying on the default ApplicationController in Rails to do it [DHH] --- .../rails/app/templates/app/controllers/application_controller.rb | 1 - 1 file changed, 1 deletion(-) (limited to 'railties') diff --git a/railties/lib/rails/generators/rails/app/templates/app/controllers/application_controller.rb b/railties/lib/rails/generators/rails/app/templates/app/controllers/application_controller.rb index 9889b52893..643a7ca16d 100644 --- a/railties/lib/rails/generators/rails/app/templates/app/controllers/application_controller.rb +++ b/railties/lib/rails/generators/rails/app/templates/app/controllers/application_controller.rb @@ -2,7 +2,6 @@ # Likewise, all the methods added will be available for all controllers. class ApplicationController < ActionController::Base - helper :all protect_from_forgery filter_parameter_logging :password end -- cgit v1.2.3 From 950e6bb4912bc87e693eab8731920a122bcff2c2 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 3 Jan 2010 21:32:40 -0500 Subject: Remove self-evident comment about how subclasses work --- .../rails/app/templates/app/controllers/application_controller.rb | 3 --- 1 file changed, 3 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/generators/rails/app/templates/app/controllers/application_controller.rb b/railties/lib/rails/generators/rails/app/templates/app/controllers/application_controller.rb index 643a7ca16d..2cdf4eae54 100644 --- a/railties/lib/rails/generators/rails/app/templates/app/controllers/application_controller.rb +++ b/railties/lib/rails/generators/rails/app/templates/app/controllers/application_controller.rb @@ -1,6 +1,3 @@ -# Filters added to this controller apply to all controllers in the application. -# Likewise, all the methods added will be available for all controllers. - class ApplicationController < ActionController::Base protect_from_forgery filter_parameter_logging :password -- cgit v1.2.3 From 51460b5bf296d7f262f8d865f6f6f1d44513c6d4 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 3 Jan 2010 21:34:19 -0500 Subject: This comment has been true of all helpers for a long time --- .../generators/rails/app/templates/app/helpers/application_helper.rb | 1 - 1 file changed, 1 deletion(-) (limited to 'railties') diff --git a/railties/lib/rails/generators/rails/app/templates/app/helpers/application_helper.rb b/railties/lib/rails/generators/rails/app/templates/app/helpers/application_helper.rb index 22a7940eb2..de6be7945c 100644 --- a/railties/lib/rails/generators/rails/app/templates/app/helpers/application_helper.rb +++ b/railties/lib/rails/generators/rails/app/templates/app/helpers/application_helper.rb @@ -1,3 +1,2 @@ -# Methods added to this helper will be available to all templates in the application. module ApplicationHelper end -- cgit v1.2.3 From 0422314b29e6b59362eb1111c983740784428b73 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 3 Jan 2010 21:55:48 -0500 Subject: Time zoning should be turned on by default with UTC --- railties/CHANGELOG | 2 ++ railties/lib/rails/application.rb | 18 ++++++++---------- railties/lib/rails/configuration.rb | 4 ++++ .../rails/app/templates/config/application.rb | 7 +++---- 4 files changed, 17 insertions(+), 14 deletions(-) (limited to 'railties') diff --git a/railties/CHANGELOG b/railties/CHANGELOG index 0bc1ea32bc..4e61479fb3 100644 --- a/railties/CHANGELOG +++ b/railties/CHANGELOG @@ -1,5 +1,7 @@ *Edge* +* Set config.time_zone to UTC by default [DHH] + * Added default .gitignore (this is just recognizing Git market share, don't throw a hissy if you use another SCM) [DHH] * Added cookies.permanent, cookies.signed, and cookies.permanent.signed accessor for common cookie actions [DHH]. Examples: diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index 457eef648c..5e68c05d7c 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -207,18 +207,16 @@ module Rails # Sets the default value for Time.zone # If assigned value cannot be matched to a TimeZone, an exception will be raised. initializer :initialize_time_zone do - if config.time_zone - require 'active_support/core_ext/time/zones' - zone_default = Time.__send__(:get_zone, config.time_zone) - - unless zone_default - raise \ - 'Value assigned to config.time_zone not recognized.' + - 'Run "rake -D time" for a list of tasks for finding appropriate time zone names.' - end + require 'active_support/core_ext/time/zones' + zone_default = Time.__send__(:get_zone, config.time_zone) - Time.zone_default = zone_default + unless zone_default + raise \ + 'Value assigned to config.time_zone not recognized.' + + 'Run "rake -D time" for a list of tasks for finding appropriate time zone names.' end + + Time.zone_default = zone_default end # Set the i18n configuration from config.i18n but special-case for the load_path which should be diff --git a/railties/lib/rails/configuration.rb b/railties/lib/rails/configuration.rb index f0a0d5e55e..7c1d549c9a 100644 --- a/railties/lib/rails/configuration.rb +++ b/railties/lib/rails/configuration.rb @@ -230,6 +230,10 @@ module Rails def log_level @log_level ||= RAILS_ENV == 'production' ? :info : :debug end + + def time_zone + @time_zone ||= "UTC" + end def i18n @i18n ||= begin diff --git a/railties/lib/rails/generators/rails/app/templates/config/application.rb b/railties/lib/rails/generators/rails/app/templates/config/application.rb index ec0729db04..b6c1cef8cd 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/application.rb +++ b/railties/lib/rails/generators/rails/app/templates/config/application.rb @@ -17,15 +17,14 @@ module <%= app_name.classify %> # config.active_record.observers = :cacher, :garbage_collector, :forum_observer # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. - # Run "rake -D time" for a list of tasks for finding time zone names. - config.time_zone = 'UTC' + # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. + # config.time_zone = 'Central Time (US & Canada)' # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')] # config.i18n.default_locale = :de - # Configure generators values. Many other options are available, be sure to - # check the documentation. + # Configure generators values. Many other options are available, be sure to check the documentation. # config.generators do |g| # g.orm :active_record # g.template_engine :erb -- cgit v1.2.3 From 6042067c0b20602e72954450e9e8a19dfa8a9f7d Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 3 Jan 2010 19:20:43 -0800 Subject: Changed the default ActiveSupport.use_standard_json_time_format from false to true and ActiveSupport.escape_html_entities_in_json from true to false to match previously announced Rails 3 defaults [DHH] --- .../app/templates/config/initializers/new_rails_defaults.rb | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/generators/rails/app/templates/config/initializers/new_rails_defaults.rb b/railties/lib/rails/generators/rails/app/templates/config/initializers/new_rails_defaults.rb index 8ec3186c84..91a8fdb688 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/initializers/new_rails_defaults.rb +++ b/railties/lib/rails/generators/rails/app/templates/config/initializers/new_rails_defaults.rb @@ -4,16 +4,6 @@ # for Rails 3. You can remove this initializer when Rails 3 is released. if defined?(ActiveRecord) - # Include Active Record class name as root for JSON serialized output. - ActiveRecord::Base.include_root_in_json = true - # Store the full class name (including module namespace) in STI type column. ActiveRecord::Base.store_full_sti_class = true -end - -# Use ISO 8601 format for JSON serialized times and dates. -ActiveSupport.use_standard_json_time_format = true - -# Don't escape HTML entities in JSON, leave that for the #json_escape helper. -# if you're including raw json in an HTML page. -ActiveSupport.escape_html_entities_in_json = false \ No newline at end of file +end \ No newline at end of file -- cgit v1.2.3 From 0ad07d9c26321f426d7d4c234d476e71d1537efb Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 3 Jan 2010 19:32:48 -0800 Subject: Removed config/initializers/new_rails_defaults.rb as all frameworks now follow the settings from it [DHH] --- railties/CHANGELOG | 2 ++ .../app/templates/config/initializers/new_rails_defaults.rb | 9 --------- 2 files changed, 2 insertions(+), 9 deletions(-) delete mode 100644 railties/lib/rails/generators/rails/app/templates/config/initializers/new_rails_defaults.rb (limited to 'railties') diff --git a/railties/CHANGELOG b/railties/CHANGELOG index 4e61479fb3..fc9277bd28 100644 --- a/railties/CHANGELOG +++ b/railties/CHANGELOG @@ -1,5 +1,7 @@ *Edge* +* Removed config/initializers/new_rails_defaults.rb as all frameworks now follow the settings from it [DHH] + * Set config.time_zone to UTC by default [DHH] * Added default .gitignore (this is just recognizing Git market share, don't throw a hissy if you use another SCM) [DHH] diff --git a/railties/lib/rails/generators/rails/app/templates/config/initializers/new_rails_defaults.rb b/railties/lib/rails/generators/rails/app/templates/config/initializers/new_rails_defaults.rb deleted file mode 100644 index 91a8fdb688..0000000000 --- a/railties/lib/rails/generators/rails/app/templates/config/initializers/new_rails_defaults.rb +++ /dev/null @@ -1,9 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# These settings change the behavior of Rails 2 apps and will be defaults -# for Rails 3. You can remove this initializer when Rails 3 is released. - -if defined?(ActiveRecord) - # Store the full class name (including module namespace) in STI type column. - ActiveRecord::Base.store_full_sti_class = true -end \ No newline at end of file -- cgit v1.2.3 From 437df4a8d3385bd28812cf6ca5662287d5246517 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 3 Jan 2010 19:46:10 -0800 Subject: Describe intent, not implementation --- railties/lib/rails/generators/rails/app/templates/config.ru | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/generators/rails/app/templates/config.ru b/railties/lib/rails/generators/rails/app/templates/config.ru index acb8435446..2ab821e38d 100644 --- a/railties/lib/rails/generators/rails/app/templates/config.ru +++ b/railties/lib/rails/generators/rails/app/templates/config.ru @@ -1,5 +1,4 @@ -# Require your environment file to bootstrap Rails -require ::File.expand_path('../config/environment', __FILE__) +# This file is used by Rack-based servers to start the application. -# Dispatch the request +require ::File.expand_path('../config/environment', __FILE__) run <%= app_const %>.instance -- cgit v1.2.3 From d7d917335e242f48fae31bc99e6d4ab381244913 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 3 Jan 2010 19:55:21 -0800 Subject: Stop featuring ActiveSupport::TestCase.use_instantiated_fixtures and ActiveSupport::TestCase.use_transactional_fixtures as likely-to-change settings in test/test_helper.rb -- they are not and their values are already set in test_help.rb [DHH] --- .../rails/app/templates/test/test_helper.rb | 25 ---------------------- 1 file changed, 25 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/generators/rails/app/templates/test/test_helper.rb b/railties/lib/rails/generators/rails/app/templates/test/test_helper.rb index a16f587d8b..45b551fc7d 100644 --- a/railties/lib/rails/generators/rails/app/templates/test/test_helper.rb +++ b/railties/lib/rails/generators/rails/app/templates/test/test_helper.rb @@ -3,31 +3,6 @@ require File.expand_path(File.dirname(__FILE__) + "/../config/environment") require 'rails/test_help' class ActiveSupport::TestCase - # Transactional fixtures accelerate your tests by wrapping each test method - # in a transaction that's rolled back on completion. This ensures that the - # test database remains unchanged so your fixtures don't have to be reloaded - # between every test method. Fewer database queries means faster tests. - # - # Read Mike Clark's excellent walkthrough at - # http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting - # - # Every Active Record database supports transactions except MyISAM tables - # in MySQL. Turn off transactional fixtures in this case; however, if you - # don't care one way or the other, switching from MyISAM to InnoDB tables - # is recommended. - # - # The only drawback to using transactional fixtures is when you actually - # need to test transactions. Since your test is bracketed by a transaction, - # any transactions started in your code will be automatically rolled back. - self.use_transactional_fixtures = true - - # Instantiated fixtures are slow, but give you @david where otherwise you - # would need people(:david). If you don't want to migrate your existing - # test cases which use the @david style and don't mind the speed hit (each - # instantiated fixtures translates to a database query per test method), - # then set this back to true. - self.use_instantiated_fixtures = false - # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order. # # Note: You'll currently still have to declare fixtures explicitly in integration tests -- 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/lib/rails/test_help.rb | 4 ---- railties/test/rails_info_controller_test.rb | 1 - 2 files changed, 5 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/test_help.rb b/railties/lib/rails/test_help.rb index 2601765065..696b65f8bf 100644 --- a/railties/lib/rails/test_help.rb +++ b/railties/lib/rails/test_help.rb @@ -8,10 +8,6 @@ require 'rack/test' require 'test/unit' require 'active_support/core_ext/kernel/requires' -# AP is always present -require 'action_controller/test_case' -require 'action_view/test_case' - require 'action_mailer/test_case' if defined?(ActionMailer) require 'active_model/test_case' if defined?(ActiveModel) 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 ce56c36cd392d6ab0505f0dc4df04c3ad2c074f1 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Mon, 4 Jan 2010 16:02:30 -0600 Subject: Autoload AM test case class --- railties/lib/rails/test_help.rb | 1 - 1 file changed, 1 deletion(-) (limited to 'railties') diff --git a/railties/lib/rails/test_help.rb b/railties/lib/rails/test_help.rb index 696b65f8bf..c1e7334ab8 100644 --- a/railties/lib/rails/test_help.rb +++ b/railties/lib/rails/test_help.rb @@ -8,7 +8,6 @@ require 'rack/test' require 'test/unit' require 'active_support/core_ext/kernel/requires' -require 'action_mailer/test_case' if defined?(ActionMailer) require 'active_model/test_case' if defined?(ActiveModel) if defined?(ActiveRecord) -- 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/lib/rails/console_app.rb | 1 - railties/lib/rails/generators/test_case.rb | 9 ++++----- .../rails/generators/test_unit/plugin/templates/test_helper.rb | 2 -- railties/test/abstract_unit.rb | 1 - 4 files changed, 4 insertions(+), 9 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/console_app.rb b/railties/lib/rails/console_app.rb index 2c4a7a51e8..902a621272 100644 --- a/railties/lib/rails/console_app.rb +++ b/railties/lib/rails/console_app.rb @@ -1,5 +1,4 @@ require 'active_support/all' -require 'active_support/test_case' require 'action_controller' # work around the at_exit hook in test/unit, which kills IRB diff --git a/railties/lib/rails/generators/test_case.rb b/railties/lib/rails/generators/test_case.rb index 643d7856c5..38a3cbb035 100644 --- a/railties/lib/rails/generators/test_case.rb +++ b/railties/lib/rails/generators/test_case.rb @@ -1,4 +1,3 @@ -require 'active_support/test_case' require 'active_support/core_ext/class/inheritable_attributes' require 'active_support/core_ext/hash/reverse_merge' require 'rails/generators' @@ -76,7 +75,7 @@ module Rails eval "$#{stream} = StringIO.new" yield result = eval("$#{stream}").string - ensure + ensure eval("$#{stream} = #{stream.upcase}") end @@ -137,9 +136,9 @@ module Rails # # assert_migration "db/migrate/create_products.rb" # - # This method manipulates the given path and tries to find any migration which + # This method manipulates the given path and tries to find any migration which # matches the migration name. For example, the call above is converted to: - # + # # assert_file "db/migrate/003_create_products.rb" # # Consequently, assert_migration accepts the same arguments has assert_file. @@ -236,4 +235,4 @@ module Rails end end end -end \ No newline at end of file +end diff --git a/railties/lib/rails/generators/test_unit/plugin/templates/test_helper.rb b/railties/lib/rails/generators/test_unit/plugin/templates/test_helper.rb index 348ec33582..2ca36a1e44 100644 --- a/railties/lib/rails/generators/test_unit/plugin/templates/test_helper.rb +++ b/railties/lib/rails/generators/test_unit/plugin/templates/test_helper.rb @@ -1,5 +1,3 @@ require 'rubygems' require 'test/unit' require 'active_support' -require 'active_support/test_case' - 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 640d9e7e32d9ad67cf81a686aad80266fee7fa61 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Mon, 4 Jan 2010 16:29:07 -0600 Subject: Autoload AMo test case --- railties/lib/rails/test_help.rb | 2 -- 1 file changed, 2 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/test_help.rb b/railties/lib/rails/test_help.rb index c1e7334ab8..e78bbaf825 100644 --- a/railties/lib/rails/test_help.rb +++ b/railties/lib/rails/test_help.rb @@ -8,8 +8,6 @@ require 'rack/test' require 'test/unit' require 'active_support/core_ext/kernel/requires' -require 'active_model/test_case' if defined?(ActiveModel) - if defined?(ActiveRecord) require 'active_record/test_case' require 'active_record/fixtures' -- cgit v1.2.3 From e5ed62deea3f281f9dafc8e7c9ae4354b5ad6a27 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Mon, 4 Jan 2010 16:50:01 -0600 Subject: Autoload AR test case --- railties/lib/rails/test_help.rb | 3 --- 1 file changed, 3 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/test_help.rb b/railties/lib/rails/test_help.rb index e78bbaf825..feaed50544 100644 --- a/railties/lib/rails/test_help.rb +++ b/railties/lib/rails/test_help.rb @@ -9,9 +9,6 @@ require 'test/unit' require 'active_support/core_ext/kernel/requires' if defined?(ActiveRecord) - require 'active_record/test_case' - require 'active_record/fixtures' - class ActiveSupport::TestCase include ActiveRecord::TestFixtures self.fixture_path = "#{Rails.root}/test/fixtures/" -- cgit v1.2.3 From 508ffccfe7e67315d82fa2947aa7989e6bfbebc9 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Mon, 4 Jan 2010 16:55:27 -0600 Subject: rack and rack-test are pulled in by AD --- railties/lib/rails/test_help.rb | 3 --- 1 file changed, 3 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/test_help.rb b/railties/lib/rails/test_help.rb index feaed50544..4308fc5b82 100644 --- a/railties/lib/rails/test_help.rb +++ b/railties/lib/rails/test_help.rb @@ -2,9 +2,6 @@ # so fixtures are loaded to the right database silence_warnings { RAILS_ENV = "test" } -require 'rack' -require 'rack/test' - require 'test/unit' require 'active_support/core_ext/kernel/requires' -- 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') 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 17f053931ea3bbf583f197d3318eece0b5a771d6 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Mon, 4 Jan 2010 17:23:36 -0600 Subject: use_instantiated_fixtures and use_transactional_fixtures defaults are set in active_record/fixtures --- railties/lib/rails/test_help.rb | 2 -- 1 file changed, 2 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/test_help.rb b/railties/lib/rails/test_help.rb index 4308fc5b82..e76c476bfb 100644 --- a/railties/lib/rails/test_help.rb +++ b/railties/lib/rails/test_help.rb @@ -9,8 +9,6 @@ if defined?(ActiveRecord) class ActiveSupport::TestCase include ActiveRecord::TestFixtures self.fixture_path = "#{Rails.root}/test/fixtures/" - self.use_instantiated_fixtures = false - self.use_transactional_fixtures = true end ActionController::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path -- cgit v1.2.3 From 952e449fc0b9adce240df6197a189d179f5e5b7f Mon Sep 17 00:00:00 2001 From: Carlhuda Date: Mon, 4 Jan 2010 16:32:43 -0800 Subject: Fix --dev option --- railties/lib/rails/generators/rails/app/templates/Gemfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/lib/rails/generators/rails/app/templates/Gemfile b/railties/lib/rails/generators/rails/app/templates/Gemfile index 59c6d333e2..7b5c89c3e2 100644 --- a/railties/lib/rails/generators/rails/app/templates/Gemfile +++ b/railties/lib/rails/generators/rails/app/templates/Gemfile @@ -5,7 +5,8 @@ gem "rails", "<%= Rails::VERSION::STRING %>" ## Bundle edge rails: <%- if options.dev? -%> -gem "rails", :path => "<%= Rails::Generators::RAILS_DEV_PATH %>" +directory "<%= Rails::Generators::RAILS_DEV_PATH %>", :glob => "{*/,}*.gemspec" +gem "rails", "<%= Rails::VERSION::STRING %>" <%- else -%> <%= "# " unless options.edge? %>gem "rails", :git => "git://github.com/rails/rails.git" <%- end -%> -- cgit v1.2.3 From 6591a10b1f6eccc91bc01ab708050884058e9665 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Mon, 4 Jan 2010 17:00:47 -0800 Subject: Reinstate explicit active_support/test_case require since console_app interacts with a non-autoloaded constant --- railties/lib/rails/console_app.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'railties') diff --git a/railties/lib/rails/console_app.rb b/railties/lib/rails/console_app.rb index 902a621272..2c4a7a51e8 100644 --- a/railties/lib/rails/console_app.rb +++ b/railties/lib/rails/console_app.rb @@ -1,4 +1,5 @@ require 'active_support/all' +require 'active_support/test_case' require 'action_controller' # work around the at_exit hook in test/unit, which kills IRB -- 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') 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/lib/rails/configuration.rb | 20 +++++++++++++++++--- railties/test/application/middleware_test.rb | 12 ++++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/configuration.rb b/railties/lib/rails/configuration.rb index 7c1d549c9a..7929cba2fe 100644 --- a/railties/lib/rails/configuration.rb +++ b/railties/lib/rails/configuration.rb @@ -4,11 +4,25 @@ module Rails # Temporarily separate the plugin configuration class from the main # configuration class while this bit is being cleaned up. class Railtie::Configuration - def self.default @default ||= new end + def self.default_middleware_stack + ActionDispatch::MiddlewareStack.new.tap do |middleware| + middleware.use('ActionDispatch::Static', lambda { Rails.public_path }, :if => lambda { Rails.application.config.serve_static_assets }) + middleware.use('::Rack::Lock', :if => lambda { !ActionController::Base.allow_concurrency }) + middleware.use('::Rack::Runtime') + middleware.use('ActionDispatch::ShowExceptions', lambda { ActionController::Base.consider_all_requests_local }) + middleware.use('ActionDispatch::Callbacks', lambda { ActionController::Dispatcher.prepare_each_request }) + middleware.use(lambda { ActionController::Base.session_store }, lambda { ActionController::Base.session_options }) + middleware.use('ActionDispatch::ParamsParser') + middleware.use('::Rack::MethodOverride') + middleware.use('::Rack::Head') + middleware.use('ActionDispatch::StringCoercion') + end + end + attr_reader :middleware def initialize(base = nil) @@ -17,7 +31,7 @@ module Rails @middleware = base.middleware.dup else @options = Hash.new { |h,k| h[k] = ActiveSupport::OrderedOptions.new } - @middleware = ActionDispatch::MiddlewareStack.new + @middleware = self.class.default_middleware_stack end end @@ -230,7 +244,7 @@ module Rails def log_level @log_level ||= RAILS_ENV == 'production' ? :info : :debug end - + def time_zone @time_zone ||= "UTC" end 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/lib/rails/configuration.rb | 1 - railties/test/application/middleware_test.rb | 1 - 2 files changed, 2 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/configuration.rb b/railties/lib/rails/configuration.rb index 7929cba2fe..e976c971f0 100644 --- a/railties/lib/rails/configuration.rb +++ b/railties/lib/rails/configuration.rb @@ -19,7 +19,6 @@ module Rails middleware.use('ActionDispatch::ParamsParser') middleware.use('::Rack::MethodOverride') middleware.use('::Rack::Head') - middleware.use('ActionDispatch::StringCoercion') end end 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 38f669766cb4d328e121afab020f4a52ca45421f Mon Sep 17 00:00:00 2001 From: Dan Croak Date: Tue, 5 Jan 2010 10:13:29 -0600 Subject: Rails layouts, error pages, and public/index now use HTML5. The specification allows the character encoding meta tag to be removed if character encoding is set at the transport level (Content-Type), which Rails is doing. http://dev.w3.org/html5/html4-differences/#character-encoding Signed-off-by: Joshua Peek --- railties/lib/rails/generators/erb/scaffold/templates/layout.html.erb | 1 - railties/lib/rails/generators/rails/app/templates/public/404.html | 1 - railties/lib/rails/generators/rails/app/templates/public/422.html | 1 - railties/lib/rails/generators/rails/app/templates/public/500.html | 1 - railties/lib/rails/generators/rails/app/templates/public/index.html | 1 - 5 files changed, 5 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/generators/erb/scaffold/templates/layout.html.erb b/railties/lib/rails/generators/erb/scaffold/templates/layout.html.erb index 51c4ad0e2e..7aa049fe80 100644 --- a/railties/lib/rails/generators/erb/scaffold/templates/layout.html.erb +++ b/railties/lib/rails/generators/erb/scaffold/templates/layout.html.erb @@ -1,7 +1,6 @@ - <%= controller_class_name %>: <%%= controller.action_name %> <%%= stylesheet_link_tag 'scaffold' %> diff --git a/railties/lib/rails/generators/rails/app/templates/public/404.html b/railties/lib/rails/generators/rails/app/templates/public/404.html index 88ee108e90..9a48320a5f 100644 --- a/railties/lib/rails/generators/rails/app/templates/public/404.html +++ b/railties/lib/rails/generators/rails/app/templates/public/404.html @@ -1,7 +1,6 @@ - The page you were looking for doesn't exist (404)