Skip to content

Commit 73ac06a

Browse files
committed
Merge branch 'master' of [email protected]:mateomurphy/rails
2 parents ad649c2 + 49a84ff commit 73ac06a

File tree

170 files changed

+2832
-1143
lines changed

Some content is hidden

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

170 files changed

+2832
-1143
lines changed

Rakefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
require 'rake'
22
require 'rake/rdoctask'
3-
require 'rake/contrib/sshpublisher'
43

54
env = %(PKG_BUILD="#{ENV['PKG_BUILD']}") if ENV['PKG_BUILD']
65

@@ -13,7 +12,7 @@ end
1312
desc 'Run all tests by default'
1413
task :default => :test
1514

16-
%w(test rdoc pgem package release).each do |task_name|
15+
%w(test isolated_test rdoc pgem package release).each do |task_name|
1716
desc "Run #{task_name} task for all projects"
1817
task task_name do
1918
PROJECTS.each do |project|
@@ -74,6 +73,7 @@ end
7473

7574
desc "Publish API docs for Rails as a whole and for each component"
7675
task :pdoc => :rdoc do
76+
require 'rake/contrib/sshpublisher'
7777
Rake::SshDirPublisher.new("wrath.rubyonrails.org", "public_html/api", "doc/rdoc").upload
7878
PROJECTS.each do |project|
7979
system %(cd #{project} && #{env} #{$0} pdoc)

actionmailer/Rakefile

+6
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ Rake::TestTask.new { |t|
2828
t.warning = false
2929
}
3030

31+
task :isolated_test do
32+
ruby = File.join(*RbConfig::CONFIG.values_at('bindir', 'RUBY_INSTALL_NAME'))
33+
Dir.glob("test/*_test.rb").all? do |file|
34+
system(ruby, '-Ilib:test', file)
35+
end or raise "Failures"
36+
end
3137

3238
# Generate the RDoc documentation
3339
Rake::RDocTask.new { |rdoc|

actionmailer/lib/action_mailer/vendor/tmail.rb

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ module TMail
1212

1313
require 'tmail'
1414

15+
require 'active_support/core_ext/kernel/reporting'
1516
silence_warnings do
1617
TMail::Encoder.const_set("MAX_LINE_LEN", 200)
1718
end

actionpack/Rakefile

+17-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ require 'rake/testtask'
44
require 'rake/rdoctask'
55
require 'rake/packagetask'
66
require 'rake/gempackagetask'
7-
require 'rake/contrib/sshpublisher'
87
require File.join(File.dirname(__FILE__), 'lib', 'action_pack', 'version')
98

109
PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
@@ -23,18 +22,24 @@ task :default => [ :test ]
2322
# Run the unit tests
2423

2524
desc "Run all unit tests"
26-
task :test => [:test_action_pack, :test_active_record_integration]
25+
task :test => [:test_action_pack, :test_active_record_integration, :test_new_base]
2726

2827
Rake::TestTask.new(:test_action_pack) do |t|
2928
t.libs << "test"
3029

3130
# make sure we include the tests in alphabetical order as on some systems
3231
# this will not happen automatically and the tests (as a whole) will error
33-
t.test_files = Dir.glob( "test/[cdft]*/**/*_test.rb" ).sort
32+
t.test_files = Dir.glob( "test/{controller,dispatch,template}/**/*_test.rb" ).sort
3433

3534
t.verbose = true
3635
#t.warning = true
3736
end
37+
task :isolated_test do
38+
ruby = File.join(*RbConfig::CONFIG.values_at('bindir', 'RUBY_INSTALL_NAME'))
39+
Dir.glob("test/{controller,dispatch,template}/**/*_test.rb").all? do |file|
40+
system(ruby, '-Ilib:test', file)
41+
end or raise "Failures"
42+
end
3843

3944
desc 'ActiveRecord Integration Tests'
4045
Rake::TestTask.new(:test_active_record_integration) do |t|
@@ -43,6 +48,13 @@ Rake::TestTask.new(:test_active_record_integration) do |t|
4348
t.verbose = true
4449
end
4550

51+
desc 'New Controller Tests'
52+
Rake::TestTask.new(:test_new_base) do |t|
53+
t.libs << "test"
54+
t.test_files = Dir.glob("test/{abstract_controller,new_base}/*_test.rb")
55+
t.verbose = true
56+
end
57+
4658

4759
# Genereate the RDoc documentation
4860

@@ -136,12 +148,14 @@ task :update_js => [ :update_scriptaculous ]
136148

137149
desc "Publish the API documentation"
138150
task :pgem => [:package] do
151+
require 'rake/contrib/sshpublisher'
139152
Rake::SshFilePublisher.new("gems.rubyonrails.org", "/u/sites/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload
140153
`ssh gems.rubyonrails.org '/u/sites/gems/gemupdate.sh'`
141154
end
142155

143156
desc "Publish the API documentation"
144157
task :pdoc => [:rdoc] do
158+
require 'rake/contrib/sshpublisher'
145159
Rake::SshDirPublisher.new("wrath.rubyonrails.org", "public_html/ap", "doc").upload
146160
end
147161

actionpack/lib/action_controller.rb

+3-10
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,9 @@
2121
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2222
#++
2323

24-
begin
25-
require 'active_support'
26-
rescue LoadError
27-
activesupport_path = "#{File.dirname(__FILE__)}/../../activesupport/lib"
28-
if File.directory?(activesupport_path)
29-
$:.unshift activesupport_path
30-
require 'active_support'
31-
end
32-
end
33-
require 'active_support/core/all'
24+
activesupport_path = "#{File.dirname(__FILE__)}/../../activesupport/lib"
25+
$:.unshift activesupport_path if File.directory?(activesupport_path)
26+
require 'active_support'
3427

3528
require File.join(File.dirname(__FILE__), "action_pack")
3629

actionpack/lib/action_controller/abstract.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ module AbstractController
77
autoload :Renderer, "action_controller/abstract/renderer"
88
# === Exceptions
99
autoload :ActionNotFound, "action_controller/abstract/exceptions"
10-
end
10+
end
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,95 @@
11
module AbstractController
2+
class Error < StandardError; end
3+
4+
class DoubleRenderError < Error
5+
DEFAULT_MESSAGE = "Render and/or redirect were called multiple times in this action. Please note that you may only call render OR redirect, and at most once per action. Also note that neither redirect nor render terminate execution of the action, so if you want to exit an action after redirecting, you need to do something like \"redirect_to(...) and return\"."
6+
7+
def initialize(message = nil)
8+
super(message || DEFAULT_MESSAGE)
9+
end
10+
end
11+
212
class Base
13+
314
attr_internal :response_body
415
attr_internal :response_obj
516
attr_internal :action_name
617

7-
def self.process(action)
8-
new.process(action)
9-
end
18+
class << self
19+
attr_reader :abstract
20+
21+
def abstract!
22+
@abstract = true
23+
end
24+
25+
alias_method :abstract?, :abstract
26+
27+
def internal_methods
28+
controller = self
29+
controller = controller.superclass until controller.abstract?
30+
controller.public_instance_methods(true)
31+
end
32+
33+
def process(action)
34+
new.process(action.to_s)
35+
end
1036

11-
def self.inherited(klass)
37+
def hidden_actions
38+
[]
39+
end
40+
41+
def action_methods
42+
@action_methods ||=
43+
# All public instance methods of this class, including ancestors
44+
public_instance_methods(true).map { |m| m.to_s }.to_set -
45+
# Except for public instance methods of Base and its ancestors
46+
internal_methods.map { |m| m.to_s } +
47+
# Be sure to include shadowed public instance methods of this class
48+
public_instance_methods(false).map { |m| m.to_s } -
49+
# And always exclude explicitly hidden actions
50+
hidden_actions
51+
end
1252
end
13-
53+
54+
abstract!
55+
1456
def initialize
1557
self.response_obj = {}
1658
end
17-
59+
1860
def process(action_name)
1961
unless respond_to_action?(action_name)
2062
raise ActionNotFound, "The action '#{action_name}' could not be found"
2163
end
22-
64+
2365
@_action_name = action_name
2466
process_action
25-
self.response_obj[:body] = self.response_body
2667
self
2768
end
28-
69+
2970
private
71+
72+
def action_methods
73+
self.class.action_methods
74+
end
75+
76+
# It is possible for respond_to?(action_name) to be false and
77+
# respond_to?(:action_missing) to be false if respond_to_action?
78+
# is overridden in a subclass. For instance, ActionController::Base
79+
# overrides it to include the case where a template matching the
80+
# action_name is found.
3081
def process_action
31-
respond_to?(action_name) ? send(action_name) : send(:action_missing, action_name)
82+
if respond_to?(action_name) then send(action_name)
83+
elsif respond_to?(:action_missing, true) then action_missing(action_name)
84+
end
3285
end
33-
86+
87+
# Override this to change the conditions that will raise an
88+
# ActionNotFound error. If you accept a difference case,
89+
# you must handle it by also overriding process_action and
90+
# handling the case.
3491
def respond_to_action?(action_name)
35-
respond_to?(action_name) || respond_to?(:action_missing, true)
92+
action_methods.include?(action_name) || respond_to?(:action_missing, true)
3693
end
3794
end
38-
end
95+
end

actionpack/lib/action_controller/abstract/callbacks.rb

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,27 @@ module Callbacks
55
depends_on ActiveSupport::NewCallbacks
66

77
included do
8-
define_callbacks :process_action
8+
define_callbacks :process_action, "response_body"
99
end
1010

1111
def process_action
1212
_run_process_action_callbacks(action_name) do
1313
super
1414
end
1515
end
16-
16+
1717
module ClassMethods
1818
def _normalize_callback_options(options)
1919
if only = options[:only]
20-
only = Array(only).map {|o| "action_name == :#{o}"}.join(" || ")
20+
only = Array(only).map {|o| "action_name == '#{o}'"}.join(" || ")
2121
options[:per_key] = {:if => only}
2222
end
2323
if except = options[:except]
24-
except = Array(except).map {|e| "action_name == :#{e}"}.join(" || ")
24+
except = Array(except).map {|e| "action_name == '#{e}'"}.join(" || ")
2525
options[:per_key] = {:unless => except}
2626
end
2727
end
28-
28+
2929
[:before, :after, :around].each do |filter|
3030
class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
3131
def #{filter}_filter(*names, &blk)
@@ -40,4 +40,4 @@ def #{filter}_filter(*names, &blk)
4040
end
4141
end
4242
end
43-
end
43+
end
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module AbstractController
22
class ActionNotFound < StandardError ; end
3-
end
3+
end

actionpack/lib/action_controller/abstract/helpers.rb

+7-13
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,26 @@ module Helpers
99
self.master_helper_module = Module.new
1010
end
1111

12-
# def self.included(klass)
13-
# klass.class_eval do
14-
# extlib_inheritable_accessor :master_helper_module
15-
# self.master_helper_module = Module.new
16-
# end
17-
# end
18-
1912
def _action_view
2013
@_action_view ||= begin
2114
av = super
2215
av.helpers.send(:include, master_helper_module)
2316
av
2417
end
2518
end
26-
19+
2720
module ClassMethods
2821
def inherited(klass)
2922
klass.master_helper_module = Module.new
3023
klass.master_helper_module.__send__ :include, master_helper_module
31-
24+
3225
super
3326
end
34-
27+
3528
def add_template_helper(mod)
3629
master_helper_module.module_eval { include mod }
3730
end
38-
31+
3932
def helper_method(*meths)
4033
meths.flatten.each do |meth|
4134
master_helper_module.class_eval <<-ruby_eval, __FILE__, __LINE__ + 1
@@ -45,7 +38,7 @@ def #{meth}(*args, &blk)
4538
ruby_eval
4639
end
4740
end
48-
41+
4942
def helper(*args, &blk)
5043
args.flatten.each do |arg|
5144
case arg
@@ -56,5 +49,6 @@ def helper(*args, &blk)
5649
master_helper_module.module_eval(&blk) if block_given?
5750
end
5851
end
52+
5953
end
60-
end
54+
end

0 commit comments

Comments
 (0)