Skip to content

Commit

Permalink
Merge branch 'master' into nested_has_many_through
Browse files Browse the repository at this point in the history
Conflicts:
	activerecord/CHANGELOG
	activerecord/lib/active_record/associations.rb
  • Loading branch information
jonleighton committed Nov 27, 2010
2 parents 1bc9004 + fd83f9d commit 3a7f43c
Show file tree
Hide file tree
Showing 171 changed files with 3,057 additions and 1,857 deletions.
4 changes: 2 additions & 2 deletions Rakefile 100644 → 100755
@@ -1,7 +1,7 @@
#!/usr/bin/env rake
gem 'rdoc', '>= 2.5.10'
require 'rdoc'

require 'rake'
require 'rdoc/task'
require 'net/http'

Expand Down Expand Up @@ -172,7 +172,7 @@ end
#
# Everything is automated and you do NOT need to run this task normally.
#
# We publish a new verion by tagging, and pushing a tag does not trigger
# We publish a new version by tagging, and pushing a tag does not trigger
# that webhook. Stable docs would be updated by any subsequent regular
# push, but if you want that to happen right away just run this.
#
Expand Down
2 changes: 1 addition & 1 deletion actionmailer/Rakefile 100644 → 100755
@@ -1,4 +1,4 @@
require 'rake'
#!/usr/bin/env rake
require 'rake/testtask'
require 'rake/packagetask'
require 'rake/gempackagetask'
Expand Down
6 changes: 3 additions & 3 deletions actionmailer/lib/action_mailer/base.rb
Expand Up @@ -234,8 +234,8 @@ module ActionMailer #:nodoc:
# default :sender => 'system@example.com'
# end
#
# You can pass in any header value that a <tt>Mail::Message</tt>, out of the box, <tt>ActionMailer::Base</tt>
# sets the following:
# You can pass in any header value that a <tt>Mail::Message</tt> accepts. Out of the box,
# <tt>ActionMailer::Base</tt> sets the following:
#
# * <tt>:mime_version => "1.0"</tt>
# * <tt>:charset => "UTF-8",</tt>
Expand Down Expand Up @@ -273,7 +273,7 @@ module ActionMailer #:nodoc:
# = Configuration options
#
# These options are specified on the class level, like
# <tt>ActionMailer::Base.template_root = "/my/templates"</tt>
# <tt>ActionMailer::Base.raise_delivery_errors = true</tt>
#
# * <tt>default</tt> - You can pass this in at a class level as well as within the class itself as
# per the above section.
Expand Down
7 changes: 5 additions & 2 deletions actionmailer/lib/action_mailer/test_case.rb
@@ -1,3 +1,5 @@
require 'active_support/core_ext/class/attribute'

module ActionMailer
class NonInferrableMailerError < ::StandardError
def initialize(name)
Expand All @@ -15,11 +17,11 @@ module Behavior

module ClassMethods
def tests(mailer)
write_inheritable_attribute(:mailer_class, mailer)
self._mailer_class = mailer
end

def mailer_class
if mailer = read_inheritable_attribute(:mailer_class)
if mailer = self._mailer_class
mailer
else
tests determine_default_mailer(name)
Expand Down Expand Up @@ -65,6 +67,7 @@ def read_fixture(action)
end

included do
class_attribute :_mailer_class
setup :initialize_test_deliveries
setup :set_expected_mail
end
Expand Down
2 changes: 2 additions & 0 deletions actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*Rails 3.1.0 (unreleased)*

* Added config.action_controller.include_all_helpers. By default 'helper :all' is done in ActionController::Base, which includes all the helpers by default. Setting include_all_helpers to false will result in including only application_helper and helper corresponding to controller (like foo_helper for foo_controller). [Piotr Sarnacki]

* Added a convenience idiom to generate HTML5 data-* attributes in tag helpers from a :data hash of options:

tag("div", :data => {:name => 'Stephen', :city_state => %w(Chicago IL)})
Expand Down
2 changes: 1 addition & 1 deletion actionpack/Rakefile 100644 → 100755
@@ -1,4 +1,4 @@
require 'rake'
#!/usr/bin/env rake
require 'rake/testtask'
require 'rake/packagetask'
require 'rake/gempackagetask'
Expand Down
2 changes: 1 addition & 1 deletion actionpack/actionpack.gemspec
Expand Up @@ -22,7 +22,7 @@ Gem::Specification.new do |s|
s.add_dependency('activesupport', version)
s.add_dependency('activemodel', version)
s.add_dependency('rack-cache', '~> 0.5.3')
s.add_dependency('builder', '~> 2.1.2')
s.add_dependency('builder', '~> 3.0.0')
s.add_dependency('i18n', '~> 0.4.2')
s.add_dependency('rack', '~> 1.2.1')
s.add_dependency('rack-test', '~> 0.5.6')
Expand Down
8 changes: 4 additions & 4 deletions actionpack/lib/abstract_controller/rendering.rb
Expand Up @@ -119,7 +119,7 @@ def _prefix
controller_path
end

