Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/rails/rails
Browse files Browse the repository at this point in the history
  • Loading branch information
mikel committed Mar 11, 2010
2 parents cefe723 + 073852d commit f5774e3
Show file tree
Hide file tree
Showing 193 changed files with 2,910 additions and 2,800 deletions.
1 change: 1 addition & 0 deletions Gemfile
@@ -1,6 +1,7 @@
path File.dirname(__FILE__)
source 'http://rubygems.org'

gem "arel", :git => "git://github.com/rails/arel.git"
gem "rails", "3.0.0.beta1"

gem "rake", ">= 0.8.7"
Expand Down
1 change: 1 addition & 0 deletions RAILS_VERSION
@@ -0,0 +1 @@
3.0.0.beta1
16 changes: 7 additions & 9 deletions Rakefile
Expand Up @@ -3,15 +3,6 @@ require 'rake/rdoctask'
require 'rake/gempackagetask'

PROJECTS = %w(activesupport activemodel actionpack actionmailer activeresource activerecord railties)
PROJECTS.each { |project| $:.unshift "#{project}/lib" }

require "active_support/version"
require "active_model/version"
require "action_pack/version"
require "action_mailer/version"
require "active_resource/version"
require "active_record/version"
require "rails/version"

desc 'Run all tests by default'
task :default => %w(test test:isolated)
Expand Down Expand Up @@ -58,6 +49,7 @@ end

desc "Install gems for all projects."
task :install => :gem do
require File.expand_path("../actionpack/lib/action_pack/version", __FILE__)
(PROJECTS - ["railties"]).each do |project|
puts "INSTALLING #{project}"
system("gem install #{project}/pkg/#{project}-#{ActionPack::VERSION::STRING}.gem --no-ri --no-rdoc")
Expand Down Expand Up @@ -130,6 +122,12 @@ task :pdoc => :rdoc do
end

task :update_versions do
require File.dirname(__FILE__) + "/version"

File.open("RAILS_VERSION", "w") do |f|
f.write Rails::VERSION::STRING + "\n"
end

constants = {
"activesupport" => "ActiveSupport",
"activemodel" => "ActiveModel",
Expand Down
7 changes: 3 additions & 4 deletions actionmailer/actionmailer.gemspec
@@ -1,10 +1,9 @@
$:.unshift "lib"
require "action_mailer/version"
version = File.read(File.expand_path("../../RAILS_VERSION", __FILE__)).strip

Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = 'actionmailer'
s.version = ActionMailer::VERSION::STRING
s.version = version
s.summary = 'Email composition, delivery, and receiving framework (part of Rails).'
s.description = 'Email on Rails. Compose, deliver, receive, and test emails using the familiar controller/view pattern. First-class support for multipart email and attachments.'
s.required_ruby_version = '>= 1.8.7'
Expand All @@ -20,7 +19,7 @@ Gem::Specification.new do |s|

s.has_rdoc = true

s.add_dependency('actionpack', "= #{ActionMailer::VERSION::STRING}")
s.add_dependency('actionpack', version)
s.add_dependency('mail', '~> 2.1.3')
s.add_dependency('text-format', '~> 1.0.0')
end
1 change: 1 addition & 0 deletions actionmailer/lib/action_mailer.rb
Expand Up @@ -34,6 +34,7 @@
require 'active_support/core_ext/module/attr_internal'
require 'active_support/core_ext/module/delegation'
require 'active_support/core_ext/string/inflections'
require 'active_support/lazy_load_hooks'

module ActionMailer
extend ::ActiveSupport::Autoload
Expand Down
18 changes: 8 additions & 10 deletions actionmailer/lib/action_mailer/base.rb
Expand Up @@ -267,11 +267,9 @@ class Base < AbstractController::Base

include AbstractController::Logger
include AbstractController::Rendering
include AbstractController::DetailsCache
include AbstractController::Layouts
include AbstractController::Helpers
include AbstractController::Translation
include AbstractController::Compatibility

helper ActionMailer::MailHelper

Expand All @@ -291,6 +289,8 @@ class Base < AbstractController::Base
:parts_order => [ "text/plain", "text/enriched", "text/html" ]
}.freeze

ActionMailer.run_base_hooks(self)

