Permalink
Browse files

Merge branch 'master' into nested_has_many_through_2

  • Loading branch information...
jonleighton committed Sep 30, 2010
2 parents b689834 + 91deff0 commit 704961ce688f5bc1942529f44ea6b00014ef8378
Showing with 1,536 additions and 849 deletions.
  1. +3 −6 actionmailer/lib/action_mailer/base.rb
  2. +10 −0 actionmailer/lib/action_mailer/railtie.rb
  3. +1 −1 actionpack/Rakefile
  4. +4 −4 actionpack/lib/abstract_controller/base.rb
  5. +1 −2 actionpack/lib/abstract_controller/layouts.rb
  6. +0 −1 actionpack/lib/abstract_controller/url_for.rb
  7. +1 −0 actionpack/lib/action_controller.rb
  8. +1 −1 actionpack/lib/action_controller/caching/actions.rb
  9. +1 −2 actionpack/lib/action_controller/caching/pages.rb
  10. +4 −1 actionpack/lib/action_controller/metal.rb
  11. +3 −3 actionpack/lib/action_controller/metal/helpers.rb
  12. +10 −12 actionpack/lib/action_controller/metal/http_authentication.rb
  13. +1 −1 actionpack/lib/action_controller/metal/renderers.rb
  14. +11 −7 actionpack/lib/action_controller/metal/url_for.rb
  15. +10 −0 actionpack/lib/action_controller/railtie.rb
  16. +8 −6 actionpack/lib/action_controller/test_case.rb
  17. +4 −4 actionpack/lib/action_controller/vendor/html-scanner/html/node.rb
  18. +9 −10 actionpack/lib/action_dispatch/http/request.rb
  19. +0 −1 actionpack/lib/action_dispatch/http/response.rb
  20. +2 −2 actionpack/lib/action_dispatch/http/url.rb
  21. +5 −3 actionpack/lib/action_dispatch/middleware/callbacks.rb
  22. +3 −3 actionpack/lib/action_dispatch/middleware/session/abstract_store.rb
  23. +6 −3 actionpack/lib/action_dispatch/middleware/stack.rb
  24. +1 −1 actionpack/lib/action_dispatch/middleware/static.rb
  25. +2 −2 actionpack/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb
  26. +3 −3 actionpack/lib/action_dispatch/middleware/templates/rescues/_trace.erb
  27. +26 −22 actionpack/lib/action_dispatch/routing/mapper.rb
  28. +5 −5 actionpack/lib/action_dispatch/routing/polymorphic_routes.rb
  29. +24 −22 actionpack/lib/action_dispatch/routing/route_set.rb
  30. +5 −0 actionpack/lib/action_dispatch/routing/url_for.rb
  31. +2 −6 actionpack/lib/action_dispatch/testing/assertions/response.rb
  32. +12 −12 actionpack/lib/action_dispatch/testing/assertions/routing.rb
  33. +5 −3 actionpack/lib/action_dispatch/testing/assertions/selector.rb
  34. +20 −13 actionpack/lib/action_dispatch/testing/integration.rb
  35. +2 −1 actionpack/lib/action_dispatch/testing/test_request.rb
  36. +1 −2 actionpack/lib/action_view/base.rb
  37. +19 −11 actionpack/lib/action_view/helpers/asset_tag_helper.rb
  38. +1 −0 actionpack/lib/action_view/helpers/date_helper.rb
  39. +22 −15 actionpack/lib/action_view/helpers/form_helper.rb
  40. +5 −6 actionpack/lib/action_view/helpers/form_options_helper.rb
  41. +1 −1 actionpack/lib/action_view/helpers/text_helper.rb
  42. +15 −13 actionpack/lib/action_view/helpers/url_helper.rb
  43. +2 −0 actionpack/lib/action_view/template.rb
  44. +1 −0 actionpack/lib/action_view/template/error.rb
  45. +1 −0 actionpack/lib/action_view/template/resolver.rb
  46. +16 −13 actionpack/lib/action_view/test_case.rb
  47. +4 −4 actionpack/lib/action_view/testing/resolvers.rb
  48. +4 −2 actionpack/test/abstract/callbacks_test.rb
  49. +1 −1 actionpack/test/abstract/layouts_test.rb
  50. +2 −2 actionpack/test/activerecord/controller_runtime_test.rb
  51. +0 −32 actionpack/test/activerecord/render_partial_with_record_identification_test.rb
  52. +10 −3 actionpack/test/controller/action_pack_assertions_test.rb
  53. +4 −3 actionpack/test/controller/caching_test.rb
  54. +9 −1 actionpack/test/controller/capture_test.rb
  55. +2 −1 actionpack/test/controller/filters_test.rb
  56. +14 −14 actionpack/test/controller/log_subscriber_test.rb
  57. +2 −2 actionpack/test/controller/mime_responds_test.rb
  58. +13 −0 actionpack/test/controller/render_json_test.rb
  59. +4 −3 actionpack/test/controller/render_other_test.rb
  60. +8 −1 actionpack/test/controller/render_test.rb
  61. +18 −19 actionpack/test/controller/request_forgery_protection_test.rb
  62. +2 −0 actionpack/test/controller/rescue_test.rb
  63. +1 −1 actionpack/test/controller/selector_test.rb
  64. +1 −1 actionpack/test/controller/test_test.rb
  65. +1 −1 actionpack/test/controller/url_for_test.rb
  66. +1 −0 actionpack/test/controller/webservice_test.rb
  67. +5 −5 actionpack/test/dispatch/cookies_test.rb
  68. +0 −1 actionpack/test/dispatch/mime_type_test.rb
  69. +77 −16 actionpack/test/dispatch/prefix_generation_test.rb
  70. +1 −1 actionpack/test/dispatch/request/multipart_params_parsing_test.rb
  71. +1 −0 actionpack/test/dispatch/request/xml_params_parsing_test.rb
  72. +4 −3 actionpack/test/dispatch/request_test.rb
  73. +8 −8 actionpack/test/dispatch/response_test.rb
  74. +18 −8 actionpack/test/dispatch/routing_test.rb
  75. +1 −1 actionpack/test/dispatch/session/cookie_store_test.rb
  76. +7 −7 actionpack/test/dispatch/show_exceptions_test.rb
  77. +1 −1 actionpack/test/fixtures/alternate_helpers/foo_helper.rb
  78. +0 −1 actionpack/test/fixtures/test/hello_world_from_rxml.builder
  79. +1 −1 actionpack/test/fixtures/test/proper_block_detection.erb
  80. +1 −1 actionpack/test/template/asset_tag_helper_test.rb
  81. +1 −1 actionpack/test/template/atom_feed_helper_test.rb
  82. +0 −20 actionpack/test/template/date_helper_test.rb
  83. +1 −2 actionpack/test/template/form_helper_test.rb
  84. +2 −2 actionpack/test/template/html-scanner/tag_node_test.rb
  85. +0 −2 actionpack/test/template/javascript_helper_test.rb
  86. +9 −9 actionpack/test/template/log_subscriber_test.rb
  87. +5 −5 actionpack/test/template/number_helper_i18n_test.rb
  88. +1 −1 actionpack/test/template/prototype_helper_test.rb
  89. +3 −2 actionpack/test/template/render_test.rb
  90. +3 −3 actionpack/test/template/tag_helper_test.rb
  91. +9 −8 actionpack/test/template/template_test.rb
  92. +3 −3 actionpack/test/template/test_case_test.rb
  93. +1 −1 actionpack/test/template/text_helper_test.rb
  94. +4 −2 activemodel/lib/active_model/naming.rb
  95. +3 −1 activemodel/lib/active_model/validations/confirmation.rb
  96. +30 −0 activemodel/test/cases/callbacks_test.rb
  97. +1 −1 activerecord/activerecord.gemspec
  98. +1 −1 activerecord/examples/performance.rb
  99. +3 −3 activerecord/lib/active_record/association_preload.rb
  100. +1 −1 activerecord/lib/active_record/associations/belongs_to_polymorphic_association.rb
  101. +12 −10 activerecord/lib/active_record/base.rb
  102. +1 −1 activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb
  103. +6 −14 activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
  104. +11 −7 activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
  105. +29 −24 activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
  106. +2 −5 activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
  107. +2 −2 activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb
  108. +20 −17 activerecord/lib/active_record/dynamic_finder_match.rb
  109. +6 −15 activerecord/lib/active_record/dynamic_scope_match.rb
  110. +3 −5 activerecord/lib/active_record/fixtures.rb
  111. +6 −1 activerecord/lib/active_record/nested_attributes.rb
  112. +1 −1 activerecord/lib/active_record/railtie.rb
  113. +2 −2 activerecord/lib/active_record/railties/databases.rake
  114. +5 −10 activerecord/lib/active_record/relation.rb
  115. +11 −6 activerecord/lib/active_record/relation/calculations.rb
  116. +17 −41 activerecord/lib/active_record/relation/query_methods.rb
  117. +1 −1 activerecord/lib/active_record/serialization.rb
  118. +5 −0 activerecord/test/cases/associations/belongs_to_associations_test.rb
  119. +10 −0 activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
  120. +12 −0 activerecord/test/cases/associations/has_many_associations_test.rb
  121. +14 −0 activerecord/test/cases/associations/has_many_through_associations_test.rb
  122. +5 −0 activerecord/test/cases/associations/has_one_associations_test.rb
  123. +22 −0 activerecord/test/cases/base_test.rb
  124. +98 −0 activerecord/test/cases/dynamic_finder_match_test.rb
  125. +0 −51 activerecord/test/cases/finder_test.rb
  126. +1 −1 activerecord/test/cases/method_scoping_test.rb
  127. +20 −3 activerecord/test/cases/migration_test.rb
  128. +17 −1 activerecord/test/cases/nested_attributes_test.rb
  129. +5 −0 activerecord/test/cases/relations_test.rb
  130. +35 −14 activeresource/lib/active_resource/base.rb
  131. +5 −5 activeresource/lib/active_resource/connection.rb
  132. +3 −0 activeresource/lib/active_resource/exceptions.rb
  133. +7 −0 activeresource/test/abstract_unit.rb
  134. +19 −0 activeresource/test/cases/base_test.rb
  135. +1 −1 activeresource/test/cases/finder_test.rb
  136. +1 −1 activeresource/test/cases/format_test.rb
  137. +5 −1 activeresource/test/fixtures/sound.rb
  138. +1 −1 activesupport/lib/active_support/callbacks.rb
  139. +22 −2 activesupport/lib/active_support/configurable.rb
  140. +22 −1 activesupport/lib/active_support/core_ext/class/attribute.rb
  141. +6 −4 activesupport/lib/active_support/core_ext/hash/keys.rb
  142. +13 −6 activesupport/lib/active_support/core_ext/module/attr_internal.rb
  143. +3 −2 activesupport/lib/active_support/core_ext/object/to_param.rb
  144. +8 −0 activesupport/lib/active_support/core_ext/uri.rb
  145. +16 −2 activesupport/lib/active_support/ordered_options.rb
  146. +23 −0 activesupport/test/callbacks_test.rb
  147. +18 −0 activesupport/test/configurable_test.rb
  148. +8 −4 activesupport/test/core_ext/hash_ext_test.rb
  149. +8 −11 railties/guides/source/action_controller_overview.textile
  150. +30 −0 railties/guides/source/action_mailer_basics.textile
  151. +3 −3 railties/guides/source/active_record_querying.textile
  152. +56 −31 railties/guides/source/association_basics.textile
  153. +1 −12 railties/guides/source/caching_with_rails.textile
  154. +18 −11 railties/guides/source/form_helpers.textile
  155. +32 −33 railties/guides/source/layouts_and_rendering.textile
  156. +19 −19 railties/guides/source/routing.textile
  157. +2 −11 railties/lib/rails/application.rb
  158. +1 −0 railties/lib/rails/application/configuration.rb
  159. +55 −0 railties/lib/rails/application/routes_reloader.rb
  160. +18 −1 railties/lib/rails/commands.rb
  161. +1 −1 railties/lib/rails/commands/plugin.rb
  162. +19 −13 railties/lib/rails/engine.rb
  163. +1 −0 railties/lib/rails/generators/rails/app/templates/Gemfile
  164. +16 −3 railties/lib/rails/railtie/configuration.rb
  165. +1 −1 railties/lib/rails/test_unit/railtie.rb
  166. +99 −0 railties/test/railties/engine_test.rb