private
private

# This method should return a hash with assigns.
# You can overwrite this configuration per controller.
Expand All @@ -128,7 +128,7 @@ def view_assigns
hash = {}
variables = instance_variable_names
variables -= protected_instance_variables if respond_to?(:protected_instance_variables)
variables.each { |name| hash[name.to_s[1..-1]] = instance_variable_get(name) }
variables.each { |name| hash[name.to_s[1, name.length]] = instance_variable_get(name) }
hash
end

Expand All @@ -138,13 +138,13 @@ def _normalize_args(action=nil, options={})
case action
when NilClass
when Hash
options, action = action, nil
options = action
when String, Symbol
action = action.to_s
key = action.include?(?/) ? :file : :action
options[key] = action
else
options.merge!(:partial => action)
options[:partial] = action
end

options
Expand Down
3 changes: 2 additions & 1 deletion actionpack/lib/action_controller/metal/helpers.rb
Expand Up @@ -53,8 +53,9 @@ module Helpers
include AbstractController::Helpers

included do
config_accessor :helpers_path
config_accessor :helpers_path, :include_all_helpers
self.helpers_path ||= []
self.include_all_helpers = true
end

module ClassMethods
Expand Down
8 changes: 4 additions & 4 deletions actionpack/lib/action_controller/metal/mime_responds.rb
Expand Up @@ -258,9 +258,8 @@ def collect_mimes_from_class_level #:nodoc:
# nil if :not_acceptable was sent to the client.
#
def retrieve_response_from_mimes(mimes=nil, &block)
collector = Collector.new { default_render }
mimes ||= collect_mimes_from_class_level
mimes.each { |mime| collector.send(mime) }
collector = Collector.new(mimes) { default_render }
block.call(collector) if block_given?

if format = request.negotiate_mime(collector.order)
Expand All @@ -277,8 +276,9 @@ class Collector #:nodoc:
include AbstractController::Collector
attr_accessor :order

def initialize(&block)
def initialize(mimes, &block)
@order, @responses, @default_response = [], {}, block
mimes.each { |mime| send(mime) }
end

def any(*args, &block)
Expand All @@ -291,7 +291,7 @@ def any(*args, &block)
alias :all :any

def custom(mime_type, &block)
mime_type = mime_type.is_a?(Mime::Type) ? mime_type : Mime::Type.lookup(mime_type.to_s)
mime_type = Mime::Type.lookup(mime_type.to_s) unless mime_type.is_a?(Mime::Type)
@order << mime_type
@responses[mime_type] ||= block
end
Expand Down
38 changes: 11 additions & 27 deletions actionpack/lib/action_controller/metal/renderers.rb
Expand Up @@ -15,30 +15,12 @@ module Renderers
end

