Skip to content

Commit

Permalink
Merge branch 'master' into nested_has_many_through
Browse files Browse the repository at this point in the history
  • Loading branch information
jonleighton committed Oct 6, 2010
2 parents f2b4191 + d40ca9c commit c954d54
Show file tree
Hide file tree
Showing 90 changed files with 990 additions and 1,040 deletions.
1 change: 1 addition & 0 deletions Gemfile
Expand Up @@ -6,6 +6,7 @@ else
gem "arel", :git => "git://github.com/rails/arel.git" gem "arel", :git => "git://github.com/rails/arel.git"
end end


gem "rack", :git => "git://github.com/rack/rack.git"
gem "rails", :path => File.dirname(__FILE__) gem "rails", :path => File.dirname(__FILE__)


gem "rake", ">= 0.8.7" gem "rake", ">= 0.8.7"
Expand Down
4 changes: 2 additions & 2 deletions actionmailer/lib/action_mailer/old_api.rb
Expand Up @@ -247,8 +247,8 @@ def parse_content_type(defaults=nil)
[ nil, {} ] [ nil, {} ]
else else
ctype, *attrs = @content_type.split(/;\s*/) ctype, *attrs = @content_type.split(/;\s*/)
attrs = attrs.inject({}) { |h,s| k,v = s.split(/\=/, 2); h[k] = v; h } attrs = Hash[attrs.map { |attr| attr.split(/\=/, 2) }]
[ctype, {"charset" => @charset}.merge(attrs)] [ctype, {"charset" => @charset}.merge!(attrs)]
end end
end end
end end
Expand Down
Expand Up @@ -6,7 +6,7 @@ class <%= class_name %> < ActionMailer::Base
# Subject can be set in your I18n file at config/locales/en.yml # Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup: # with the following lookup:
# #
# en.<%= file_name %>.<%= action %>.subject # en.<%= file_path.gsub("/",".") %>.<%= action %>.subject
# #
def <%= action %> def <%= action %>
@greeting = "Hi" @greeting = "Hi"
Expand Down
6 changes: 3 additions & 3 deletions actionpack/CHANGELOG
@@ -1,12 +1,12 @@
*Rails 3.1.0 (unreleased)* *Rails 3.1.0 (unreleased)*


* Rely on Rack::Session stores API for more compatibility across the Ruby world. This is backwards incompatible since Rack::Session expects #get_session to accept 4 arguments and requires #destroy_session instead of simply #destroy. [José Valim]

* file_field automatically adds :multipart => true to the enclosing form. [Santiago Pastorino] * file_field automatically adds :multipart => true to the enclosing form. [Santiago Pastorino]


* Renames csrf_meta_tag -> csrf_meta_tags, and aliases csrf_meta_tag for backwards compatibility. [fxn] * Renames csrf_meta_tag -> csrf_meta_tags, and aliases csrf_meta_tag for backwards compatibility. [fxn]


* Add Rack::Cache to the default stack. Create a Rails store that delegates to the Rails cache, so by default, whatever caching layer you are using will be used * Add Rack::Cache to the default stack. Create a Rails store that delegates to the Rails cache, so by default, whatever caching layer you are using will be used for HTTP caching. Note that Rack::Cache will be used if you use #expires_in, #fresh_when or #stale with :public => true. Otherwise, the caching rules will apply to the browser only. [Yehuda Katz, Carl Lerche]
for HTTP caching. Note that Rack::Cache will be used if you use #expires_in, #fresh_when or #stale with :public => true. Otherwise, the caching rules will apply
to the browser only.


*Rails 3.0.0 (August 29, 2010)* *Rails 3.0.0 (August 29, 2010)*


Expand Down
9 changes: 6 additions & 3 deletions actionpack/lib/action_controller/test_case.rb
Expand Up @@ -187,15 +187,18 @@ def recycle!
end end
end end


class TestSession < ActionDispatch::Session::AbstractStore::SessionHash #:nodoc: class TestSession < Rack::Session::Abstract::SessionHash #:nodoc:
DEFAULT_OPTIONS = ActionDispatch::Session::AbstractStore::DEFAULT_OPTIONS DEFAULT_OPTIONS = Rack::Session::Abstract::ID::DEFAULT_OPTIONS


def initialize(session = {}) def initialize(session = {})
@env, @by = nil, nil
replace(session.stringify_keys) replace(session.stringify_keys)
@loaded = true @loaded = true
end end


def exists?; true; end def exists?
true
end
end end