class << self

def mailer_name
Expand Down Expand Up @@ -616,14 +616,12 @@ def collect_responses_and_parts_order(headers) #:nodoc:

def each_template(paths, name, &block) #:nodoc:
Array(paths).each do |path|
self.class.view_paths.each do |load_paths|
templates = load_paths.find_all(name, {}, path)
templates = templates.uniq_by { |t| t.details[:formats] }

unless templates.empty?
templates.each(&block)
return
end
templates = lookup_context.find_all(name, path)
templates = templates.uniq_by { |t| t.formats }

unless templates.empty?
templates.each(&block)
return
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion actionmailer/lib/action_mailer/old_api.rb
Expand Up @@ -206,7 +206,7 @@ def create_parts
if String === @body
@parts.unshift create_inline_part(@body)
elsif @parts.empty? || @parts.all? { |p| p.content_disposition =~ /^attachment/ }
self.class.view_paths.first.find_all(@template, {}, @mailer_name).each do |template|
lookup_context.find_all(@template, @mailer_name).each do |template|
@parts << create_inline_part(render(:_template => template), template.mime_type)
end

Expand Down
2 changes: 1 addition & 1 deletion actionmailer/lib/action_mailer/quoting.rb
Expand Up @@ -22,7 +22,7 @@ def quoted_printable_encode(character)
# A quick-and-dirty regexp for determining whether a string contains any
# characters that need escaping.
if !defined?(CHARS_NEEDING_QUOTING)
CHARS_NEEDING_QUOTING = /[\000-\011\013\014\016-\037\177-\377]/
CHARS_NEEDING_QUOTING = Regexp.new('[\000-\011\013\014\016-\037\177-\377]', nil, 'n')
end

# Quote the given text if it contains any "illegal" characters
Expand Down
10 changes: 6 additions & 4 deletions actionmailer/lib/action_mailer/railtie.rb
Expand Up @@ -6,19 +6,21 @@ class Railtie < Rails::Railtie
railtie_name :action_mailer

initializer "action_mailer.url_for", :before => :load_environment_config do |app|
ActionMailer::Base.send(:include, app.routes.url_helpers)
ActionMailer.base_hook { include app.routes.url_helpers }
end

require "action_mailer/railties/log_subscriber"
log_subscriber ActionMailer::Railties::LogSubscriber.new

initializer "action_mailer.logger" do
ActionMailer::Base.logger ||= Rails.logger
ActionMailer.base_hook { self.logger ||= Rails.logger }
end

initializer "action_mailer.set_configs" do |app|
app.config.action_mailer.each do |k,v|
ActionMailer::Base.send "#{k}=", v
ActionMailer.base_hook do
app.config.action_mailer.each do |k,v|
send "#{k}=", v
end
end
end
end
Expand Down
6 changes: 5 additions & 1 deletion actionmailer/test/log_subscriber_test.rb
Expand Up @@ -4,7 +4,11 @@

class AMLogSubscriberTest < ActionMailer::TestCase
include Rails::LogSubscriber::TestHelper
Rails::LogSubscriber.add(:action_mailer, ActionMailer::Railties::LogSubscriber.new)

def setup
super
Rails::LogSubscriber.add(:action_mailer, ActionMailer::Railties::LogSubscriber.new)
end

class TestMailer < ActionMailer::Base
def basic
Expand Down
9 changes: 6 additions & 3 deletions actionmailer/test/old_base/asset_host_test.rb
Expand Up @@ -14,20 +14,23 @@ def setup
set_delivery_method :test
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.deliveries.clear
AssetHostMailer.configure do |c|
c.asset_host = "http://www.example.com"
c.assets_dir = ''
end
end

def teardown
restore_delivery_method
end

def test_asset_host_as_string
ActionController::Base.asset_host = "http://www.example.com"
mail = AssetHostMailer.email_with_asset
assert_equal "<img alt=\"Somelogo\" src=\"http://www.example.com/images/somelogo.png\" />", mail.body.to_s.strip
end

