From 5e7d2cf97374757ffda8df1460659d94b6d9f36b Mon Sep 17 00:00:00 2001 From: Jacques Distler Date: Thu, 5 Mar 2009 07:54:17 -0600 Subject: [PATCH] Rails 2.3.1 Update to the release version of Rails 2.3.1. --- vendor/rails/actionmailer/CHANGELOG | 2 +- vendor/rails/actionpack/CHANGELOG | 4 +- .../actionpack/lib/action_controller/base.rb | 2 +- .../lib/action_controller/routing/segments.rb | 10 +++- .../activerecord/active_record_store_test.rb | 21 +++++++ .../test/controller/resources_test.rb | 12 +++- .../test/controller/routing_test.rb | 16 ++++++ vendor/rails/activerecord/CHANGELOG | 2 +- .../lib/active_record/session_store.rb | 10 +++- vendor/rails/activeresource/CHANGELOG | 2 +- vendor/rails/activesupport/CHANGELOG | 2 +- .../lib/active_support/ordered_hash.rb | 4 +- .../lib/active_support/test_case.rb | 2 +- .../activesupport/test/ordered_hash_test.rb | 14 ++++- vendor/rails/railties/CHANGELOG | 2 +- vendor/rails/railties/Rakefile | 9 ++- vendor/rails/railties/lib/initializer.rb | 6 ++ .../railties/lib/rails/backtrace_cleaner.rb | 3 + vendor/rails/railties/lib/rails/rack/metal.rb | 16 +++++- .../metal/multiplemetals/app/metal/metal_a.rb | 5 ++ .../metal/multiplemetals/app/metal/metal_b.rb | 5 ++ .../metal/singlemetal/app/metal/foo_metal.rb | 5 ++ .../subfolders/app/metal/Folder/metal_a.rb | 7 +++ .../subfolders/app/metal/Folder/metal_b.rb | 7 +++ vendor/rails/railties/test/metal_test.rb | 57 +++++++++++++++++++ 25 files changed, 199 insertions(+), 26 deletions(-) create mode 100644 vendor/rails/railties/test/fixtures/metal/multiplemetals/app/metal/metal_a.rb create mode 100644 vendor/rails/railties/test/fixtures/metal/multiplemetals/app/metal/metal_b.rb create mode 100644 vendor/rails/railties/test/fixtures/metal/singlemetal/app/metal/foo_metal.rb create mode 100644 vendor/rails/railties/test/fixtures/metal/subfolders/app/metal/Folder/metal_a.rb create mode 100644 vendor/rails/railties/test/fixtures/metal/subfolders/app/metal/Folder/metal_b.rb create mode 100644 vendor/rails/railties/test/metal_test.rb diff --git a/vendor/rails/actionmailer/CHANGELOG b/vendor/rails/actionmailer/CHANGELOG index 7c6cba29..2a5e3b81 100644 --- a/vendor/rails/actionmailer/CHANGELOG +++ b/vendor/rails/actionmailer/CHANGELOG @@ -1,4 +1,4 @@ -*2.3.1 [RC2] (February ?, 2009)* +*2.3.1 [RC2] (March 5, 2009)* * Fixed that ActionMailer should send correctly formatted Return-Path in MAIL FROM for SMTP #1842 [Matt Jones] diff --git a/vendor/rails/actionpack/CHANGELOG b/vendor/rails/actionpack/CHANGELOG index 809e90ff..c4e4211c 100644 --- a/vendor/rails/actionpack/CHANGELOG +++ b/vendor/rails/actionpack/CHANGELOG @@ -1,4 +1,6 @@ -*2.3.1 [RC2] (February ?, 2009)* +*2.3.1 [RC2] (March 5, 2009)* + +* Fixed that redirection would just log the options, not the final url (which lead to "Redirected to #") [DHH] * Added ability to pass in :public => true to fresh_when, stale?, and expires_in to make the request proxy cachable #2095 [Gregg Pollack] diff --git a/vendor/rails/actionpack/lib/action_controller/base.rb b/vendor/rails/actionpack/lib/action_controller/base.rb index 564fdf67..b769a2e6 100644 --- a/vendor/rails/actionpack/lib/action_controller/base.rb +++ b/vendor/rails/actionpack/lib/action_controller/base.rb @@ -1101,7 +1101,6 @@ module ActionController #:nodoc: end response.redirected_to = options - logger.info("Redirected to #{options}") if logger && logger.info? case options # The scheme name consist of a letter followed by any combination of @@ -1124,6 +1123,7 @@ module ActionController #:nodoc: def redirect_to_full_url(url, status) raise DoubleRenderError if performed? + logger.info("Redirected to #{url}") if logger && logger.info? response.redirect(url, interpret_status(status)) @performed_redirect = true end diff --git a/vendor/rails/actionpack/lib/action_controller/routing/segments.rb b/vendor/rails/actionpack/lib/action_controller/routing/segments.rb index 97375b1a..199eddbe 100644 --- a/vendor/rails/actionpack/lib/action_controller/routing/segments.rb +++ b/vendor/rails/actionpack/lib/action_controller/routing/segments.rb @@ -317,18 +317,22 @@ module ActionController end def regexp_chunk - '(\.[^/?\.]+)?' + '/|(\.[^/?\.]+)?' end def to_s '(.:format)?' end - + + def extract_value + "#{local_name} = options[:#{key}] && options[:#{key}].to_s.downcase" + end + #the value should not include the period (.) def match_extraction(next_capture) %[ if (m = match[#{next_capture}]) - params[:#{key}] = URI.unescape(m.from(1)) + params[:#{key}] = CGI.unescape(m.from(1)) end ] end diff --git a/vendor/rails/actionpack/test/activerecord/active_record_store_test.rb b/vendor/rails/actionpack/test/activerecord/active_record_store_test.rb index 6a75e605..7998f9c2 100644 --- a/vendor/rails/actionpack/test/activerecord/active_record_store_test.rb +++ b/vendor/rails/actionpack/test/activerecord/active_record_store_test.rb @@ -21,6 +21,11 @@ class ActiveRecordStoreTest < ActionController::IntegrationTest render :text => "foo: #{session[:foo].inspect}" end + def call_reset_session + reset_session + head :ok + end + def rescue_action(e) raise end end @@ -61,6 +66,22 @@ class ActiveRecordStoreTest < ActionController::IntegrationTest end end + def test_setting_session_value_after_session_reset + with_test_route_set do + get '/set_session_value' + assert_response :success + assert cookies['_session_id'] + + get '/call_reset_session' + assert_response :success + assert_not_equal [], headers['Set-Cookie'] + + get '/get_session_value' + assert_response :success + assert_equal 'foo: nil', response.body + end + end + def test_prevents_session_fixation with_test_route_set do get '/set_session_value' diff --git a/vendor/rails/actionpack/test/controller/resources_test.rb b/vendor/rails/actionpack/test/controller/resources_test.rb index ae2639d2..c441cfd4 100644 --- a/vendor/rails/actionpack/test/controller/resources_test.rb +++ b/vendor/rails/actionpack/test/controller/resources_test.rb @@ -750,9 +750,17 @@ class ResourcesTest < ActionController::TestCase end def test_with_path_segment - with_restful_routing :messages, :as => 'reviews' do - assert_simply_restful_for :messages, :as => 'reviews' + with_restful_routing :messages do + assert_simply_restful_for :messages + assert_recognizes({:controller => "messages", :action => "index"}, "/messages") + assert_recognizes({:controller => "messages", :action => "index"}, "/messages/") end + + with_restful_routing :messages, :as => 'reviews' do + assert_simply_restful_for :messages, :as => 'reviews' + assert_recognizes({:controller => "messages", :action => "index"}, "/reviews") + assert_recognizes({:controller => "messages", :action => "index"}, "/reviews/") + end end def test_multiple_with_path_segment_and_controller diff --git a/vendor/rails/actionpack/test/controller/routing_test.rb b/vendor/rails/actionpack/test/controller/routing_test.rb index 13ba0c30..01b3db64 100644 --- a/vendor/rails/actionpack/test/controller/routing_test.rb +++ b/vendor/rails/actionpack/test/controller/routing_test.rb @@ -2237,6 +2237,22 @@ class RouteSetTest < Test::Unit::TestCase ) end + def test_format_is_not_inherit + set.draw do |map| + map.connect '/posts.:format', :controller => 'posts' + end + + assert_equal '/posts', set.generate( + {:controller => 'posts'}, + {:controller => 'posts', :action => 'index', :format => 'xml'} + ) + + assert_equal '/posts.xml', set.generate( + {:controller => 'posts', :format => 'xml'}, + {:controller => 'posts', :action => 'index', :format => 'xml'} + ) + end + def test_expiry_determination_should_consider_values_with_to_param set.draw { |map| map.connect 'projects/:project_id/:controller/:action' } assert_equal '/projects/1/post/show', set.generate( diff --git a/vendor/rails/activerecord/CHANGELOG b/vendor/rails/activerecord/CHANGELOG index c521a3be..404481ea 100644 --- a/vendor/rails/activerecord/CHANGELOG +++ b/vendor/rails/activerecord/CHANGELOG @@ -1,4 +1,4 @@ -*2.3.1 [RC2] (February ?, 2009)* +*2.3.1 [RC2] (March 5, 2009)* * Added ActiveRecord::Base.each and ActiveRecord::Base.find_in_batches for batch processing [DHH/Jamis Buck] diff --git a/vendor/rails/activerecord/lib/active_record/session_store.rb b/vendor/rails/activerecord/lib/active_record/session_store.rb index de199d30..3cc4640f 100644 --- a/vendor/rails/activerecord/lib/active_record/session_store.rb +++ b/vendor/rails/activerecord/lib/active_record/session_store.rb @@ -287,8 +287,7 @@ module ActiveRecord def get_session(env, sid) Base.silence do sid ||= generate_sid - session = @@session_class.find_by_session_id(sid) - session ||= @@session_class.new(:session_id => sid, :data => {}) + session = find_session(sid) env[SESSION_RECORD_KEY] = session [sid, session.data] end @@ -296,7 +295,7 @@ module ActiveRecord def set_session(env, sid, session_data) Base.silence do - record = env[SESSION_RECORD_KEY] + record = env[SESSION_RECORD_KEY] ||= find_session(sid) record.data = session_data return false unless record.save @@ -310,5 +309,10 @@ module ActiveRecord return true end + + def find_session(id) + @@session_class.find_by_session_id(id) || + @@session_class.new(:session_id => id, :data => {}) + end end end diff --git a/vendor/rails/activeresource/CHANGELOG b/vendor/rails/activeresource/CHANGELOG index 00ee2c24..ea0f7b1b 100644 --- a/vendor/rails/activeresource/CHANGELOG +++ b/vendor/rails/activeresource/CHANGELOG @@ -1,4 +1,4 @@ -*2.3.1 [RC2] (February ?, 2009)* +*2.3.1 [RC2] (March 5, 2009)* * Nothing new, just included in 2.3.1 diff --git a/vendor/rails/activesupport/CHANGELOG b/vendor/rails/activesupport/CHANGELOG index 2ac432e3..bbece634 100644 --- a/vendor/rails/activesupport/CHANGELOG +++ b/vendor/rails/activesupport/CHANGELOG @@ -1,4 +1,4 @@ -*2.3.1 [RC2] (February ?, 2009)* +*2.3.1 [RC2] (March 5, 2009)* * Vendorize i18n 0.1.3 gem (fixes issues with incompatible character encodings in Ruby 1.9) #2038 [Akira Matsuda] diff --git a/vendor/rails/activesupport/lib/active_support/ordered_hash.rb b/vendor/rails/activesupport/lib/active_support/ordered_hash.rb index 66aab9e5..fed8094a 100644 --- a/vendor/rails/activesupport/lib/active_support/ordered_hash.rb +++ b/vendor/rails/activesupport/lib/active_support/ordered_hash.rb @@ -54,7 +54,7 @@ module ActiveSupport end def to_hash - Hash.new(self) + self end def each_key @@ -93,7 +93,7 @@ module ActiveSupport end def inspect - "#" + "#" end private diff --git a/vendor/rails/activesupport/lib/active_support/test_case.rb b/vendor/rails/activesupport/lib/active_support/test_case.rb index 97b2b6ef..f05d4098 100644 --- a/vendor/rails/activesupport/lib/active_support/test_case.rb +++ b/vendor/rails/activesupport/lib/active_support/test_case.rb @@ -20,7 +20,7 @@ module ActiveSupport alias_method :method_name, :name else # TODO: Figure out how to get the Rails::BacktraceFilter into minitest/unit - if defined?(Rails) + if defined?(Rails) && ENV['BACKTRACE'].nil? require 'rails/backtrace_cleaner' Test::Unit::Util::BacktraceFilter.module_eval { include Rails::BacktraceFilterForTestUnit } end diff --git a/vendor/rails/activesupport/test/ordered_hash_test.rb b/vendor/rails/activesupport/test/ordered_hash_test.rb index fb76ca1a..7cd8c8a8 100644 --- a/vendor/rails/activesupport/test/ordered_hash_test.rb +++ b/vendor/rails/activesupport/test/ordered_hash_test.rb @@ -4,9 +4,11 @@ class OrderedHashTest < Test::Unit::TestCase def setup @keys = %w( blue green red pink orange ) @values = %w( 000099 009900 aa0000 cc0066 cc6633 ) + @hash = Hash.new @ordered_hash = ActiveSupport::OrderedHash.new @keys.each_with_index do |key, index| + @hash[key] = @values[index] @ordered_hash[key] = @values[index] end end @@ -17,7 +19,7 @@ class OrderedHashTest < Test::Unit::TestCase end def test_access - assert @keys.zip(@values).all? { |k, v| @ordered_hash[k] == v } + assert @hash.all? { |k, v| @ordered_hash[k] == v } end def test_assignment @@ -45,6 +47,10 @@ class OrderedHashTest < Test::Unit::TestCase assert_nil @ordered_hash.delete(bad_key) end + def test_to_hash + assert_same @ordered_hash, @ordered_hash.to_hash + end + def test_has_key assert_equal true, @ordered_hash.has_key?('blue') assert_equal true, @ordered_hash.key?('blue') @@ -148,4 +154,8 @@ class OrderedHashTest < Test::Unit::TestCase @ordered_hash.keys.pop assert_equal original, @ordered_hash.keys end -end \ No newline at end of file + + def test_inspect + assert @ordered_hash.inspect.include?(@hash.inspect) + end +end diff --git a/vendor/rails/railties/CHANGELOG b/vendor/rails/railties/CHANGELOG index 2b852dae..de506dfb 100644 --- a/vendor/rails/railties/CHANGELOG +++ b/vendor/rails/railties/CHANGELOG @@ -1,4 +1,4 @@ -*2.3.1 [RC2] (February ?, 2009)* +*2.3.1 [RC2] (March 5, 2009)* * Allow metal to live in plugins #2045 [Matthew Rudy] diff --git a/vendor/rails/railties/Rakefile b/vendor/rails/railties/Rakefile index 0250cc72..4b524f1c 100644 --- a/vendor/rails/railties/Rakefile +++ b/vendor/rails/railties/Rakefile @@ -344,9 +344,12 @@ task :pgem => [:gem] do `ssh gems.rubyonrails.org '/u/sites/gems/gemupdate.sh'` end -desc "Publish the API documentation" -task :pdoc => :rdoc do - # railties API isn't separately published +desc "Publish the guides" +task :pguides => :guides do + mkdir_p 'pkg' + `tar -czf pkg/guides.gz guides/output` + Rake::SshFilePublisher.new("web.rubyonrails.org", "/u/sites/guides.rubyonrails.org/public", "pkg", "guides.gz").upload + `ssh web.rubyonrails.org 'cd /u/sites/guides.rubyonrails.org/public/ && tar -xvzf guides.gz && mv guides/output/* . && rm -rf guides*'` end desc "Publish the release files to RubyForge." diff --git a/vendor/rails/railties/lib/initializer.rb b/vendor/rails/railties/lib/initializer.rb index 24ce3e75..edea4e51 100644 --- a/vendor/rails/railties/lib/initializer.rb +++ b/vendor/rails/railties/lib/initializer.rb @@ -559,6 +559,7 @@ Run `rake gems:install` to install the missing gems. end def initialize_metal + Rails::Rack::Metal.requested_metals = configuration.metals Rails::Rack::Metal.metal_paths += plugin_loader.engine_metal_paths configuration.middleware.insert_before( @@ -715,6 +716,11 @@ Run `rake gems:install` to install the missing gems. @plugins = plugins.nil? ? nil : plugins.map { |p| p.to_sym } end + # The list of metals to load. If this is set to nil, all metals will + # be loaded in alphabetical order. If this is set to [], no metals will + # be loaded. Otherwise metals will be loaded in the order specified + attr_accessor :metals + # The path to the root of the plugins directory. By default, it is in # vendor/plugins. attr_accessor :plugin_paths diff --git a/vendor/rails/railties/lib/rails/backtrace_cleaner.rb b/vendor/rails/railties/lib/rails/backtrace_cleaner.rb index e1b42271..b6fdf42c 100644 --- a/vendor/rails/railties/lib/rails/backtrace_cleaner.rb +++ b/vendor/rails/railties/lib/rails/backtrace_cleaner.rb @@ -2,6 +2,8 @@ module Rails class BacktraceCleaner < ActiveSupport::BacktraceCleaner ERB_METHOD_SIG = /:in `_run_erb_.*/ + RAILS_GEMS = %w( actionpack activerecord actionmailer activesupport activeresource rails ) + VENDOR_DIRS = %w( vendor/gems vendor/rails ) SERVER_DIRS = %w( lib/mongrel bin/mongrel lib/passenger bin/passenger-spawn-server @@ -20,6 +22,7 @@ module Rails add_filter { |line| line.sub('./', '/') } # for tests add_filter { |line| line.sub(/(#{GEMS_DIR})\/gems\/([a-z]+)-([0-9.]+)\/(.*)/, '\2 (\3) \4')} # http://gist.github.com/30430 add_silencer { |line| ALL_NOISE.any? { |dir| line.include?(dir) } } + add_silencer { |line| RAILS_GEMS.any? { |gem| line =~ /^#{gem} / } } add_silencer { |line| line =~ %r(vendor/plugins/[^\/]+/lib) } end end diff --git a/vendor/rails/railties/lib/rails/rack/metal.rb b/vendor/rails/railties/lib/rails/rack/metal.rb index 8dac992e..bce59f4c 100644 --- a/vendor/rails/railties/lib/rails/rack/metal.rb +++ b/vendor/rails/railties/lib/rails/rack/metal.rb @@ -8,16 +8,26 @@ module Rails cattr_accessor :metal_paths self.metal_paths = ["#{Rails.root}/app/metal"] + cattr_accessor :requested_metals def self.metals matcher = /#{Regexp.escape('/app/metal/')}(.*)\.rb\Z/ metal_glob = metal_paths.map{ |base| "#{base}/**/*.rb" } + all_metals = {} Dir[*metal_glob].sort.map do |file| - path = file.match(matcher)[1] - require path - path.classify.constantize + file = file.match(matcher)[1] + all_metals[file.classify] = file end + + load_list = requested_metals || all_metals.keys + + load_list.map do |requested_metal| + if metal = all_metals[requested_metal] + require metal + requested_metal.constantize + end + end.compact end def initialize(app) diff --git a/vendor/rails/railties/test/fixtures/metal/multiplemetals/app/metal/metal_a.rb b/vendor/rails/railties/test/fixtures/metal/multiplemetals/app/metal/metal_a.rb new file mode 100644 index 00000000..b8e70013 --- /dev/null +++ b/vendor/rails/railties/test/fixtures/metal/multiplemetals/app/metal/metal_a.rb @@ -0,0 +1,5 @@ +class MetalA < Rails::Rack::Metal + def self.call(env) + [200, { "Content-Type" => "text/html"}, "Hi"] + end +end diff --git a/vendor/rails/railties/test/fixtures/metal/multiplemetals/app/metal/metal_b.rb b/vendor/rails/railties/test/fixtures/metal/multiplemetals/app/metal/metal_b.rb new file mode 100644 index 00000000..adc2f45f --- /dev/null +++ b/vendor/rails/railties/test/fixtures/metal/multiplemetals/app/metal/metal_b.rb @@ -0,0 +1,5 @@ +class MetalB < Rails::Rack::Metal + def self.call(env) + [200, { "Content-Type" => "text/html"}, "Hi"] + end +end diff --git a/vendor/rails/railties/test/fixtures/metal/singlemetal/app/metal/foo_metal.rb b/vendor/rails/railties/test/fixtures/metal/singlemetal/app/metal/foo_metal.rb new file mode 100644 index 00000000..9ade2ce8 --- /dev/null +++ b/vendor/rails/railties/test/fixtures/metal/singlemetal/app/metal/foo_metal.rb @@ -0,0 +1,5 @@ +class FooMetal < Rails::Rack::Metal + def self.call(env) + [200, { "Content-Type" => "text/html"}, "Hi"] + end +end diff --git a/vendor/rails/railties/test/fixtures/metal/subfolders/app/metal/Folder/metal_a.rb b/vendor/rails/railties/test/fixtures/metal/subfolders/app/metal/Folder/metal_a.rb new file mode 100644 index 00000000..71a5a62e --- /dev/null +++ b/vendor/rails/railties/test/fixtures/metal/subfolders/app/metal/Folder/metal_a.rb @@ -0,0 +1,7 @@ +module Folder + class MetalA < Rails::Rack::Metal + def self.call(env) + [200, { "Content-Type" => "text/html"}, "Hi"] + end + end +end diff --git a/vendor/rails/railties/test/fixtures/metal/subfolders/app/metal/Folder/metal_b.rb b/vendor/rails/railties/test/fixtures/metal/subfolders/app/metal/Folder/metal_b.rb new file mode 100644 index 00000000..430d7bfe --- /dev/null +++ b/vendor/rails/railties/test/fixtures/metal/subfolders/app/metal/Folder/metal_b.rb @@ -0,0 +1,7 @@ +module Folder + class MetalB < Rails::Rack::Metal + def self.call(env) + [200, { "Content-Type" => "text/html"}, "Hi"] + end + end +end diff --git a/vendor/rails/railties/test/metal_test.rb b/vendor/rails/railties/test/metal_test.rb new file mode 100644 index 00000000..a31f4ab2 --- /dev/null +++ b/vendor/rails/railties/test/metal_test.rb @@ -0,0 +1,57 @@ +require 'abstract_unit' +require 'initializer' + +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_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 + + private + + 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