Permalink
Browse files

Merge branch 'master' into cherry

Conflicts:
	activesupport/CHANGELOG
	activesupport/lib/active_support/core_ext/class/delegating_attributes.rb
	activesupport/lib/active_support/core_ext/hash/conversions.rb
	activesupport/lib/active_support/core_ext/module/attribute_accessors.rb
	activesupport/lib/active_support/core_ext/string/multibyte.rb
	activesupport/lib/active_support/core_ext/time/calculations.rb
	activesupport/lib/active_support/deprecation.rb
  • Loading branch information...
2 parents db05c73 + 164a94d commit 685a53a360d0d8fc4a9f3b49f900621c940a71f2 @jeremy jeremy committed Apr 21, 2009
Showing 321 changed files with 6,746 additions and 3,022 deletions.
View
@@ -14,6 +14,7 @@ railties/pkg
railties/test/500.html
railties/doc/guides/html/images
railties/doc/guides/html/stylesheets
+benches
railties/guides/output
*.rbc
*.swp
@@ -373,6 +373,14 @@ def mailer_name=(value)
attr_reader :mail
attr_reader :template_name, :default_template_name, :action_name
+ def controller_path
+ self.class.controller_path
+ end
+
+ def formats
+ @template.formats
+ end
+
class << self
attr_writer :mailer_name
@@ -466,7 +474,7 @@ def create!(method_name, *parameters) #:nodoc:
# have not already been specified manually.
if @parts.empty?
Dir.glob("#{template_path}/#{@template}.*").each do |path|
- template = template_root["#{mailer_name}/#{File.basename(path)}"]
+ template = template_root.find_by_parts("#{mailer_name}/#{File.basename(path)}")
# Skip unless template has a multipart format
next unless template && template.multipart?
@@ -475,7 +483,7 @@ def create!(method_name, *parameters) #:nodoc:
:content_type => template.content_type,
:disposition => "inline",
:charset => charset,
- :body => render_message(template, @body)
+ :body => render_template(template, @body)
)
end
unless @parts.empty?
@@ -489,7 +497,7 @@ def create!(method_name, *parameters) #:nodoc:
# normal template exists (or if there were no implicit parts) we render
# it.
template_exists = @parts.empty?
- template_exists ||= template_root["#{mailer_name}/#{@template}"]
+ template_exists ||= template_root.find_by_parts("#{mailer_name}/#{@template}")
@body = render_message(@template, @body) if template_exists
# Finally, if there are other message parts and a textual body exists,
@@ -514,6 +522,7 @@ def create!(method_name, *parameters) #:nodoc:
# no alternate has been given as the parameter, this will fail.
def deliver!(mail = @mail)
raise "no mail object available for delivery!" unless mail
+
unless logger.nil?
logger.info "Sent mail to #{Array(recipients).join(', ')}"
logger.debug "\n#{mail.encoded}"
@@ -545,27 +554,43 @@ def initialize_defaults(method_name)
@mime_version = @@default_mime_version.dup if @@default_mime_version
end
- def render_message(method_name, body)
- if method_name.respond_to?(:content_type)
- @current_template_content_type = method_name.content_type
+ def render_template(template, body)
+ if template.respond_to?(:content_type)
+ @current_template_content_type = template.content_type
end
+
+ @template = initialize_template_class(body)
+ layout = _pick_layout(layout, true) unless template.exempt_from_layout?
+ @template._render_template_with_layout(template, layout, {})
+ ensure
+ @current_template_content_type = nil
+ end
+
+ def render_message(method_name, body)
render :file => method_name, :body => body
ensure
@current_template_content_type = nil
end
def render(opts)
- body = opts.delete(:body)
- if opts[:file] && (opts[:file] !~ /\// && !opts[:file].respond_to?(:render))
- opts[:file] = "#{mailer_name}/#{opts[:file]}"
- end
-
+ layout, file = opts.delete(:layout), opts[:file]
+
begin
- old_template, @template = @template, initialize_template_class(body)
- layout = respond_to?(:pick_layout, true) ? pick_layout(opts) : false
- @template.render(opts.merge(:layout => layout))
- ensure
- @template = old_template
+ @template = initialize_template_class(opts.delete(:body))
+
+ if file
+ prefix = mailer_name unless file =~ /\//
+ template = view_paths.find_by_parts(file, formats, prefix)
+ end
+
+ layout = _pick_layout(layout,
+ !template || !template.exempt_from_layout?)
+
+ if template
+ @template._render_template_with_layout(template, layout, opts)
+ elsif inline = opts[:inline]
+ @template._render_inline(inline, layout, opts)
+ end
end
end
@@ -577,12 +602,6 @@ def default_template_format
end
end
- def candidate_for_layout?(options)
- !self.view_paths.find_template(default_template_name, default_template_format).exempt_from_layout?
- rescue ActionView::MissingTemplate
- return true
- end
-
def template_root
self.class.template_root
end
@@ -597,7 +616,7 @@ def template_path
def initialize_template_class(assigns)
template = ActionView::Base.new(self.class.view_paths, assigns, self)
- template.template_format = default_template_format
+ template.formats = [default_template_format]
template
end
@@ -19,7 +19,6 @@
$:.unshift "#{File.dirname(__FILE__)}/fixtures/helpers"
-ActionView::Base.cache_template_loading = true
FIXTURE_LOAD_PATH = File.join(File.dirname(__FILE__), 'fixtures')
ActionMailer::Base.template_root = FIXTURE_LOAD_PATH
@@ -565,13 +565,31 @@ def test_performs_delivery_via_sendmail
TestMailer.deliver_signed_up(@recipient)
end
+ class FakeLogger
+ attr_reader :info_contents, :debug_contents
+
+ def initialize
+ @info_contents, @debug_contents = "", ""
+ end
+
+ def info(str)
+ @info_contents << str
+ end
+
+ def debug(str)
+ @debug_contents << str
+ end
+ end
+
def test_delivery_logs_sent_mail
mail = TestMailer.create_signed_up(@recipient)
- logger = mock()
- logger.expects(:info).with("Sent mail to #{@recipient}")
- logger.expects(:debug).with("\n#{mail.encoded}")
- TestMailer.logger = logger
+ # logger = mock()
+ # logger.expects(:info).with("Sent mail to #{@recipient}")
+ # logger.expects(:debug).with("\n#{mail.encoded}")
+ TestMailer.logger = FakeLogger.new
TestMailer.deliver_signed_up(@recipient)
+ assert(TestMailer.logger.info_contents =~ /Sent mail to #{@recipient}/)
+ assert_equal(TestMailer.logger.debug_contents, "\n#{mail.encoded}")
end
def test_unquote_quoted_printable_subject
View
@@ -1,7 +1,14 @@
+*Edge*
+
+* Fixed that TestResponse.cookies was returning cookies unescaped #1867 [Doug McInnes]
+
+
*2.3.2 [Final] (March 15, 2009)*
* Fixed that redirection would just log the options, not the final url (which lead to "Redirected to #<Post:0x23150b8>") [DHH]
+* Don't check authenticity tokens for any AJAX requests [Ross Kaffenberger/Bryan Helmkamp]
+
* Added ability to pass in :public => true to fresh_when, stale?, and expires_in to make the request proxy cachable #2095 [Gregg Pollack]
* Fixed that passing a custom form builder would be forwarded to nested fields_for calls #2023 [Eloy Duran/Nate Wiger]
View
@@ -30,7 +30,7 @@ Rake::TestTask.new(:test_action_pack) do |t|
# make sure we include the tests in alphabetical order as on some systems
# this will not happen automatically and the tests (as a whole) will error
- t.test_files = Dir.glob( "test/[cft]*/**/*_test.rb" ).sort
+ t.test_files = Dir.glob( "test/[cdft]*/**/*_test.rb" ).sort
t.verbose = true
#t.warning = true
@@ -31,86 +31,59 @@
end
end
-begin
- gem 'rack', '~> 1.0.0'
- require 'rack'
-rescue Gem::LoadError
- require 'action_controller/vendor/rack-1.0/rack'
-end
+require File.join(File.dirname(__FILE__), "action_pack")
module ActionController
# TODO: Review explicit to see if they will automatically be handled by
# the initilizer if they are really needed.
def self.load_all!
- [Base, CGIHandler, CgiRequest, Request, Response, Http::Headers, UrlRewriter, UrlWriter]
+ [Base, Request, Response, UrlRewriter, UrlWriter]
+ [ActionDispatch::Http::Headers]
end
- autoload :AbstractRequest, 'action_controller/request'
- autoload :Base, 'action_controller/base'
- autoload :Benchmarking, 'action_controller/benchmarking'
+ autoload :Base, 'action_controller/base/base'
+ autoload :Benchmarking, 'action_controller/base/chained/benchmarking'
autoload :Caching, 'action_controller/caching'
- autoload :Cookies, 'action_controller/cookies'
- autoload :Dispatcher, 'action_controller/dispatcher'
- autoload :Failsafe, 'action_controller/failsafe'
- autoload :Filters, 'action_controller/filters'
- autoload :Flash, 'action_controller/flash'
- autoload :Helpers, 'action_controller/helpers'
- autoload :HttpAuthentication, 'action_controller/http_authentication'
- autoload :Integration, 'action_controller/integration'
- autoload :IntegrationTest, 'action_controller/integration'
- autoload :Layout, 'action_controller/layout'
- autoload :MiddlewareStack, 'action_controller/middleware_stack'
- autoload :MimeResponds, 'action_controller/mime_responds'
- autoload :ParamsParser, 'action_controller/params_parser'
- autoload :PolymorphicRoutes, 'action_controller/polymorphic_routes'
+ autoload :Cookies, 'action_controller/base/cookies'
+ autoload :Dispatcher, 'action_controller/dispatch/dispatcher'
+ autoload :Filters, 'action_controller/base/chained/filters'
+ autoload :Flash, 'action_controller/base/chained/flash'
+ autoload :Helpers, 'action_controller/base/helpers'
+ autoload :HttpAuthentication, 'action_controller/base/http_authentication'
+ autoload :Integration, 'action_controller/testing/integration'
+ autoload :IntegrationTest, 'action_controller/testing/integration'
+ autoload :Layout, 'action_controller/base/layout'
+ autoload :MimeResponds, 'action_controller/base/mime_responds'
+ autoload :PolymorphicRoutes, 'action_controller/routing/generation/polymorphic_routes'
autoload :RecordIdentifier, 'action_controller/record_identifier'
- autoload :Reloader, 'action_controller/reloader'
- autoload :Request, 'action_controller/request'
- autoload :RequestForgeryProtection, 'action_controller/request_forgery_protection'
- autoload :Rescue, 'action_controller/rescue'
- autoload :Resources, 'action_controller/resources'
- autoload :Response, 'action_controller/response'
- autoload :RewindableInput, 'action_controller/rewindable_input'
+ autoload :Redirector, 'action_controller/base/redirect'
+ autoload :Renderer, 'action_controller/base/render'
+ autoload :RequestForgeryProtection, 'action_controller/base/request_forgery_protection'
+ autoload :Rescue, 'action_controller/dispatch/rescue'
+ autoload :Resources, 'action_controller/routing/resources'
+ autoload :Responder, 'action_controller/base/responder'
autoload :Routing, 'action_controller/routing'
- autoload :SessionManagement, 'action_controller/session_management'
- autoload :StatusCodes, 'action_controller/status_codes'
- autoload :Streaming, 'action_controller/streaming'
- autoload :TestCase, 'action_controller/test_case'
- autoload :TestProcess, 'action_controller/test_process'
+ autoload :SessionManagement, 'action_controller/base/session_management'
+ autoload :Streaming, 'action_controller/base/streaming'
+ autoload :TestCase, 'action_controller/testing/test_case'
+ autoload :TestProcess, 'action_controller/testing/process'
autoload :Translation, 'action_controller/translation'
- autoload :UploadedFile, 'action_controller/uploaded_file'
- autoload :UploadedStringIO, 'action_controller/uploaded_file'
- autoload :UploadedTempfile, 'action_controller/uploaded_file'
- autoload :UrlRewriter, 'action_controller/url_rewriter'
- autoload :UrlWriter, 'action_controller/url_rewriter'
- autoload :Verification, 'action_controller/verification'
+ autoload :UrlEncodedPairParser, 'action_controller/dispatch/url_encoded_pair_parser'
+ autoload :UrlRewriter, 'action_controller/routing/generation/url_rewriter'
+ autoload :UrlWriter, 'action_controller/routing/generation/url_rewriter'
+ autoload :Verification, 'action_controller/base/verification'
module Assertions
- autoload :DomAssertions, 'action_controller/assertions/dom_assertions'
- autoload :ModelAssertions, 'action_controller/assertions/model_assertions'
- autoload :ResponseAssertions, 'action_controller/assertions/response_assertions'
- autoload :RoutingAssertions, 'action_controller/assertions/routing_assertions'
- autoload :SelectorAssertions, 'action_controller/assertions/selector_assertions'
- autoload :TagAssertions, 'action_controller/assertions/tag_assertions'
- end
-
- module Http
- autoload :Headers, 'action_controller/headers'
+ autoload :DomAssertions, 'action_controller/testing/assertions/dom'
+ autoload :ModelAssertions, 'action_controller/testing/assertions/model'
+ autoload :ResponseAssertions, 'action_controller/testing/assertions/response'
+ autoload :RoutingAssertions, 'action_controller/testing/assertions/routing'
+ autoload :SelectorAssertions, 'action_controller/testing/assertions/selector'
+ autoload :TagAssertions, 'action_controller/testing/assertions/tag'
end
-
- module Session
- autoload :AbstractStore, 'action_controller/session/abstract_store'
- autoload :CookieStore, 'action_controller/session/cookie_store'
- autoload :MemCacheStore, 'action_controller/session/mem_cache_store'
- end
-
- # DEPRECATE: Remove CGI support
- autoload :CgiRequest, 'action_controller/cgi_process'
- autoload :CGIHandler, 'action_controller/cgi_process'
end
-autoload :Mime, 'action_controller/mime_type'
-
autoload :HTML, 'action_controller/vendor/html-scanner'
+require 'action_dispatch'
require 'action_view'
@@ -0,0 +1,10 @@
+module AbstractController
+ autoload :Base, "action_controller/abstract/base"
+ autoload :Callbacks, "action_controller/abstract/callbacks"
+ autoload :Helpers, "action_controller/abstract/helpers"
+ autoload :Layouts, "action_controller/abstract/layouts"
+ autoload :Logger, "action_controller/abstract/logger"
+ autoload :Renderer, "action_controller/abstract/renderer"
+ # === Exceptions
+ autoload :ActionNotFound, "action_controller/abstract/exceptions"
+end
@@ -0,0 +1,41 @@
+module AbstractController
+ class Base
+
+ attr_internal :response_body
+ attr_internal :response_obj
+ attr_internal :action_name
+
+ def self.process(action)
+ new.process(action)
+ end
+
+ def self.inherited(klass)
+ end
+
+ def initialize
+ self.response_obj = {}
+ end
+
+ def process(action_name)
+ unless respond_to_action?(action_name)
+ raise ActionNotFound, "The action '#{action_name}' could not be found"
+ end
+
+ @_action_name = action_name
+ process_action
+ self.response_obj[:body] = self.response_body
+ self
+ end
+
+ private
+
+ def process_action
+ respond_to?(action_name) ? send(action_name) : send(:action_missing, action_name)
+ end
+
+ def respond_to_action?(action_name)
+ respond_to?(action_name) || respond_to?(:action_missing, true)
+ end
+
+ end
+end
Oops, something went wrong.

0 comments on commit 685a53a

Please sign in to comment.