Skip to content

Commit 906aebc

Browse files
committed
Bring abstract_controller up to date with rails/master
Resolved all the conflicts since 2.3.0 -> HEAD. Following is a list of commits that could not be applied cleanly or are obviated with the abstract_controller refactor. They all need to be revisited to ensure that fixes made in 2.3 do not reappear in 3.0: 2259ecf AR not available * This will be reimplemented with ActionORM or equivalent 06182ea implicitly rendering a js response should not use the default layout [rails#1844 state:resolved] * This will be handled generically 893e9eb Improve view rendering performance in development mode and reinstate template recompiling in production [rails#1909 state:resolved] * We will need to reimplement rails-dev-boost on top of the refactor; the changes here are very implementation specific and cannot be cleanly applied. The following commits are implicated: 199e750 3942cb4 f8ea9f8 e3b166a ae9f258 4442312 0cb020b workaround for picking layouts based on wrong view_paths [rails#1974 state:resolved] * The specifics of this commit no longer apply. Since it is a two-line commit, we will reimplement this change. 8c5cc66 make action_controller/layouts pick templates from the current instance's view_paths instead of the class view_paths [rails#1974 state:resolved] * This does not apply at all. It should be trivial to apply the feature to the reimplemented ActionController::Base. 87e8b16 fix HTML fallback for explicit templates [rails#2052 state:resolved] * There were a number of patches related to this that simply compounded each other. Basically none of them apply cleanly, and the underlying issue needs to be revisited. After discussing the underlying problem with Koz, we will defer these fixes for further discussion.
2 parents 2036d3b + c877857 commit 906aebc

File tree

622 files changed

+31620
-41616
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

622 files changed

+31620
-41616
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ railties/test/500.html
1515
railties/doc/guides/html/images
1616
railties/doc/guides/html/stylesheets
1717
benches
18+
railties/guides/output
1819
*.rbc
1920
*.swp
2021
*.swo

actionmailer/CHANGELOG

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
*2.3.0 [Edge]*
1+
*2.3.2 [Final] (March 15, 2009)*
2+
3+
* Fixed that ActionMailer should send correctly formatted Return-Path in MAIL FROM for SMTP #1842 [Matt Jones]
24

35
* Fixed RFC-2045 quoted-printable bug #1421 [squadette]
46

actionmailer/Rakefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ spec = Gem::Specification.new do |s|
5555
s.rubyforge_project = "actionmailer"
5656
s.homepage = "http://www.rubyonrails.org"
5757

58-
s.add_dependency('actionpack', '= 2.3.0' + PKG_BUILD)
58+
s.add_dependency('actionpack', '= 2.3.2' + PKG_BUILD)
5959

6060
s.has_rdoc = true
6161
s.requirements << 'none'

actionmailer/lib/action_mailer.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,5 @@ module Net
5858
end
5959

6060
autoload :MailHelper, 'action_mailer/mail_helper'
61-
autoload :TMail, 'action_mailer/vendor/tmail'
61+
62+
require 'action_mailer/vendor/tmail'

actionmailer/lib/action_mailer/base.rb

+5-3
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,8 @@ class Base
254254
private_class_method :new #:nodoc:
255255

256256
class_inheritable_accessor :view_paths
257+
self.view_paths = []
258+
257259
cattr_accessor :logger
258260

259261
@@smtp_settings = {
@@ -485,7 +487,7 @@ def create!(method_name, *parameters) #:nodoc:
485487
)
486488
end
487489
unless @parts.empty?
488-
@content_type = "multipart/alternative"
490+
@content_type = "multipart/alternative" if @content_type !~ /^multipart/
489491
@parts = sort_parts(@parts, @implicit_parts_order)
490492
end
491493
end
@@ -613,7 +615,7 @@ def template_path
613615
end
614616

615617
def initialize_template_class(assigns)
616-
template = ActionView::Base.new(view_paths, assigns, self)
618+
template = ActionView::Base.new(self.class.view_paths, assigns, self)
617619
template.formats = [default_template_format]
618620
template
619621
end
@@ -691,7 +693,7 @@ def create_mail
691693
def perform_delivery_smtp(mail)
692694
destinations = mail.destinations
693695
mail.ready_to_send
694-
sender = mail['return-path'] || mail.from
696+
sender = (mail['return-path'] && mail['return-path'].spec) || mail.from
695697

696698
smtp = Net::SMTP.new(smtp_settings[:address], smtp_settings[:port])
697699
smtp.enable_starttls_auto if smtp_settings[:enable_starttls_auto] && smtp.respond_to?(:enable_starttls_auto)

actionmailer/lib/action_mailer/part.rb

+4-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,10 @@ def to_mail(defaults)
8888
part.parts << prt
8989
end
9090

91-
part.set_content_type(real_content_type, nil, ctype_attrs) if real_content_type =~ /multipart/
91+
if real_content_type =~ /multipart/
92+
ctype_attrs.delete 'charset'
93+
part.set_content_type(real_content_type, nil, ctype_attrs)
94+
end
9295
end
9396

9497
headers.each { |k,v| part[k] = v }

actionmailer/lib/action_mailer/vendor/text-format-0.6.3/text/format.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1150,7 +1150,7 @@ def test_format_style
11501150
assert_equal(Text::Format::JUSTIFY, @format_o.format_style)
11511151
assert_match(/^of freedom, and that government of the people, by the people, for the$/,
11521152
@format_o.format(GETTYSBURG).split("\n")[-3])
1153-
assert_raises(ArgumentError) { @format_o.format_style = 33 }
1153+
assert_raise(ArgumentError) { @format_o.format_style = 33 }
11541154
end
11551155

11561156
def test_tag_paragraph

actionmailer/lib/action_mailer/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module ActionMailer
22
module VERSION #:nodoc:
33
MAJOR = 2
44
MINOR = 3
5-
TINY = 0
5+
TINY = 2
66

77
STRING = [MAJOR, MINOR, TINY].join('.')
88
end

actionmailer/test/abstract_unit.rb

+4-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
require 'rubygems'
12
require 'test/unit'
23

4+
gem 'mocha', '>= 0.9.5'
5+
require 'mocha'
6+
37
$:.unshift "#{File.dirname(__FILE__)}/../lib"
48
$:.unshift "#{File.dirname(__FILE__)}/../../activesupport/lib"
59
$:.unshift "#{File.dirname(__FILE__)}/../../actionpack/lib"
@@ -43,21 +47,13 @@ def self.new(*args)
4347
end
4448

4549
def uses_gem(gem_name, test_name, version = '> 0')
46-
require 'rubygems'
4750
gem gem_name.to_s, version
4851
require gem_name.to_s
4952
yield
5053
rescue LoadError
5154
$stderr.puts "Skipping #{test_name} tests. `gem install #{gem_name}` and try again."
5255
end
5356

54-
# Wrap tests that use Mocha and skip if unavailable.
55-
unless defined? uses_mocha
56-
def uses_mocha(test_name, &block)
57-
uses_gem('mocha', test_name, '>= 0.5.5', &block)
58-
end
59-
end
60-
6157
def set_delivery_method(delivery_method)
6258
@old_delivery_method = ActionMailer::Base.delivery_method
6359
ActionMailer::Base.delivery_method = delivery_method

actionmailer/test/mail_layout_test.rb

+29-1
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ def nolayout(recipient)
2121
body render(:inline => "Hello, <%= @world %>", :layout => false, :body => { :world => "Earth" })
2222
end
2323

24-
def multipart(recipient)
24+
def multipart(recipient, type = nil)
2525
recipients recipient
2626
subject "You have a mail"
2727
28+
29+
content_type(type) if type
2830
end
2931
end
3032

@@ -64,6 +66,19 @@ def test_should_pickup_default_layout
6466

6567
def test_should_pickup_multipart_layout
6668
mail = AutoLayoutMailer.create_multipart(@recipient)
69+
assert_equal "multipart/alternative", mail.content_type
70+
assert_equal 2, mail.parts.size
71+
72+
assert_equal 'text/plain', mail.parts.first.content_type
73+
assert_equal "text/plain layout - text/plain multipart", mail.parts.first.body
74+
75+
assert_equal 'text/html', mail.parts.last.content_type
76+
assert_equal "Hello from layout text/html multipart", mail.parts.last.body
77+
end
78+
79+
def test_should_pickup_multipartmixed_layout
80+
mail = AutoLayoutMailer.create_multipart(@recipient, "multipart/mixed")
81+
assert_equal "multipart/mixed", mail.content_type
6782
assert_equal 2, mail.parts.size
6883

6984
assert_equal 'text/plain', mail.parts.first.content_type
@@ -73,6 +88,19 @@ def test_should_pickup_multipart_layout
7388
assert_equal "Hello from layout text/html multipart", mail.parts.last.body
7489
end
7590

91+
def test_should_fix_multipart_layout
92+
mail = AutoLayoutMailer.create_multipart(@recipient, "text/plain")
93+
assert_equal "multipart/alternative", mail.content_type
94+
assert_equal 2, mail.parts.size
95+
96+
assert_equal 'text/plain', mail.parts.first.content_type
97+
assert_equal "text/plain layout - text/plain multipart", mail.parts.first.body
98+
99+
assert_equal 'text/html', mail.parts.last.content_type
100+
assert_equal "Hello from layout text/html multipart", mail.parts.last.body
101+
end
102+
103+
76104
def test_should_pickup_layout_given_to_render
77105
mail = AutoLayoutMailer.create_spam(@recipient)
78106
assert_equal "Spammer layout Hello, Earth", mail.body.strip

actionmailer/test/mail_service_test.rb

+3-5
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,6 @@ def receive(mail)
289289
end
290290
end
291291

292-
uses_mocha 'ActionMailerTest' do
293-
294292
class ActionMailerTest < Test::Unit::TestCase
295293
include ActionMailer::Quoting
296294

@@ -332,6 +330,7 @@ def test_nested_parts
332330
assert_equal "multipart/mixed", created.content_type
333331
assert_equal "multipart/alternative", created.parts.first.content_type
334332
assert_equal "bar", created.parts.first.header['foo'].to_s
333+
assert_nil created.parts.first.charset
335334
assert_equal "text/plain", created.parts.first.parts.first.content_type
336335
assert_equal "text/html", created.parts.first.parts[1].content_type
337336
assert_equal "application/octet-stream", created.parts[1].content_type
@@ -958,6 +957,7 @@ def test_return_path_with_deliver
958957
ActionMailer::Base.delivery_method = :smtp
959958
TestMailer.deliver_return_path
960959
assert_match %r{^Return-Path: <[email protected]>}, MockSMTP.deliveries[0][0]
960+
assert_equal "[email protected]", MockSMTP.deliveries[0][1].to_s
961961
end
962962

963963
def test_body_is_stored_as_an_ivar
@@ -992,8 +992,6 @@ def test_starttls_is_not_enabled
992992
end
993993
end
994994

995-
end # uses_mocha
996-
997995
class InheritableTemplateRootTest < Test::Unit::TestCase
998996
def test_attr
999997
expected = "#{File.dirname(__FILE__)}/fixtures/path.with.dots"
@@ -1089,7 +1087,7 @@ def test_should_not_respond_to_method_where_deliver_is_not_a_suffix
10891087
end
10901088

10911089
def test_should_still_raise_exception_with_expected_message_when_calling_an_undefined_method
1092-
error = assert_raises NoMethodError do
1090+
error = assert_raise NoMethodError do
10931091
RespondToMailer.not_a_method
10941092
end
10951093

actionmailer/test/test_helper_test.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def test_mailer_class_is_correctly_inferred
2626
end
2727

2828
def test_determine_default_mailer_raises_correct_error
29-
assert_raises(ActionMailer::NonInferrableMailerError) do
29+
assert_raise(ActionMailer::NonInferrableMailerError) do
3030
self.class.determine_default_mailer("NotAMailerTest")
3131
end
3232
end
@@ -84,7 +84,7 @@ def test_assert_no_emails
8484
end
8585

8686
def test_assert_emails_too_few_sent
87-
error = assert_raises ActiveSupport::TestCase::Assertion do
87+
error = assert_raise ActiveSupport::TestCase::Assertion do
8888
assert_emails 2 do
8989
TestHelperMailer.deliver_test
9090
end
@@ -94,7 +94,7 @@ def test_assert_emails_too_few_sent
9494
end
9595

9696
def test_assert_emails_too_many_sent
97-
error = assert_raises ActiveSupport::TestCase::Assertion do
97+
error = assert_raise ActiveSupport::TestCase::Assertion do
9898
assert_emails 1 do
9999
TestHelperMailer.deliver_test
100100
TestHelperMailer.deliver_test
@@ -105,7 +105,7 @@ def test_assert_emails_too_many_sent
105105
end
106106

107107
def test_assert_no_emails_failure
108-
error = assert_raises ActiveSupport::TestCase::Assertion do
108+
error = assert_raise ActiveSupport::TestCase::Assertion do
109109
assert_no_emails do
110110
TestHelperMailer.deliver_test
111111
end

actionpack/CHANGELOG

+32-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,35 @@
1-
*2.3.0 [Edge]*
1+
*Edge*
2+
3+
* Fixed that TestResponse.cookies was returning cookies unescaped #1867 [Doug McInnes]
4+
5+
6+
*2.3.2 [Final] (March 15, 2009)*
7+
8+
* Fixed that redirection would just log the options, not the final url (which lead to "Redirected to #<Post:0x23150b8>") [DHH]
9+
10+
* Added ability to pass in :public => true to fresh_when, stale?, and expires_in to make the request proxy cachable #2095 [Gregg Pollack]
11+
12+
* Fixed that passing a custom form builder would be forwarded to nested fields_for calls #2023 [Eloy Duran/Nate Wiger]
13+
14+
* Form option helpers now support disabled option tags and the use of lambdas for selecting/disabling option tags from collections #837 [Tekin]
15+
16+
* Added partial scoping to TranslationHelper#translate, so if you call translate(".foo") from the people/index.html.erb template, you'll actually be calling I18n.translate("people.index.foo") [DHH]
17+
18+
* Fix a syntax error in current_page?() that was prevent matches against URL's with multiple query parameters #1385, #1868 [chris finne/Andrew White]
19+
20+
* Added localized rescue template when I18n.locale is set (ex: public/404.da.html) #1835 [José Valim]
21+
22+
* Make the form_for and fields_for helpers support the new Active Record nested update options. #1202 [Eloy Duran]
23+
24+
<% form_for @person do |person_form| %>
25+
...
26+
<% person_form.fields_for :projects do |project_fields| %>
27+
<% if project_fields.object.active? %>
28+
Name: <%= project_fields.text_field :name %>
29+
<% end %>
30+
<% end %>
31+
<% end %>
32+
233

334
* Added grouped_options_for_select helper method for wrapping option tags in optgroups. #977 [Jon Crawford]
435

actionpack/Rakefile

+1-2
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ spec = Gem::Specification.new do |s|
8080
s.has_rdoc = true
8181
s.requirements << 'none'
8282

83-
s.add_dependency('activesupport', '= 2.3.0' + PKG_BUILD)
84-
s.add_dependency('rack', '>= 0.9.0')
83+
s.add_dependency('activesupport', '= 2.3.2' + PKG_BUILD)
8584

8685
s.require_path = 'lib'
8786
s.autorequire = 'action_controller'

actionpack/lib/action_controller.rb

+11
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@
3232
end
3333

3434
require File.join(File.dirname(__FILE__), "action_pack")
35+
$:.unshift "#{File.dirname(__FILE__)}/action_controller/vendor/rack-1.0"
36+
begin
37+
gem 'rack', '~> 1.0.0'
38+
require 'rack'
39+
rescue Gem::LoadError
40+
require 'action_controller/vendor/rack-1.0/rack'
41+
end
3542

3643
module ActionController
3744
# TODO: Review explicit to see if they will automatically be handled by
@@ -57,6 +64,7 @@ def self.load_all!
5764
autoload :PolymorphicRoutes, 'action_controller/routing/generation/polymorphic_routes'
5865
autoload :RecordIdentifier, 'action_controller/record_identifier'
5966
autoload :Redirector, 'action_controller/base/redirect'
67+
autoload :Reloader, 'action_controller/reloader'
6068
autoload :Renderer, 'action_controller/base/render'
6169
autoload :RequestForgeryProtection, 'action_controller/base/request_forgery_protection'
6270
autoload :Rescue, 'action_controller/dispatch/rescue'
@@ -72,6 +80,9 @@ def self.load_all!
7280
autoload :UrlRewriter, 'action_controller/routing/generation/url_rewriter'
7381
autoload :UrlWriter, 'action_controller/routing/generation/url_rewriter'
7482
autoload :Verification, 'action_controller/base/verification'
83+
autoload :UploadedFile, 'action_dispatch/utils/uploaded_file'
84+
autoload :UploadedStringIO, 'action_dispatch/utils/uploaded_file'
85+
autoload :UploadedTempfile, 'action_dispatch/utils/uploaded_file'
7586

7687
module Assertions
7788
autoload :DomAssertions, 'action_controller/testing/assertions/dom'

0 commit comments

Comments
 (0)