module ClassMethods
def _write_render_options
renderers = _renderers.map do |name, value|
<<-RUBY_EVAL
if options.key?(:#{name})
_process_options(options)
return _render_option_#{name}(options.delete(:#{name}), options)
end
RUBY_EVAL
end

class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
def _handle_render_options(options)
#{renderers.join}
end
RUBY_EVAL
end

def use_renderers(*args)
new = _renderers.dup
args.each do |key|
new[key] = RENDERERS[key]
end
self._renderers = new.freeze
_write_render_options
end
alias use_renderer use_renderers
end
Expand All @@ -47,31 +29,33 @@ def render_to_body(options)
_handle_render_options(options) || super
end

def _handle_render_options(options)
_renderers.each do |name, value|
if options.key?(name.to_sym)
_process_options(options)
return send("_render_option_#{name}", options.delete(name.to_sym), options)
end
end
nil
end

RENDERERS = {}
def self.add(key, &block)
define_method("_render_option_#{key}", &block)
RENDERERS[key] = block
All._write_render_options
end

module All
extend ActiveSupport::Concern
include Renderers

INCLUDED = []
included do
self._renderers = RENDERERS
_write_render_options
INCLUDED << self
end

def self._write_render_options
INCLUDED.each(&:_write_render_options)
end
end

add :json do |json, options|
json = json.to_json(options) unless json.respond_to?(:to_str)
json = json.to_json(options) unless json.kind_of?(String)
json = "#{options[:callback]}(#{json})" unless options[:callback].blank?
self.content_type ||= Mime::JSON
self.response_body = json
Expand Down
47 changes: 23 additions & 24 deletions actionpack/lib/action_controller/metal/rendering.rb
Expand Up @@ -20,36 +20,35 @@ def render(*args) #:nodoc:

private

# Normalize arguments by catching blocks and setting them on :update.
def _normalize_args(action=nil, options={}, &blk) #:nodoc:
options = super
options[:update] = blk if block_given?
options
end

# Normalize both text and status options.
def _normalize_options(options) #:nodoc:
if options.key?(:text) && options[:text].respond_to?(:to_text)
options[:text] = options[:text].to_text
end
# Normalize arguments by catching blocks and setting them on :update.
def _normalize_args(action=nil, options={}, &blk) #:nodoc:
options = super
options[:update] = blk if block_given?
options
end

if options[:status]
options[:status] = Rack::Utils.status_code(options[:status])
end
# Normalize both text and status options.
def _normalize_options(options) #:nodoc:
if options.key?(:text) && options[:text].respond_to?(:to_text)
options[:text] = options[:text].to_text
end

super
if options[:status]
options[:status] = Rack::Utils.status_code(options[:status])
end

# Process controller specific options, as status, content-type and location.
def _process_options(options) #:nodoc:
status, content_type, location = options.values_at(:status, :content_type, :location)
super
end

self.status = status if status
self.content_type = content_type if content_type
self.headers["Location"] = url_for(location) if location
# Process controller specific options, as status, content-type and location.
def _process_options(options) #:nodoc:
status, content_type, location = options.values_at(:status, :content_type, :location)

super
end
self.status = status if status
self.content_type = content_type if content_type
self.headers["Location"] = url_for(location) if location

super
end
end
end
Expand Up @@ -53,9 +53,13 @@ module ClassMethods
# class FooController < ApplicationController
# protect_from_forgery :except => :index
#
# # you can disable csrf protection on controller-by-controller basis:
# skip_before_filter :verify_authenticity_token
# end
# You can disable csrf protection on controller-by-controller basis:
#
# skip_before_filter :verify_authenticity_token
#
# It can also be disabled for specific controller actions:
#
# skip_before_filter :verify_authenticity_token, :except => [:create]
#
# Valid Options:
#
Expand Down
4 changes: 3 additions & 1 deletion actionpack/lib/action_controller/metal/url_for.rb
Expand Up @@ -6,7 +6,8 @@ module UrlFor

def url_options
@_url_options ||= super.reverse_merge(
:host => request.host_with_port,
:host => request.host,
:port => request.optional_port,
:protocol => request.protocol,
:_path_segments => request.symbolized_path_parameters
).freeze
Expand All @@ -20,5 +21,6 @@ def url_options
@_url_options
end
end

end
end
4 changes: 3 additions & 1 deletion actionpack/lib/action_controller/railties/paths.rb
Expand Up @@ -13,7 +13,9 @@ def self.with(app)
end

klass.helpers_path = paths
klass.helper :all if klass.superclass == ActionController::Base
if klass.superclass == ActionController::Base && ActionController::Base.include_all_helpers
klass.helper :all
end
end
end
end
Expand Down
6 changes: 4 additions & 2 deletions actionpack/lib/action_controller/test_case.rb
@@ -1,6 +1,7 @@
require 'rack/session/abstract/id'
require 'active_support/core_ext/object/blank'
require 'active_support/core_ext/object/to_query'
require 'active_support/core_ext/class/attribute'

module ActionController
module TemplateAssertions
Expand Down Expand Up @@ -325,11 +326,11 @@ def tests(controller_class)

def controller_class=(new_class)
prepare_controller_class(new_class) if new_class
write_inheritable_attribute(:controller_class, new_class)
self._controller_class = new_class
end

def controller_class
if current_controller_class = read_inheritable_attribute(:controller_class)
if current_controller_class = self._controller_class
current_controller_class
else
self.controller_class = determine_default_controller_class(name)
Expand Down Expand Up @@ -442,6 +443,7 @@ def rescue_action_in_public!
included do
include ActionController::TemplateAssertions
include ActionDispatch::Assertions
class_attribute :_controller_class
setup :setup_controller_request_and_response
end

Expand Down
@@ -1,5 +1,5 @@
require 'set'
require 'active_support/core_ext/class/inheritable_attributes'
require 'active_support/core_ext/class/attribute'

module HTML
class Sanitizer
Expand Down Expand Up @@ -60,7 +60,7 @@ def process_node(node, result, options)
class WhiteListSanitizer < Sanitizer
[:protocol_separator, :uri_attributes, :allowed_attributes, :allowed_tags, :allowed_protocols, :bad_tags,
:allowed_css_properties, :allowed_css_keywords, :shorthand_css_properties].each do |attr|
class_inheritable_accessor attr, :instance_writer => false
class_attribute attr, :instance_writer => false
end

# A regular expression of the valid characters used to separate protocols like
Expand Down

0 comments on commit 3a7f43c

Please sign in to comment.