mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Some merge cleanup
This commit is contained in:
@@ -862,7 +862,7 @@ module ActionController #:nodoc:
|
||||
end
|
||||
|
||||
def close_session
|
||||
@_session.close if @_session && @_session.respond_to?(:close)
|
||||
# @_session.close if @_session && @_session.respond_to?(:close)
|
||||
end
|
||||
|
||||
def default_template(action_name = self.action_name)
|
||||
@@ -895,7 +895,7 @@ module ActionController #:nodoc:
|
||||
Base.class_eval do
|
||||
[ Filters, Layout, Renderer, Redirector, Responder, Benchmarking, Rescue, Flash, MimeResponds, Helpers,
|
||||
Cookies, Caching, Verification, Streaming, SessionManagement,
|
||||
HttpAuthentication::Basic::ControllerMethods, RecordIdentifier,
|
||||
HttpAuthentication::Basic::ControllerMethods, HttpAuthentication::Digest::ControllerMethods, RecordIdentifier,
|
||||
RequestForgeryProtection, Translation
|
||||
].each do |mod|
|
||||
include mod
|
||||
|
||||
@@ -94,25 +94,26 @@ module ActionDispatch
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# Returns the accepted MIME type for the request.
|
||||
def accepts
|
||||
@accepts ||= begin
|
||||
header = @env['HTTP_ACCEPT'].to_s.strip
|
||||
|
||||
fallback = xhr? ? Mime::JS : Mime::HTML
|
||||
fallback = xhr? ? Mime::JS : Mime::HTML
|
||||
|
||||
if header.empty?
|
||||
[content_type, fallback, Mime::ALL].compact
|
||||
else
|
||||
ret = Mime::Type.parse(header)
|
||||
if ret.last == Mime::ALL
|
||||
ret.insert(-2, fallback)
|
||||
if header.empty?
|
||||
[content_type, fallback, Mime::ALL].compact
|
||||
else
|
||||
ret = Mime::Type.parse(header)
|
||||
if ret.last == Mime::ALL
|
||||
ret.insert(-2, fallback)
|
||||
end
|
||||
ret
|
||||
end
|
||||
ret
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def if_modified_since
|
||||
if since = env['HTTP_IF_MODIFIED_SINCE']
|
||||
Time.rfc2822(since) rescue nil
|
||||
|
||||
@@ -177,7 +177,7 @@ class CookieStoreTest < ActionController::IntegrationTest
|
||||
end
|
||||
|
||||
def test_session_store_with_expire_after
|
||||
app = ActionController::Session::CookieStore.new(DispatcherApp, :key => SessionKey, :secret => SessionSecret, :expire_after => 5.hours)
|
||||
app = ActionDispatch::Session::CookieStore.new(DispatcherApp, :key => SessionKey, :secret => SessionSecret, :expire_after => 5.hours)
|
||||
@integration_session = open_session(app)
|
||||
|
||||
with_test_route_set do
|
||||
|
||||
@@ -62,7 +62,7 @@ end
|
||||
|
||||
class RackRequestTest < BaseRackTest
|
||||
test "proxy request" do
|
||||
assert_equal 'glu.ttono.us', @request.host_with_port(true)
|
||||
assert_equal 'glu.ttono.us', @request.host_with_port
|
||||
end
|
||||
|
||||
test "http host" do
|
||||
|
||||
@@ -255,7 +255,7 @@ class RequestTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
test "server software" do
|
||||
assert_equal nil, @request.server_software(true)
|
||||
assert_equal nil, @request.server_software
|
||||
|
||||
@request.env['SERVER_SOFTWARE'] = 'Apache3.422'
|
||||
assert_equal 'apache', @request.server_software
|
||||
|
||||
121
activesupport/test/new_callbacks_test.rb
Normal file
121
activesupport/test/new_callbacks_test.rb
Normal file
@@ -0,0 +1,121 @@
|
||||
# require 'abstract_unit'
|
||||
require 'test/unit'
|
||||
$:.unshift "#{File.dirname(__FILE__)}/../lib"
|
||||
require 'active_support'
|
||||
|
||||
class Record
|
||||
include ActiveSupport::Callbacks
|
||||
define_callbacks :save
|
||||
end
|
||||
|
||||
class AroundPerson < Record
|
||||
attr_reader :history
|
||||
|
||||
save_callback :before, :nope, :if => :no
|
||||
save_callback :before, :nope, :unless => :yes
|
||||
save_callback :after, :tweedle
|
||||
save_callback :before, "tweedle_dee"
|
||||
save_callback :before, proc {|m| m.history << "yup" }
|
||||
save_callback :before, :nope, :if => proc { false }
|
||||
save_callback :before, :nope, :unless => proc { true }
|
||||
save_callback :before, :yup, :if => proc { true }
|
||||
save_callback :before, :yup, :unless => proc { false }
|
||||
save_callback :around, :tweedle_dum
|
||||
save_callback :around, :w0tyes, :if => :yes
|
||||
save_callback :around, :w0tno, :if => :no
|
||||
save_callback :around, :tweedle_deedle
|
||||
|
||||
def no; false; end
|
||||
def yes; true; end
|
||||
|
||||
def nope
|
||||
@history << "boom"
|
||||
end
|
||||
|
||||
def yup
|
||||
@history << "yup"
|
||||
end
|
||||
|
||||
def w0tyes
|
||||
@history << "w0tyes before"
|
||||
yield
|
||||
@history << "w0tyes after"
|
||||
end
|
||||
|
||||
def w0tno
|
||||
@history << "boom"
|
||||
yield
|
||||
end
|
||||
|
||||
def tweedle_dee
|
||||
@history << "tweedle dee"
|
||||
end
|
||||
|
||||
def tweedle_dum
|
||||
@history << "tweedle dum pre"
|
||||
yield
|
||||
@history << "tweedle dum post"
|
||||
end
|
||||
|
||||
def tweedle
|
||||
@history << "tweedle"
|
||||
end
|
||||
|
||||
def tweedle_deedle
|
||||
@history << "tweedle deedle pre"
|
||||
yield
|
||||
@history << "tweedle deedle post"
|
||||
end
|
||||
|
||||
def initialize
|
||||
@history = []
|
||||
end
|
||||
|
||||
def save
|
||||
_run_save_callbacks do
|
||||
@history << "running"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Foo
|
||||
include ActiveSupport::Callbacks
|
||||
define_callbacks :save
|
||||
end
|
||||
|
||||
class Bar < Foo
|
||||
save_callback(:before) {|s| puts "Before" }
|
||||
end
|
||||
|
||||
class Baz < Bar
|
||||
save_callback(:after) {|s| puts "After"}
|
||||
end
|
||||
|
||||
class Bat < Baz
|
||||
def inside
|
||||
_run_save_callbacks do
|
||||
puts "Inside"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Bat.new.inside
|
||||
|
||||
# class AroundCallbacksTest < Test::Unit::TestCase
|
||||
# def test_save_around
|
||||
# around = AroundPerson.new
|
||||
# around.save
|
||||
# assert_equal [
|
||||
# "tweedle dee",
|
||||
# "yup", "yup", "yup",
|
||||
# "tweedle dum pre",
|
||||
# "w0tyes before",
|
||||
# "tweedle deedle pre",
|
||||
# "running",
|
||||
# "tweedle deedle post",
|
||||
# "w0tyes after",
|
||||
# "tweedle dum post",
|
||||
# "tweedle"
|
||||
# ], around.history
|
||||
# end
|
||||
# end
|
||||
Reference in New Issue
Block a user