@@ -409,7 +409,7 @@ def respond_to?(method, *args) #:nodoc:
protected
def set_payload_for_mail(payload, mail) #:nodoc:
- payload[:mailer] = self.name
+ payload[:mailer] = name
payload[:message_id] = mail.message_id
payload[:subject] = mail.subject
payload[:to] = mail.to
@@ -421,11 +421,8 @@ def set_payload_for_mail(payload, mail) #:nodoc:
end
def method_missing(method, *args) #:nodoc:
- if action_methods.include?(method.to_s)
- new(method, *args).message
- else
- super
- end
+ return super unless respond_to?(method)
+ new(method, *args).message
end
end
@@ -18,12 +18,22 @@ class Railtie < Rails::Railtie
options.javascripts_dir ||= paths.public.javascripts.to_a.first
options.stylesheets_dir ||= paths.public.stylesheets.to_a.first
+ # make sure readers methods get compiled
+ options.asset_path ||= nil
+ options.asset_host ||= nil
+
ActiveSupport.on_load(:action_mailer) do
include AbstractController::UrlFor
extend ::AbstractController::Railties::RoutesHelpers.with(app.routes)
include app.routes.mounted_helpers
options.each { |k,v| send("#{k}=", v) }
end
end
+
+ initializer "action_mailer.compile_config_methods" do
+ ActiveSupport.on_load(:action_mailer) do
+ config.compile_methods! if config.respond_to?(:compile_methods!)
+ end
+ end
end
end
View
@@ -18,7 +18,7 @@ Rake::TestTask.new(:test_action_pack) do |t|
# this will not happen automatically and the tests (as a whole) will error
t.test_files = Dir.glob('test/{abstract,controller,dispatch,template}/**/*_test.rb').sort
- #t.warning = true
+ t.warning = true
t.verbose = true
end
@@ -61,13 +61,13 @@ def hidden_actions
def action_methods
@action_methods ||= begin
# All public instance methods of this class, including ancestors
- methods = public_instance_methods(true).map { |m| m.to_s }.to_set -
+ methods = (public_instance_methods(true) -
# Except for public instance methods of Base and its ancestors
- internal_methods.map { |m| m.to_s } +
+ internal_methods +
# Be sure to include shadowed public instance methods of this class
- public_instance_methods(false).map { |m| m.to_s } -
+ public_instance_methods(false)).uniq.map { |x| x.to_s } -
# And always exclude explicitly hidden actions
- hidden_actions
+ hidden_actions.to_a
# Clear out AS callback method pollution
methods.reject { |method| method =~ /_one_time_conditions/ }
@@ -347,8 +347,7 @@ def _default_layout(require_layout = false)
begin
layout_name = _layout if action_has_layout?
rescue NameError => e
- raise NoMethodError,
- "You specified #{@_layout.inspect} as the layout, but no such method was found"
+ raise e, "Could not render layout: #{e.message}"
end
if require_layout && action_has_layout? && !layout_name
@@ -1,7 +1,6 @@
module AbstractController
module UrlFor
extend ActiveSupport::Concern
-
include ActionDispatch::Routing::UrlFor
def _routes
@@ -72,4 +72,5 @@ module ActionController
require 'active_support/core_ext/module/attr_internal'
require 'active_support/core_ext/module/delegation'
require 'active_support/core_ext/name_error'
+require 'active_support/core_ext/uri'
require 'active_support/inflector'
@@ -161,7 +161,7 @@ def initialize(controller, options = {}, infer_extension = true)
def normalize!(path)
path << 'index' if path[-1] == ?/
path << ".#{extension}" if extension and !path.ends_with?(extension)
- URI.unescape(path)
+ URI.parser.unescape(path)
end
end
end
@@ -1,5 +1,4 @@
require 'fileutils'
-require 'uri'
require 'active_support/core_ext/class/attribute_accessors'
module ActionController #:nodoc:
@@ -99,7 +98,7 @@ def caches_page(*actions)
private
def page_cache_file(path)
- name = (path.empty? || path == "/") ? "/index" : URI.unescape(path.chomp('/'))
+ name = (path.empty? || path == "/") ? "/index" : URI.parser.unescape(path.chomp('/'))
name << page_cache_extension unless (name.split('/').last || name).include? '.'
return name
end
@@ -85,6 +85,9 @@ def controller_name
def initialize(*)
@_headers = {"Content-Type" => "text/html"}
@_status = 200
+ @_request = nil
+ @_response = nil
+ @_routes = nil
super
end
@@ -99,7 +102,7 @@ def params=(val)
# Basic implementations for content_type=, location=, and headers are
# provided to reduce the dependency on the RackDelegation module
# in Renderer and Redirector.
-
+
def content_type=(type)
headers["Content-Type"] = type.to_s
end
@@ -96,9 +96,9 @@ def all_application_helpers
def all_helpers_from_path(path)
helpers = []
- Array.wrap(path).each do |path|
- extract = /^#{Regexp.quote(path.to_s)}\/?(.*)_helper.rb$/
- helpers += Dir["#{path}/**/*_helper.rb"].map { |file| file.sub(extract, '\1') }
+ Array.wrap(path).each do |_path|
+ extract = /^#{Regexp.quote(_path.to_s)}\/?(.*)_helper.rb$/
+ helpers += Dir["#{_path}/**/*_helper.rb"].map { |file| file.sub(extract, '\1') }
end
helpers.sort!
helpers.uniq!
@@ -214,7 +214,7 @@ def ha1(credentials, password)
def encode_credentials(http_method, credentials, password, password_is_ha1)
credentials[:response] = expected_response(http_method, credentials[:uri], credentials, password, password_is_ha1)
- "Digest " + credentials.sort_by {|x| x[0].to_s }.inject([]) {|a, v| a << "#{v[0]}='#{v[1]}'" }.join(', ')
+ "Digest " + credentials.sort_by {|x| x[0].to_s }.map {|v| "#{v[0]}='#{v[1]}'" }.join(', ')
end
def decode_credentials_header(request)
@@ -423,14 +423,13 @@ def authenticate(controller, &login_procedure)
# Returns nil if no token is found.
def token_and_options(request)
if header = request.authorization.to_s[/^Token (.*)/]
- values = $1.split(',').
- inject({}) do |memo, value|
- value.strip! # remove any spaces between commas and values
- key, value = value.split(/\=\"?/) # split key=value pairs
- value.chomp!('"') # chomp trailing " in value
- value.gsub!(/\\\"/, '"') # unescape remaining quotes
- memo.update(key => value)
- end
+ values = Hash[$1.split(',').map do |value|
+ value.strip! # remove any spaces between commas and values
+ key, value = value.split(/\=\"?/) # split key=value pairs
+ value.chomp!('"') # chomp trailing " in value
+ value.gsub!(/\\\"/, '"') # unescape remaining quotes
+ [key, value]
+ end]
[values.delete("token"), values.with_indifferent_access]
end
end
@@ -442,9 +441,8 @@ def token_and_options(request)
#
# Returns String.
def encode_credentials(token, options = {})
- values = ["token=#{token.to_s.inspect}"]
- options.each do |key, value|
- values << "#{key}=#{value.to_s.inspect}"
+ values = ["token=#{token.to_s.inspect}"] + options.map do |key, value|
+ "#{key}=#{value.to_s.inspect}"
end
"Token #{values * ", "}"
end
@@ -71,7 +71,7 @@ def self._write_render_options
end
add :json do |json, options|
- json = ActiveSupport::JSON.encode(json, options) unless json.respond_to?(:to_str)
+ json = json.to_json(options) unless json.respond_to?(:to_str)
json = "#{options[:callback]}(#{json})" unless options[:callback].blank?
self.content_type ||= Mime::JSON
self.response_body = json
@@ -5,16 +5,20 @@ module UrlFor
include AbstractController::UrlFor
def url_options
- options = {}
- if _routes.equal?(env["action_dispatch.routes"])
- options[:script_name] = request.script_name.dup
- end
-
- super.merge(options).reverse_merge(
+ @_url_options ||= super.reverse_merge(
:host => request.host_with_port,
:protocol => request.protocol,
:_path_segments => request.symbolized_path_parameters
- )
+ ).freeze
+
+ if _routes.equal?(env["action_dispatch.routes"])
+ @_url_options.dup.tap do |options|
+ options[:script_name] = request.script_name.dup
+ options.freeze
+ end
+ else
+ @_url_options
+ end
end
end
end
@@ -26,12 +26,22 @@ class Railtie < Rails::Railtie
options.stylesheets_dir ||= paths.public.stylesheets.to_a.first
options.page_cache_directory ||= paths.public.to_a.first
+ # make sure readers methods get compiled
+ options.asset_path ||= nil
+ options.asset_host ||= nil
+
ActiveSupport.on_load(:action_controller) do
include app.routes.mounted_helpers
extend ::AbstractController::Railties::RoutesHelpers.with(app.routes)
extend ::ActionController::Railties::Paths.with(app)
options.each { |k,v| send("#{k}=", v) }
end
end
+
+ initializer "action_controller.compile_config_methods" do
+ ActiveSupport.on_load(:action_controller) do
+ config.compile_methods! if config.respond_to?(:compile_methods!)
+ end
+ end
end
end
@@ -127,7 +127,7 @@ def initialize(env = {})
class Result < ::Array #:nodoc:
def to_s() join '/' end
def self.new_escaped(strings)
- new strings.collect {|str| URI.unescape str}
+ new strings.collect {|str| uri_parser.unescape str}
end
end
@@ -394,7 +394,7 @@ def process(action, parameters = nil, session = nil, flash = nil, http_method =
parameters ||= {}
@request.assign_parameters(@routes, @controller.class.name.underscore.sub(/_controller$/, ''), action.to_s, parameters)
- @request.session = ActionController::TestSession.new(session) unless session.nil?
+ @request.session = ActionController::TestSession.new(session) if session
@request.session["flash"] = @request.flash.update(flash || {})
@request.session["flash"].sweep
@@ -417,7 +417,7 @@ def setup_controller_request_and_response
@request.env.delete('PATH_INFO')
- if @controller
+ if defined?(@controller) && @controller
@controller.request = @request
@controller.params = {}
end
@@ -462,9 +462,11 @@ def build_request_uri(action, parameters)
# The exception is stored in the exception accessor for further inspection.
module RaiseActionExceptions
def self.included(base)
- base.class_eval do
- attr_accessor :exception
- protected :exception, :exception=
+ unless base.method_defined?(:exception) && base.method_defined?(:exception=)
+ base.class_eval do
+ attr_accessor :exception
+ protected :exception, :exception=
+ end
end
end
@@ -18,14 +18,14 @@ def initialize(hash)
hash[k] = Conditions.new(v)
when :children
hash[k] = v = keys_to_symbols(v)
- v.each do |k,v2|
- case k
+ v.each do |key,value|
+ case key
when :count, :greater_than, :less_than
# keys are valid, and require no further processing
when :only
- v[k] = Conditions.new(v2)
+ v[key] = Conditions.new(value)
else
- raise "illegal key #{k.inspect} => #{v2.inspect}"
+ raise "illegal key #{key.inspect} => #{value.inspect}"
end
end
else
@@ -54,11 +54,7 @@ def key?(key)
# the application should use), this \method returns the overridden
# value, not the original.
def request_method
- @request_method ||= begin
- method = env["REQUEST_METHOD"]
- HTTP_METHOD_LOOKUP[method] || raise(ActionController::UnknownHttpMethod, "#{method}, accepted HTTP methods are #{HTTP_METHODS.to_sentence(:locale => :en)}")
- method
- end
+ @request_method ||= check_method(env["REQUEST_METHOD"])
end
# Returns a symbol form of the #request_method
@@ -70,11 +66,7 @@ def request_method_symbol
# even if it was overridden by middleware. See #request_method for
# more information.
def method
- @method ||= begin
- method = env["rack.methodoverride.original_method"] || env['REQUEST_METHOD']
- HTTP_METHOD_LOOKUP[method] || raise(ActionController::UnknownHttpMethod, "#{method}, accepted HTTP methods are #{HTTP_METHODS.to_sentence(:locale => :en)}")
- method
- end
+ @method ||= check_method(env["rack.methodoverride.original_method"] || env['REQUEST_METHOD'])
end
# Returns a symbol form of the #method
@@ -246,5 +238,12 @@ def authorization
def local?
LOCALHOST.any? { |local_ip| local_ip === remote_addr && local_ip === remote_ip }
end
+
+ private
+
+ def check_method(name)
+ HTTP_METHOD_LOOKUP[name] || raise(ActionController::UnknownHttpMethod, "#{name}, accepted HTTP methods are #{HTTP_METHODS.to_sentence(:locale => :en)}")
+ name
+ end
end
end
@@ -140,7 +140,6 @@ def to_a
assign_default_content_type_and_charset!
handle_conditional_get!
self["Set-Cookie"] = self["Set-Cookie"].join("\n") if self["Set-Cookie"].respond_to?(:join)
- self["ETag"] = @_etag if @_etag
super
end
@@ -15,12 +15,12 @@ def scheme
# Returns 'https://' if this is an SSL request and 'http://' otherwise.
def protocol
- ssl? ? 'https://' : 'http://'
+ @protocol ||= ssl? ? 'https://' : 'http://'
end
# Is this an SSL request?
def ssl?
- @env['HTTPS'] == 'on' || @env['HTTP_X_FORWARDED_PROTO'] == 'https'
+ @ssl ||= @env['HTTPS'] == 'on' || @env['HTTP_X_FORWARDED_PROTO'] == 'https'
end
# Returns the \host for this request, such as "example.com".
@@ -19,9 +19,11 @@ class Callbacks
# replace the existing callback. Passing an identifier is a suggested
# practice if the code adding a preparation block may be reloaded.
def self.to_prepare(*args, &block)
- if args.first.is_a?(Symbol) && block_given?
- define_method :"__#{args.first}", &block
- set_callback(:prepare, :"__#{args.first}")
+ first_arg = args.first
+ if first_arg.is_a?(Symbol) && block_given?
+ remove_method :"__#{first_arg}" if method_defined?(:"__#{first_arg}")
+ define_method :"__#{first_arg}", &block
+ set_callback(:prepare, :"__#{first_arg}")
else
set_callback(:prepare, *args, &block)
end
Oops, something went wrong.

0 comments on commit 704961c

Please sign in to comment.