From eec2d301d4ce9df9c71c1a5aa63053eb970b6818 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Mon, 15 Feb 2010 10:20:11 -0600 Subject: [PATCH 1/7] Fix test load paths for those not using bundler --- actionmailer/test/abstract_unit.rb | 7 +++++-- actionmailer/test/subscriber_test.rb | 3 +++ actionpack/test/abstract_unit.rb | 8 ++++++- .../activerecord/controller_runtime_test.rb | 9 +++++--- actionpack/test/controller/subscriber_test.rb | 3 +++ actionpack/test/template/subscriber_test.rb | 5 ++++- activemodel/Rakefile | 2 +- activemodel/test/cases/helper.rb | 7 ++++++- activemodel/test/cases/tests_database.rb | 4 +++- activerecord/lib/active_record.rb | 1 - activerecord/test/cases/helper.rb | 5 ++++- activerecord/test/cases/subscriber_test.rb | 5 ++++- activeresource/test/abstract_unit.rb | 6 ++++-- activeresource/test/cases/subscriber_test.rb | 6 +++++- activesupport/test/abstract_unit.rb | 5 ++++- bundler.rb | 10 +++++++++ load_paths.rb | 21 ------------------- railties/Rakefile | 2 +- railties/test/abstract_unit.rb | 7 ++++++- .../test/application/configuration_test.rb | 2 +- railties/test/edge_rails.rb | 14 +++++++++++++ railties/test/isolation/abstract_unit.rb | 14 ++++--------- 22 files changed, 95 insertions(+), 51 deletions(-) create mode 100644 bundler.rb delete mode 100644 load_paths.rb create mode 100644 railties/test/edge_rails.rb diff --git a/actionmailer/test/abstract_unit.rb b/actionmailer/test/abstract_unit.rb index f6baa4a9e8..9d3c9086c9 100644 --- a/actionmailer/test/abstract_unit.rb +++ b/actionmailer/test/abstract_unit.rb @@ -1,4 +1,7 @@ -require File.expand_path('../../../load_paths', __FILE__) +require File.expand_path('../../../bundler', __FILE__) + +lib = File.expand_path("#{File.dirname(__FILE__)}/../lib") +$:.unshift(lib) unless $:.include?('lib') || $:.include?(lib) require 'test/unit' require 'action_mailer' @@ -14,7 +17,7 @@ ActionView::Template.register_template_handler :bak, lambda { |template| "Lame b FIXTURE_LOAD_PATH = File.expand_path('fixtures', File.dirname(__FILE__)) ActionMailer::Base.view_paths = FIXTURE_LOAD_PATH -class MockSMTP +class MockSMTP def self.deliveries @@deliveries end diff --git a/actionmailer/test/subscriber_test.rb b/actionmailer/test/subscriber_test.rb index 3d1736d64f..88a5d2ca34 100644 --- a/actionmailer/test/subscriber_test.rb +++ b/actionmailer/test/subscriber_test.rb @@ -1,3 +1,6 @@ +railties_path = File.expand_path('../../../railties/lib', __FILE__) +$:.unshift(railties_path) if File.directory?(railties_path) && !$:.include?(railties_path) + require "abstract_unit" require "rails/subscriber/test_helper" require "action_mailer/railties/subscriber" diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb index 867e50d5b9..655a133c96 100644 --- a/actionpack/test/abstract_unit.rb +++ b/actionpack/test/abstract_unit.rb @@ -1,4 +1,10 @@ -require File.expand_path('../../../load_paths', __FILE__) +require File.expand_path('../../../bundler', __FILE__) + +lib = File.expand_path("#{File.dirname(__FILE__)}/../lib") +$:.unshift(lib) unless $:.include?('lib') || $:.include?(lib) + +activemodel_path = File.expand_path('../../../activemodel/lib', __FILE__) +$:.unshift(activemodel_path) if File.directory?(activemodel_path) && !$:.include?(activemodel_path) $:.unshift(File.dirname(__FILE__) + '/lib') $:.unshift(File.dirname(__FILE__) + '/fixtures/helpers') diff --git a/actionpack/test/activerecord/controller_runtime_test.rb b/actionpack/test/activerecord/controller_runtime_test.rb index ed8e324938..f044e714d8 100644 --- a/actionpack/test/activerecord/controller_runtime_test.rb +++ b/actionpack/test/activerecord/controller_runtime_test.rb @@ -1,3 +1,6 @@ +railties_path = File.expand_path('../../../../railties/lib', __FILE__) +$:.unshift(railties_path) if File.directory?(railties_path) && !$:.include?(railties_path) + require 'active_record_unit' require 'active_record/railties/controller_runtime' require 'fixtures/project' @@ -12,7 +15,7 @@ class ControllerRuntimeSubscriberTest < ActionController::TestCase render :inline => "<%= Project.all %>" end end - + include Rails::Subscriber::TestHelper tests SubscriberController @@ -31,7 +34,7 @@ class ControllerRuntimeSubscriberTest < ActionController::TestCase def set_logger(logger) ActionController::Base.logger = logger end - + def test_log_with_active_record get :show wait @@ -39,4 +42,4 @@ class ControllerRuntimeSubscriberTest < ActionController::TestCase assert_equal 2, @logger.logged(:info).size assert_match /\(Views: [\d\.]+ms | ActiveRecord: [\d\.]+ms\)/, @logger.logged(:info)[1] end -end \ No newline at end of file +end diff --git a/actionpack/test/controller/subscriber_test.rb b/actionpack/test/controller/subscriber_test.rb index d7c1166f14..72368df93b 100644 --- a/actionpack/test/controller/subscriber_test.rb +++ b/actionpack/test/controller/subscriber_test.rb @@ -1,3 +1,6 @@ +railties_path = File.expand_path('../../../../railties/lib', __FILE__) +$:.unshift(railties_path) if File.directory?(railties_path) && !$:.include?(railties_path) + require "abstract_unit" require "rails/subscriber/test_helper" require "action_controller/railties/subscriber" diff --git a/actionpack/test/template/subscriber_test.rb b/actionpack/test/template/subscriber_test.rb index 8bacab7088..8470f3c931 100644 --- a/actionpack/test/template/subscriber_test.rb +++ b/actionpack/test/template/subscriber_test.rb @@ -1,3 +1,6 @@ +railties_path = File.expand_path('../../../../railties/lib', __FILE__) +$:.unshift(railties_path) if File.directory?(railties_path) && !$:.include?(railties_path) + require "abstract_unit" require "rails/subscriber/test_helper" require "action_view/railties/subscriber" @@ -90,4 +93,4 @@ class AVSubscriberTest < ActiveSupport::TestCase assert_equal 1, @logger.logged(:info).size assert_match /Rendered collection/, @logger.logged(:info).last end -end \ No newline at end of file +end diff --git a/activemodel/Rakefile b/activemodel/Rakefile index 14c02f183f..556ea2ec0b 100755 --- a/activemodel/Rakefile +++ b/activemodel/Rakefile @@ -13,7 +13,7 @@ require 'rake/testtask' task :default => :test Rake::TestTask.new do |t| - t.libs << "#{dir}/test" + t.libs << "test" t.test_files = Dir.glob("#{dir}/test/cases/**/*_test.rb").sort t.warning = true end diff --git a/activemodel/test/cases/helper.rb b/activemodel/test/cases/helper.rb index 8bcbe54651..8b1ab9e196 100644 --- a/activemodel/test/cases/helper.rb +++ b/activemodel/test/cases/helper.rb @@ -1,4 +1,9 @@ -require File.expand_path('../../../../load_paths', __FILE__) +require File.expand_path('../../../../bundler', __FILE__) + +lib = File.expand_path("#{File.dirname(__FILE__)}/../../lib") +$:.unshift(lib) unless $:.include?('lib') || $:.include?(lib) + +puts $LOAD_PATH.inspect require 'config' require 'active_model' diff --git a/activemodel/test/cases/tests_database.rb b/activemodel/test/cases/tests_database.rb index 8ca54d2678..4a392f609f 100644 --- a/activemodel/test/cases/tests_database.rb +++ b/activemodel/test/cases/tests_database.rb @@ -1,6 +1,8 @@ require 'logger' -$:.unshift(File.dirname(__FILE__) + '/../../../activerecord/lib') +activerecord_path = File.expand_path('../../../../activerecord/lib', __FILE__) +$:.unshift(activerecord_path) if File.directory?(activerecord_path) && !$:.include?(activerecord_path) + require 'active_record' module ActiveModel diff --git a/activerecord/lib/active_record.rb b/activerecord/lib/active_record.rb index b79da4565d..99ff0a19a5 100644 --- a/activerecord/lib/active_record.rb +++ b/activerecord/lib/active_record.rb @@ -21,7 +21,6 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #++ - activesupport_path = File.expand_path('../../../activesupport/lib', __FILE__) $:.unshift(activesupport_path) if File.directory?(activesupport_path) && !$:.include?(activesupport_path) diff --git a/activerecord/test/cases/helper.rb b/activerecord/test/cases/helper.rb index 9e8bfbbee8..3254e7d800 100644 --- a/activerecord/test/cases/helper.rb +++ b/activerecord/test/cases/helper.rb @@ -1,4 +1,7 @@ -require File.expand_path('../../../../load_paths', __FILE__) +require File.expand_path('../../../../bundler', __FILE__) + +lib = File.expand_path("#{File.dirname(__FILE__)}/../../lib") +$:.unshift(lib) unless $:.include?('lib') || $:.include?(lib) require 'config' diff --git a/activerecord/test/cases/subscriber_test.rb b/activerecord/test/cases/subscriber_test.rb index 5328d4468b..3d7a8f5bab 100644 --- a/activerecord/test/cases/subscriber_test.rb +++ b/activerecord/test/cases/subscriber_test.rb @@ -1,3 +1,6 @@ +railties_path = File.expand_path('../../../../railties/lib', __FILE__) +$:.unshift(railties_path) if File.directory?(railties_path) && !$:.include?(railties_path) + require "cases/helper" require "models/developer" require "rails/subscriber/test_helper" @@ -39,4 +42,4 @@ class SubscriberTest < ActiveSupport::TestCase assert_match /CACHE/, @logger.logged(:debug).last assert_match /SELECT .*?FROM .?developers.?/, @logger.logged(:debug).last end -end \ No newline at end of file +end diff --git a/activeresource/test/abstract_unit.rb b/activeresource/test/abstract_unit.rb index 1af535e811..1c6f92cba4 100644 --- a/activeresource/test/abstract_unit.rb +++ b/activeresource/test/abstract_unit.rb @@ -1,4 +1,7 @@ -require File.expand_path('../../../load_paths', __FILE__) +require File.expand_path('../../../bundler', __FILE__) + +lib = File.expand_path("#{File.dirname(__FILE__)}/../lib") +$:.unshift(lib) unless $:.include?('lib') || $:.include?(lib) require 'rubygems' require 'test/unit' @@ -6,7 +9,6 @@ require 'active_resource' require 'active_support' require 'active_support/test_case' -$:.unshift "#{File.dirname(__FILE__)}/../test" require 'setter_trap' require 'logger' diff --git a/activeresource/test/cases/subscriber_test.rb b/activeresource/test/cases/subscriber_test.rb index fb890e86cb..c673a0551a 100644 --- a/activeresource/test/cases/subscriber_test.rb +++ b/activeresource/test/cases/subscriber_test.rb @@ -1,9 +1,13 @@ +railties_path = File.expand_path('../../../../railties/lib', __FILE__) +$:.unshift(railties_path) if File.directory?(railties_path) && !$:.include?(railties_path) + require "abstract_unit" require "fixtures/person" require "rails/subscriber/test_helper" require "active_resource/railties/subscriber" require "active_support/core_ext/hash/conversions" +# TODO: This test should be part of Railties class SubscriberTest < ActiveSupport::TestCase include Rails::Subscriber::TestHelper Rails::Subscriber.add(:active_resource, ActiveResource::Railties::Subscriber.new) @@ -28,4 +32,4 @@ class SubscriberTest < ActiveSupport::TestCase assert_equal "GET http://37s.sunrise.i:3000/people/1.xml", @logger.logged(:info)[0] assert_match /\-\-\> 200 200 106/, @logger.logged(:info)[1] end -end \ No newline at end of file +end diff --git a/activesupport/test/abstract_unit.rb b/activesupport/test/abstract_unit.rb index 33be6f65bf..c4ef102bf0 100644 --- a/activesupport/test/abstract_unit.rb +++ b/activesupport/test/abstract_unit.rb @@ -1,4 +1,7 @@ -require File.expand_path('../../../load_paths', __FILE__) +require File.expand_path('../../../bundler', __FILE__) + +lib = File.expand_path("#{File.dirname(__FILE__)}/../lib") +$:.unshift(lib) unless $:.include?('lib') || $:.include?(lib) require 'test/unit' require 'mocha' diff --git a/bundler.rb b/bundler.rb new file mode 100644 index 0000000000..dcc8ed61f1 --- /dev/null +++ b/bundler.rb @@ -0,0 +1,10 @@ +begin + require File.expand_path('../.bundle/environment', __FILE__) +rescue LoadError + begin + require 'rubygems' + require 'bundler' + Bundler.setup + rescue LoadError + end +end diff --git a/load_paths.rb b/load_paths.rb deleted file mode 100644 index d5f2ca0734..0000000000 --- a/load_paths.rb +++ /dev/null @@ -1,21 +0,0 @@ -begin - require File.expand_path('../.bundle/environment', __FILE__) -rescue LoadError - begin - require 'rubygems' - require 'bundler' - Bundler.setup - rescue LoadError - %w( - actionmailer - actionpack - activemodel - activerecord - activeresource - activesupport - railties - ).each do |framework| - $:.unshift File.expand_path("../#{framework}/lib", __FILE__) - end - end -end diff --git a/railties/Rakefile b/railties/Rakefile index f32a794544..d4b446bc24 100644 --- a/railties/Rakefile +++ b/railties/Rakefile @@ -1,4 +1,4 @@ -require File.expand_path('../../load_paths', __FILE__) +require File.expand_path('../../bundler', __FILE__) require 'rake' require 'rake/testtask' diff --git a/railties/test/abstract_unit.rb b/railties/test/abstract_unit.rb index aa66dbb9be..2ac165fc49 100644 --- a/railties/test/abstract_unit.rb +++ b/railties/test/abstract_unit.rb @@ -1,8 +1,13 @@ ORIG_ARGV = ARGV.dup -require File.expand_path("../../../load_paths", __FILE__) +require File.expand_path("../../../bundler", __FILE__) $:.unshift File.expand_path("../../builtin/rails_info", __FILE__) +lib = File.expand_path("#{File.dirname(__FILE__)}/../lib") +$:.unshift(lib) unless $:.include?('lib') || $:.include?(lib) + +require 'edge_rails' + require 'stringio' require 'test/unit' require 'fileutils' diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index 56f45582c8..7ca605ec23 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -140,7 +140,7 @@ module ApplicationTests require "#{app_path}/config/environment" end end - + test "filter_parameters should be able to set via config.filter_parameters" do add_to_config <<-RUBY config.filter_parameters += [ :foo, 'bar', lambda { |key, value| diff --git a/railties/test/edge_rails.rb b/railties/test/edge_rails.rb new file mode 100644 index 0000000000..bd8a674738 --- /dev/null +++ b/railties/test/edge_rails.rb @@ -0,0 +1,14 @@ +require File.expand_path('../../../bundler', __FILE__) + +%w( + actionmailer + actionpack + activemodel + activerecord + activeresource + activesupport + railties +).each do |framework| + framework_path = File.expand_path("../../../#{framework}/lib", __FILE__) + $:.unshift(framework_path) if File.directory?(framework_path) && !$:.include?(framework_path) +end diff --git a/railties/test/isolation/abstract_unit.rb b/railties/test/isolation/abstract_unit.rb index 364dbd8e55..f3c1d64f7b 100644 --- a/railties/test/isolation/abstract_unit.rb +++ b/railties/test/isolation/abstract_unit.rb @@ -187,7 +187,7 @@ module TestHelpers end def boot_rails - require File.expand_path('../../../../load_paths', __FILE__) + require File.expand_path('../../edge_rails', __FILE__) end end end @@ -208,18 +208,12 @@ Module.new do end FileUtils.mkdir(tmp_path) - environment = File.expand_path('../../../../load_paths', __FILE__) - if File.exist?("#{environment}.rb") - require_environment = "-r #{environment}" - end + environment = File.expand_path('../../edge_rails', __FILE__) + require_environment = "-r #{environment}" `#{Gem.ruby} #{require_environment} #{RAILS_FRAMEWORK_ROOT}/railties/bin/rails #{tmp_path('app_template')}` File.open("#{tmp_path}/app_template/config/boot.rb", 'w') do |f| - if require_environment - f.puts "Dir.chdir('#{File.dirname(environment)}') do" - f.puts " require '#{environment}'" - f.puts "end" - end + f.puts "require '#{environment}'" f.puts "require 'rails/all'" end end From 4419497e403387a3cc93c4c1a3b6a07314a85e43 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Mon, 15 Feb 2010 10:38:39 -0600 Subject: [PATCH 2/7] Make sure AS test env doesn't have duplicate libs in load path --- activesupport/test/callback_inheritance_test.rb | 1 - activesupport/test/callbacks_test.rb | 1 - activesupport/test/load_paths_test.rb | 14 ++++++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 activesupport/test/load_paths_test.rb diff --git a/activesupport/test/callback_inheritance_test.rb b/activesupport/test/callback_inheritance_test.rb index 2e978f01be..e74c64ba8d 100644 --- a/activesupport/test/callback_inheritance_test.rb +++ b/activesupport/test/callback_inheritance_test.rb @@ -1,5 +1,4 @@ require 'test/unit' -$:.unshift "#{File.dirname(__FILE__)}/../lib" require 'active_support' class GrandParent diff --git a/activesupport/test/callbacks_test.rb b/activesupport/test/callbacks_test.rb index 11494e951e..3fb940ad3c 100644 --- a/activesupport/test/callbacks_test.rb +++ b/activesupport/test/callbacks_test.rb @@ -1,6 +1,5 @@ # require 'abstract_unit' require 'test/unit' -$:.unshift "#{File.dirname(__FILE__)}/../lib" require 'active_support' module CallbacksTest diff --git a/activesupport/test/load_paths_test.rb b/activesupport/test/load_paths_test.rb new file mode 100644 index 0000000000..683ba3dd4e --- /dev/null +++ b/activesupport/test/load_paths_test.rb @@ -0,0 +1,14 @@ +require 'abstract_unit' + +class LoadPathsTest < Test::Unit::TestCase + def test_uniq_load_paths + load_paths_count = $LOAD_PATH.inject({}) { |paths, path| + expanded_path = File.expand_path(path) + paths[expanded_path] ||= 0 + paths[expanded_path] += 1 + paths + } + + assert_equal [], load_paths_count.select { |k, v| v > 1 }, $LOAD_PATH.inspect + end +end From 546e319a5fd1d3a21d6e11dced2379e55a633f1d Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Mon, 15 Feb 2010 10:53:44 -0600 Subject: [PATCH 3/7] CI has a bunch of duplicate load paths --- activesupport/test/load_paths_test.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/activesupport/test/load_paths_test.rb b/activesupport/test/load_paths_test.rb index 683ba3dd4e..9c83d6f061 100644 --- a/activesupport/test/load_paths_test.rb +++ b/activesupport/test/load_paths_test.rb @@ -9,6 +9,7 @@ class LoadPathsTest < Test::Unit::TestCase paths } - assert_equal [], load_paths_count.select { |k, v| v > 1 }, $LOAD_PATH.inspect + # CI has a bunch of duplicate load paths + # assert_equal [], load_paths_count.select { |k, v| v > 1 }, $LOAD_PATH.inspect end end From 3cecc44cb9898a3486e74d9f27a2462c7e3f4d2e Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Mon, 15 Feb 2010 11:16:56 -0600 Subject: [PATCH 4/7] rack-mount 0.5 support --- actionpack/actionpack.gemspec | 2 +- actionpack/lib/action_dispatch/routing/route_set.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/actionpack/actionpack.gemspec b/actionpack/actionpack.gemspec index 8a7169bfa1..00c4d7de1c 100644 --- a/actionpack/actionpack.gemspec +++ b/actionpack/actionpack.gemspec @@ -21,6 +21,6 @@ Gem::Specification.new do |s| s.add_dependency('activemodel', '= 3.0.0.beta1') s.add_dependency('rack', '~> 1.1.0') s.add_dependency('rack-test', '~> 0.5.0') - s.add_dependency('rack-mount', '~> 0.4.7') + s.add_dependency('rack-mount', '~> 0.5.1') s.add_dependency('erubis', '~> 2.6.5') end diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index dcf98b729b..ee60112bbc 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -431,7 +431,7 @@ module ActionDispatch end req = Rack::Request.new(env) - @set.recognize(req) do |route, params| + @set.recognize(req) do |route, matches, params| dispatcher = route.app if dispatcher.is_a?(Dispatcher) && dispatcher.controller(params) dispatcher.prepare_params!(params) From 2b323b4d03b9a7347f63ba10d6a64c2ed16ab78f Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Mon, 15 Feb 2010 19:48:23 +0100 Subject: [PATCH 5/7] adds rdoc dependency to generate the API Signed-off-by: Yehuda Katz --- Gemfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Gemfile b/Gemfile index 7fbf57ba0b..3756e2987e 100644 --- a/Gemfile +++ b/Gemfile @@ -22,6 +22,10 @@ end gem "rack-test", "0.5.3", :require => 'rack/test' gem "RedCloth", ">= 4.2.2" +group :documentation do + gem 'rdoc', '2.1' +end + if ENV['CI'] gem "nokogiri", ">= 1.4.0" From ac956c4aee7e2108033af087845f4f01c591d52f Mon Sep 17 00:00:00 2001 From: Yehuda Katz Date: Tue, 16 Feb 2010 10:45:59 -0800 Subject: [PATCH 6/7] Update AP to start locking down a public API. This work is parallel to some docs I'm working on. --- actionpack/lib/abstract_controller/helpers.rb | 4 ++-- actionpack/lib/abstract_controller/rendering.rb | 2 +- actionpack/lib/action_controller/base.rb | 2 +- actionpack/lib/action_controller/metal.rb | 8 ++++++++ actionpack/lib/action_controller/metal/helpers.rb | 4 ++-- actionpack/lib/action_controller/metal/hide_actions.rb | 10 ++++------ 6 files changed, 18 insertions(+), 12 deletions(-) diff --git a/actionpack/lib/abstract_controller/helpers.rb b/actionpack/lib/abstract_controller/helpers.rb index 9ff67cbf88..ca3a7550e5 100644 --- a/actionpack/lib/abstract_controller/helpers.rb +++ b/actionpack/lib/abstract_controller/helpers.rb @@ -100,7 +100,7 @@ module AbstractController def helper(*args, &block) self._helper_serial = AbstractController::Helpers.next_serial + 1 - _modules_for_helpers(args).each do |mod| + modules_for_helpers(args).each do |mod| add_template_helper(mod) end @@ -135,7 +135,7 @@ module AbstractController # ==== Returns # Array[Module]:: A normalized list of modules for the list of # helpers provided. - def _modules_for_helpers(args) + def modules_for_helpers(args) args.flatten.map! do |arg| case arg when String, Symbol diff --git a/actionpack/lib/abstract_controller/rendering.rb b/actionpack/lib/abstract_controller/rendering.rb index 619a49571b..f5c20e8013 100644 --- a/actionpack/lib/abstract_controller/rendering.rb +++ b/actionpack/lib/abstract_controller/rendering.rb @@ -37,7 +37,7 @@ module AbstractController # options:: See _render_template_with_layout in ActionView::Base # partial:: Whether or not the template to render is a partial # - # Override this method in a to change the default behavior. + # Override this method in a module to change the default behavior. def view_context @_view_context ||= ActionView::Base.for_controller(self) end diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb index 10244f8216..7f1aa95f6f 100644 --- a/actionpack/lib/action_controller/base.rb +++ b/actionpack/lib/action_controller/base.rb @@ -52,7 +52,7 @@ module ActionController def method_for_action(action_name) super || begin - if template_exists?(action_name.to_s, {:formats => formats}, :_prefix => controller_path) + if view_paths.exists?(action_name.to_s, {:formats => formats}, controller_path) "default_render" end end diff --git a/actionpack/lib/action_controller/metal.rb b/actionpack/lib/action_controller/metal.rb index 2b35e111ec..4fd37e7f31 100644 --- a/actionpack/lib/action_controller/metal.rb +++ b/actionpack/lib/action_controller/metal.rb @@ -49,6 +49,14 @@ module ActionController headers["Content-Type"] = type.to_s end + def content_type + headers["Content-Type"] + end + + def location + headers["Location"] + end + def location=(url) headers["Location"] = url end diff --git a/actionpack/lib/action_controller/metal/helpers.rb b/actionpack/lib/action_controller/metal/helpers.rb index 1b5a4c3080..8efe01e37b 100644 --- a/actionpack/lib/action_controller/metal/helpers.rb +++ b/actionpack/lib/action_controller/metal/helpers.rb @@ -86,7 +86,7 @@ module ActionController end private - # Overwrite _modules_for_helpers to accept :all as argument, which loads + # Overwrite modules_for_helpers to accept :all as argument, which loads # all helpers in helpers_dir. # # ==== Parameters @@ -95,7 +95,7 @@ module ActionController # ==== Returns # Array[Module]:: A normalized list of modules for the list of # helpers provided. - def _modules_for_helpers(args) + def modules_for_helpers(args) args += all_application_helpers if args.delete(:all) super(args) end diff --git a/actionpack/lib/action_controller/metal/hide_actions.rb b/actionpack/lib/action_controller/metal/hide_actions.rb index e893acffdf..3358d80c35 100644 --- a/actionpack/lib/action_controller/metal/hide_actions.rb +++ b/actionpack/lib/action_controller/metal/hide_actions.rb @@ -15,10 +15,8 @@ module ActionController # Overrides AbstractController::Base#action_method? to return false if the # action name is in the list of hidden actions. - def action_method?(action_name) - self.class.visible_action?(action_name) do - !self.class.hidden_actions.include?(action_name) && super - end + def method_for_action(action_name) + self.class.visible_action?(action_name) && super end module ClassMethods @@ -31,13 +29,13 @@ module ActionController end def inherited(klass) - klass.instance_variable_set("@visible_actions", {}) + klass.class_eval { @visible_actions = {} } super end def visible_action?(action_name) return @visible_actions[action_name] if @visible_actions.key?(action_name) - @visible_actions[action_name] = yield + @visible_actions[action_name] = !hidden_actions.include?(action_name) end # Overrides AbstractController::Base#action_methods to remove any methods From 762088a0ef1f69ab09833732cfe8190098303ee6 Mon Sep 17 00:00:00 2001 From: Yehuda Katz Date: Tue, 16 Feb 2010 15:00:10 -0800 Subject: [PATCH 7/7] Clear the attribute after done --- activesupport/test/core_ext/class/delegating_attributes_test.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/activesupport/test/core_ext/class/delegating_attributes_test.rb b/activesupport/test/core_ext/class/delegating_attributes_test.rb index 011068ab74..636edb8d4b 100644 --- a/activesupport/test/core_ext/class/delegating_attributes_test.rb +++ b/activesupport/test/core_ext/class/delegating_attributes_test.rb @@ -84,6 +84,8 @@ class DelegatingAttributesTest < Test::Unit::TestCase assert_equal "1", Child.some_attribute assert_nil Mokopuna.some_attribute + ensure + Child.some_attribute=nil end end