def test_asset_host_as_one_arguement_proc
ActionController::Base.asset_host = Proc.new { |source|
AssetHostMailer.config.asset_host = Proc.new { |source|
if source.starts_with?('/images')
"http://images.example.com"
else
Expand All @@ -39,7 +42,7 @@ def test_asset_host_as_one_arguement_proc
end

def test_asset_host_as_two_arguement_proc
ActionController::Base.asset_host = Proc.new {|source,request|
ActionController::Base.config.asset_host = Proc.new {|source,request|
if request && request.ssl?
"https://www.example.com"
else
Expand Down
4 changes: 4 additions & 0 deletions actionmailer/test/old_base/url_test.rb
Expand Up @@ -13,6 +13,10 @@ class ActionMailer::Base
class TestMailer < ActionMailer::Base
default_url_options[:host] = 'www.basecamphq.com'

configure do |c|
c.assets_dir = '' # To get the tests to pass
end

def signed_up_with_url(recipient)
@recipients = recipient
@subject = "[Signed up] Welcome #{recipient}"
Expand Down
11 changes: 5 additions & 6 deletions actionpack/actionpack.gemspec
@@ -1,10 +1,9 @@
$:.unshift "lib"
require "action_pack/version"
version = File.read(File.expand_path("../../RAILS_VERSION", __FILE__)).strip

Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = 'actionpack'
s.version = ActionPack::VERSION::STRING
s.version = version
s.summary = 'Web-flow and rendering framework putting the VC in MVC (part of Rails).'
s.description = 'Web apps on Rails. Simple, battle-tested conventions for building and testing MVC web applications. Works with any Rack-compatible server.'
s.required_ruby_version = '>= 1.8.7'
Expand All @@ -20,10 +19,10 @@ Gem::Specification.new do |s|

s.has_rdoc = true

s.add_dependency('activesupport', "= #{ActionPack::VERSION::STRING}")
s.add_dependency('activemodel', "= #{ActionPack::VERSION::STRING}")
s.add_dependency('activesupport', version)
s.add_dependency('activemodel', version)
s.add_dependency('rack', '~> 1.1.0')
s.add_dependency('rack-test', '~> 0.5.0')
s.add_dependency('rack-mount', '~> 0.5.1')
s.add_dependency('rack-mount', '~> 0.6.0')
s.add_dependency('erubis', '~> 2.6.5')
end
4 changes: 2 additions & 2 deletions actionpack/lib/abstract_controller.rb
Expand Up @@ -7,18 +7,18 @@
require 'active_support/core_ext/module/attr_internal'
require 'active_support/core_ext/module/delegation'
require 'active_support/core_ext/module/anonymous'
require 'active_support/i18n'

module AbstractController
extend ActiveSupport::Autoload

autoload :Base
autoload :Callbacks
autoload :Collector
autoload :Compatibility
autoload :DetailsCache
autoload :Helpers
autoload :Layouts
autoload :Logger
autoload :Rendering
autoload :Translation
autoload :ViewPaths
end
16 changes: 12 additions & 4 deletions actionpack/lib/abstract_controller/base.rb
@@ -1,11 +1,12 @@
require 'active_support/ordered_options'

module AbstractController
class Error < StandardError; end
class ActionNotFound < StandardError; end

class Base
attr_internal :response_body
attr_internal :action_name
attr_internal :formats

class << self
attr_reader :abstract
Expand All @@ -28,6 +29,14 @@ def descendants
@descendants ||= []
end

def config
@config ||= ActiveSupport::InheritableOptions.new(superclass < Base ? superclass.config : {})
end

def configure
yield config
end

# A list of all internal methods for a controller. This finds the first
# abstract superclass of a controller, and gets a list of all public
# instance methods on that abstract class. Public instance methods of
Expand Down Expand Up @@ -90,9 +99,8 @@ def controller_path

abstract!

# Initialize controller with nil formats.
def initialize #:nodoc:
@_formats = nil
def config
@config ||= ActiveSupport::InheritableOptions.new(self.class.config)
end

# Calls the action going through the entire action dispatch stack.
Expand Down
18 changes: 0 additions & 18 deletions actionpack/lib/abstract_controller/compatibility.rb

This file was deleted.

48 changes: 0 additions & 48 deletions actionpack/lib/abstract_controller/details_cache.rb

This file was deleted.

0 comments on commit f5774e3

Please sign in to comment.