Skip to content

Commit

Permalink
Merge commit 'mainstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
lifo committed Dec 28, 2008
2 parents aaea12c + a2270ef commit d6c2285
Show file tree
Hide file tree
Showing 47 changed files with 769 additions and 411 deletions.
Expand Up @@ -402,6 +402,7 @@ def assert_select_rjs(*args, &block)
if rjs_type
if rjs_type == :insert
position = args.shift
id = args.shift
insertion = "insert_#{position}".to_sym
raise ArgumentError, "Unknown RJS insertion type #{position}" unless RJS_STATEMENTS[insertion]
statement = "(#{RJS_STATEMENTS[insertion]})"
Expand Down
6 changes: 3 additions & 3 deletions actionpack/lib/action_controller/helpers.rb
Expand Up @@ -163,9 +163,9 @@ def helper(*args, &block)
def helper_method(*methods)
methods.flatten.each do |method|
master_helper_module.module_eval <<-end_eval
def #{method}(*args, &block)
controller.send(%(#{method}), *args, &block)
end
def #{method}(*args, &block) # def current_user(*args, &block)
controller.send(%(#{method}), *args, &block) # controller.send(%(current_user), *args, &block)
end # end
end_eval
end
end
Expand Down
23 changes: 19 additions & 4 deletions actionpack/lib/action_controller/mime_responds.rb
Expand Up @@ -143,12 +143,27 @@ def any(*args, &block)
custom(@mime_type_priority.first, &block)
end
end

def self.generate_method_for_mime(mime)
sym = mime.is_a?(Symbol) ? mime : mime.to_sym
const = sym.to_s.upcase
class_eval <<-RUBY, __FILE__, __LINE__ + 1
def #{sym}(&block) # def html(&block)
custom(Mime::#{const}, &block) # custom(Mime::HTML, &block)
end # end
RUBY
end

def method_missing(symbol, &block)
mime_constant = symbol.to_s.upcase
Mime::SET.each do |mime|
generate_method_for_mime(mime)
end

if Mime::SET.include?(Mime.const_get(mime_constant))
custom(Mime.const_get(mime_constant), &block)
def method_missing(symbol, &block)
mime_constant = Mime.const_get(symbol.to_s.upcase)

if Mime::SET.include?(mime_constant)
self.class.generate_method_for_mime(mime_constant)
send(symbol, &block)
else
super
end
Expand Down
18 changes: 11 additions & 7 deletions actionpack/lib/action_controller/polymorphic_routes.rb
Expand Up @@ -118,13 +118,17 @@ def polymorphic_path(record_or_hash_or_array, options = {})

%w(edit new).each do |action|
module_eval <<-EOT, __FILE__, __LINE__
def #{action}_polymorphic_url(record_or_hash, options = {})
polymorphic_url(record_or_hash, options.merge(:action => "#{action}"))
end
def #{action}_polymorphic_path(record_or_hash, options = {})
polymorphic_url(record_or_hash, options.merge(:action => "#{action}", :routing_type => :path))
end
def #{action}_polymorphic_url(record_or_hash, options = {}) # def edit_polymorphic_url(record_or_hash, options = {})
polymorphic_url( # polymorphic_url(
record_or_hash, # record_or_hash,
options.merge(:action => "#{action}")) # options.merge(:action => "edit"))
end # end
#
def #{action}_polymorphic_path(record_or_hash, options = {}) # def edit_polymorphic_path(record_or_hash, options = {})
polymorphic_url( # polymorphic_url(
record_or_hash, # record_or_hash,
options.merge(:action => "#{action}", :routing_type => :path)) # options.merge(:action => "edit", :routing_type => :path))
end # end
EOT
end

Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_controller/request.rb
Expand Up @@ -288,7 +288,7 @@ def raw_host_with_port
if forwarded = env["HTTP_X_FORWARDED_HOST"]
forwarded.split(/,\s?/).last
else
env['HTTP_HOST'] || env['SERVER_NAME'] || "#{env['SERVER_ADDR']}:#{env['SERVER_PORT']}"
env['HTTP_HOST'] || "#{env['SERVER_NAME'] || env['SERVER_ADDR']}:#{env['SERVER_PORT']}"
end
end

Expand Down
61 changes: 31 additions & 30 deletions actionpack/lib/action_controller/routing/route_set.rb
Expand Up @@ -145,10 +145,10 @@ def named_helper_module_eval(code, *args)
def define_hash_access(route, name, kind, options)
selector = hash_access_name(name, kind)
named_helper_module_eval <<-end_eval # We use module_eval to avoid leaks
def #{selector}(options = nil)
options ? #{options.inspect}.merge(options) : #{options.inspect}
end
protected :#{selector}
def #{selector}(options = nil) # def hash_for_users_url(options = nil)
options ? #{options.inspect}.merge(options) : #{options.inspect} # options ? {:only_path=>false}.merge(options) : {:only_path=>false}
end # end
protected :#{selector} # protected :hash_for_users_url
end_eval
helpers << selector
end
Expand All @@ -173,32 +173,33 @@ def define_url_helper(route, name, kind, options)
# foo_url(bar, baz, bang, :sort_by => 'baz')
#
named_helper_module_eval <<-end_eval # We use module_eval to avoid leaks
def #{selector}(*args)
#{generate_optimisation_block(route, kind)}
opts = if args.empty? || Hash === args.first
args.first || {}
else
options = args.extract_options!
args = args.zip(#{route.segment_keys.inspect}).inject({}) do |h, (v, k)|
h[k] = v
h
end
options.merge(args)
end
url_for(#{hash_access_method}(opts))
end
#Add an alias to support the now deprecated formatted_* URL.
def formatted_#{selector}(*args)
ActiveSupport::Deprecation.warn(
"formatted_#{selector}() has been deprecated. please pass format to the standard" +
"#{selector}() method instead.", caller)
#{selector}(*args)
end
protected :#{selector}
def #{selector}(*args) # def users_url(*args)
#
#{generate_optimisation_block(route, kind)} # #{generate_optimisation_block(route, kind)}
#
opts = if args.empty? || Hash === args.first # opts = if args.empty? || Hash === args.first
args.first || {} # args.first || {}
else # else
options = args.extract_options! # options = args.extract_options!
args = args.zip(#{route.segment_keys.inspect}).inject({}) do |h, (v, k)| # args = args.zip([]).inject({}) do |h, (v, k)|
h[k] = v # h[k] = v
h # h
end # end
options.merge(args) # options.merge(args)
end # end
#
url_for(#{hash_access_method}(opts)) # url_for(hash_for_users_url(opts))
#
end # end
#Add an alias to support the now deprecated formatted_* URL. # #Add an alias to support the now deprecated formatted_* URL.
def formatted_#{selector}(*args) # def formatted_users_url(*args)
ActiveSupport::Deprecation.warn( # ActiveSupport::Deprecation.warn(
"formatted_#{selector}() has been deprecated. " + # "formatted_users_url() has been deprecated. " +
"please pass format to the standard" + # "please pass format to the standard" +
"#{selector}() method instead.", caller) # "users_url() method instead.", caller)
#{selector}(*args) # users_url(*args)
end # end
protected :#{selector} # protected :users_url
end_eval
helpers << selector
end
Expand Down
6 changes: 1 addition & 5 deletions actionpack/lib/action_controller/test_process.rb
Expand Up @@ -33,11 +33,7 @@ class TestRequest < Request #:nodoc:
attr_accessor :host

def initialize
env = Rack::MockRequest.env_for("/")

# TODO: Fix Request to assume env['SERVER_ADDR'] doesn't contain port number
env['SERVER_ADDR'] = env.delete("SERVER_NAME")
super(env)
super(Rack::MockRequest.env_for("/"))

@query_parameters = {}
@session = TestSession.new
Expand Down
10 changes: 7 additions & 3 deletions actionpack/lib/action_view/helpers/form_helper.rb
Expand Up @@ -737,9 +737,13 @@ def initialize(object_name, object, template, options, proc)

(field_helpers - %w(label check_box radio_button fields_for)).each do |selector|
src = <<-end_src
def #{selector}(method, options = {})
@template.send(#{selector.inspect}, @object_name, method, objectify_options(options))
end
def #{selector}(method, options = {}) # def text_field(method, options = {})
@template.send( # @template.send(
#{selector.inspect}, # "text_field",
@object_name, # @object_name,
method, # method,
objectify_options(options)) # objectify_options(options))
end # end
end_src
class_eval src, __FILE__, __LINE__
end
Expand Down
8 changes: 8 additions & 0 deletions actionpack/test/controller/assert_select_test.rb
Expand Up @@ -248,6 +248,14 @@ def test_assert_select_from_rjs_with_multiple_results
end
end

def test_assert_select_rjs_for_positioned_insert_should_fail_when_mixing_arguments
render_rjs do |page|
page.insert_html :top, "test1", "<div id=\"1\">foo</div>"
page.insert_html :bottom, "test2", "<div id=\"2\">foo</div>"
end
assert_raises(Assertion) {assert_select_rjs :insert, :top, "test2"}
end

#
# Test css_select.
#
Expand Down
22 changes: 12 additions & 10 deletions actionpack/test/controller/layout_test.rb
Expand Up @@ -165,15 +165,17 @@ def test_layout_status_is_rendered
end
end

class LayoutSymlinkedTest < LayoutTest
layout "symlinked/symlinked_layout"
end

class LayoutSymlinkedIsRenderedTest < ActionController::TestCase
def test_symlinked_layout_is_rendered
@controller = LayoutSymlinkedTest.new
get :hello
assert_response 200
assert_equal "layouts/symlinked/symlinked_layout", @response.layout
unless RUBY_PLATFORM =~ /(:?mswin|mingw|bccwin)/
class LayoutSymlinkedTest < LayoutTest
layout "symlinked/symlinked_layout"
end

class LayoutSymlinkedIsRenderedTest < ActionController::TestCase
def test_symlinked_layout_is_rendered
@controller = LayoutSymlinkedTest.new
get :hello
assert_response 200
assert_equal "layouts/symlinked/symlinked_layout", @response.layout
end
end
end
4 changes: 2 additions & 2 deletions actionpack/test/controller/rack_test.rb
Expand Up @@ -4,7 +4,7 @@ class BaseRackTest < Test::Unit::TestCase
def setup
@env = {
"HTTP_MAX_FORWARDS" => "10",
"SERVER_NAME" => "glu.ttono.us:8007",
"SERVER_NAME" => "glu.ttono.us",
"FCGI_ROLE" => "RESPONDER",
"AUTH_TYPE" => "Basic",
"HTTP_X_FORWARDED_HOST" => "glu.ttono.us",
Expand Down Expand Up @@ -145,7 +145,7 @@ def test_cgi_environment_variables
assert_equal "kevin", @request.remote_user
assert_equal :get, @request.request_method
assert_equal "/dispatch.fcgi", @request.script_name
assert_equal "glu.ttono.us:8007", @request.server_name
assert_equal "glu.ttono.us", @request.server_name
assert_equal 8007, @request.server_port
assert_equal "HTTP/1.1", @request.server_protocol
assert_equal "lighttpd", @request.server_software
Expand Down
9 changes: 4 additions & 5 deletions actionpack/test/controller/session/cookie_store_test.rb
Expand Up @@ -25,7 +25,7 @@ def persistent_session_id

def set_session_value
session[:foo] = "bar"
render :text => Marshal.dump(session.to_hash)
render :text => Verifier.generate(session.to_hash)
end

def get_session_value
Expand Down Expand Up @@ -94,8 +94,7 @@ def test_setting_session_value
with_test_route_set do
get '/set_session_value'
assert_response :success
session_payload = Verifier.generate(Marshal.load(response.body))
assert_equal ["_myapp_session=#{session_payload}; path=/"],
assert_equal ["_myapp_session=#{response.body}; path=/"],
headers['Set-Cookie']
end
end
Expand Down Expand Up @@ -148,8 +147,8 @@ def test_setting_session_value_after_session_reset
with_test_route_set do
get '/set_session_value'
assert_response :success
session_payload = Verifier.generate(Marshal.load(response.body))
assert_equal ["_myapp_session=#{session_payload}; path=/"],
session_payload = response.body
assert_equal ["_myapp_session=#{response.body}; path=/"],
headers['Set-Cookie']

get '/call_reset_session'
Expand Down
2 changes: 2 additions & 0 deletions activerecord/CHANGELOG
@@ -1,5 +1,7 @@
*2.3.0/3.0*

* Fixed that ActiveRecord::Base#new_record? should return false (not nil) for existing records #1219 [Yaroslav Markin]

* I18n the word separator for error messages. Introduces the activerecord.errors.format.separator translation key. #1294 [Akira Matsuda]

* Add :having as a key to find and the relevant associations. [Emilio Tagua]
Expand Down

0 comments on commit d6c2285

Please sign in to comment.