# Superclass for ActionController functional tests. Functional tests allow you to # Superclass for ActionController functional tests. Functional tests allow you to
Expand Down
22 changes: 1 addition & 21 deletions actionpack/lib/action_dispatch/http/cache.rb
Expand Up @@ -50,8 +50,7 @@ def initialize(*)
if cache_control = self["Cache-Control"] if cache_control = self["Cache-Control"]
cache_control.split(/,\s*/).each do |segment| cache_control.split(/,\s*/).each do |segment|
first, last = segment.split("=") first, last = segment.split("=")
last ||= true @cache_control[first.to_sym] = last || true
@cache_control[first.to_sym] = last
end end
end end
end end
Expand Down Expand Up @@ -88,28 +87,9 @@ def etag=(etag)
def handle_conditional_get! def handle_conditional_get!
if etag? || last_modified? || !@cache_control.empty? if etag? || last_modified? || !@cache_control.empty?
set_conditional_cache_control! set_conditional_cache_control!
elsif nonempty_ok_response?
self.etag = body

if request && request.etag_matches?(etag)
self.status = 304
self.body = []
end

set_conditional_cache_control!
else
headers["Cache-Control"] = "no-cache"
end end
end end


def nonempty_ok_response?
@status == 200 && string_body?
end

def string_body?
!@blank && @body.respond_to?(:all?) && @body.all? { |part| part.is_a?(String) }
end

DEFAULT_CACHE_CONTROL = "max-age=0, private, must-revalidate" DEFAULT_CACHE_CONTROL = "max-age=0, private, must-revalidate"


def set_conditional_cache_control! def set_conditional_cache_control!
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_dispatch/http/request.rb
Expand Up @@ -199,7 +199,7 @@ def body_stream #:nodoc:
# TODO This should be broken apart into AD::Request::Session and probably # TODO This should be broken apart into AD::Request::Session and probably
# be included by the session middleware. # be included by the session middleware.
def reset_session def reset_session
session.destroy if session session.destroy if session && session.respond_to?(:destroy)
self.session = {} self.session = {}
@env['action_dispatch.request.flash_hash'] = nil @env['action_dispatch.request.flash_hash'] = nil
end end
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_dispatch/http/response.rb
Expand Up @@ -132,7 +132,7 @@ def location=(url)
# information. # information.
attr_accessor :charset, :content_type attr_accessor :charset, :content_type


CONTENT_TYPE = "Content-Type" CONTENT_TYPE = "Content-Type"


cattr_accessor(:default_charset) { "utf-8" } cattr_accessor(:default_charset) { "utf-8" }


Expand Down
25 changes: 13 additions & 12 deletions actionpack/lib/action_dispatch/http/upload.rb
Expand Up @@ -2,27 +2,28 @@


module ActionDispatch module ActionDispatch
module Http module Http
class UploadedFile < Tempfile class UploadedFile
attr_accessor :original_filename, :content_type, :tempfile, :headers attr_accessor :original_filename, :content_type, :tempfile, :headers


def initialize(hash) def initialize(hash)
@original_filename = hash[:filename] @original_filename = hash[:filename]
@content_type = hash[:type] @content_type = hash[:type]
@headers = hash[:head] @headers = hash[:head]
@tempfile = hash[:tempfile]
raise(ArgumentError, ':tempfile is required') unless @tempfile
end


# To the untrained eye, this may appear as insanity. Given the alternatives, def read(*args)
# such as busting the method cache on every request or breaking backwards @tempfile.read(*args)
# compatibility with is_a?(Tempfile), this solution is the best available
# option.
#
# TODO: Deprecate is_a?(Tempfile) and define a real API for this parameter
tempfile = hash[:tempfile]
tempfile.instance_variables.each do |ivar|
instance_variable_set(ivar, tempfile.instance_variable_get(ivar))
end
end end


alias local_path path def rewind
@tempfile.rewind
end

def size
@tempfile.size
end
end end


module Upload module Upload
Expand Down
5 changes: 0 additions & 5 deletions actionpack/lib/action_dispatch/http/url.rb
Expand Up @@ -18,11 +18,6 @@ def protocol
@protocol ||= ssl? ? 'https://' : 'http://' @protocol ||= ssl? ? 'https://' : 'http://'
end end


# Is this an SSL request?
def ssl?
@ssl ||= @env['HTTPS'] == 'on' || @env['HTTP_X_FORWARDED_PROTO'] == 'https'
end

# Returns the \host for this request, such as "example.com". # Returns the \host for this request, such as "example.com".
def raw_host_with_port def raw_host_with_port
if forwarded = env["HTTP_X_FORWARDED_HOST"] if forwarded = env["HTTP_X_FORWARDED_HOST"]
Expand Down

0 comments on commit c954d54

Please sign in to comment.