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
NZKoz committed May 6, 2008
2 parents c26d105 + 04f5221 commit a08004a
Show file tree
Hide file tree
Showing 16 changed files with 320 additions and 241 deletions.
2 changes: 1 addition & 1 deletion actionpack/lib/action_controller/base.rb
Expand Up @@ -998,7 +998,7 @@ def rewrite_options(options) #:nodoc:
# As you can infer from the example, this is mostly useful for situations where you want to centralize dynamic decisions about the
# urls as they stem from the business domain. Please note that any individual url_for call can always override the defaults set
# by this method.
def default_url_options(options) #:doc:
def default_url_options(options = nil)
end

# Redirects the browser to the target specified in +options+. This parameter can take one of three forms:
Expand Down
6 changes: 3 additions & 3 deletions actionpack/lib/action_controller/routing/optimisations.rb
Expand Up @@ -61,9 +61,9 @@ def guard_condition
# if they're using foo_url(:id=>2) it's one
# argument, but we don't want to generate /foos/id2
if number_of_arguments == 1
"(!defined?(default_url_options) || default_url_options(nil).blank?) && defined?(request) && request && args.size == 1 && !args.first.is_a?(Hash)"
"(!defined?(default_url_options) || default_url_options.blank?) && defined?(request) && request && args.size == 1 && !args.first.is_a?(Hash)"
else
"(!defined?(default_url_options) || default_url_options(nil).blank?) && defined?(request) && request && args.size == #{number_of_arguments}"
"(!defined?(default_url_options) || default_url_options.blank?) && defined?(request) && request && args.size == #{number_of_arguments}"
end
end

Expand Down Expand Up @@ -98,7 +98,7 @@ def generation_code
# argument
class PositionalArgumentsWithAdditionalParams < PositionalArguments
def guard_condition
"(!defined?(default_url_options) || default_url_options(nil).blank?) && defined?(request) && request && args.size == #{route.segment_keys.size + 1} && !args.last.has_key?(:anchor) && !args.last.has_key?(:port) && !args.last.has_key?(:host)"
"(!defined?(default_url_options) || default_url_options.blank?) && defined?(request) && request && args.size == #{route.segment_keys.size + 1} && !args.last.has_key?(:anchor) && !args.last.has_key?(:port) && !args.last.has_key?(:host)"
end

# This case uses almost the same code as positional arguments,
Expand Down
14 changes: 9 additions & 5 deletions actionpack/lib/action_view/helpers/form_helper.rb
Expand Up @@ -614,23 +614,27 @@ def add_default_name_and_id(options)
end

def tag_name
"#{@object_name}[#{@method_name}]"
"#{@object_name}[#{sanitized_method_name}]"
end

def tag_name_with_index(index)
"#{@object_name}[#{index}][#{@method_name}]"
"#{@object_name}[#{index}][#{sanitized_method_name}]"
end

def tag_id
"#{sanitized_object_name}_#{@method_name}"
"#{sanitized_object_name}_#{sanitized_method_name}"
end

def tag_id_with_index(index)
"#{sanitized_object_name}_#{index}_#{@method_name}"
"#{sanitized_object_name}_#{index}_#{sanitized_method_name}"
end

def sanitized_object_name
@object_name.gsub(/[^-a-zA-Z0-9:.]/, "_").sub(/_$/, "")
@sanitized_object_name ||= @object_name.gsub(/[^-a-zA-Z0-9:.]/, "_").sub(/_$/, "")
end

def sanitized_method_name
@sanitized_method_name ||= @method_name.sub(/\?$/,"")
end
end

Expand Down
15 changes: 14 additions & 1 deletion actionpack/test/controller/base_test.rb
Expand Up @@ -52,7 +52,7 @@ class DefaultUrlOptionsController < ActionController::Base
def default_url_options_action
end

def default_url_options(options)
def default_url_options(options = nil)
{ :host => 'www.override.com', :action => 'new', :bacon => 'chunky' }
end
end
Expand Down Expand Up @@ -167,4 +167,17 @@ def test_default_url_options_are_used_if_set
ensure
ActionController::Routing::Routes.load!
end
end

class EnsureNamedRoutesWorksTicket22BugTest < Test::Unit::TestCase
def test_named_routes_still_work
ActionController::Routing::Routes.draw do |map|
map.resources :things
end
EmptyController.send :include, ActionController::UrlWriter

assert_equal '/things', EmptyController.new.send(:things_path)
ensure
ActionController::Routing::Routes.load!
end
end
9 changes: 9 additions & 0 deletions actionpack/test/template/form_helper_test.rb
Expand Up @@ -6,6 +6,7 @@
alias_method :title_before_type_cast, :title unless respond_to?(:title_before_type_cast)
alias_method :body_before_type_cast, :body unless respond_to?(:body_before_type_cast)
alias_method :author_name_before_type_cast, :author_name unless respond_to?(:author_name_before_type_cast)
alias_method :secret?, :secret

def new_record=(boolean)
@new_record = boolean
Expand Down Expand Up @@ -71,10 +72,12 @@ def test_label
'<label class="title_label" for="post_title">Title</label>',
label("post", "title", nil, :class => 'title_label')
)
assert_dom_equal('<label for="post_secret">Secret?</label>', label("post", "secret?"))
end

def test_label_with_symbols
assert_dom_equal('<label for="post_title">Title</label>', label(:post, :title))
assert_dom_equal('<label for="post_secret">Secret?</label>', label(:post, :secret?))
end

def test_label_with_for_attribute_as_symbol
Expand Down Expand Up @@ -140,6 +143,8 @@ def test_text_field_doesnt_change_param_values
def test_hidden_field
assert_dom_equal '<input id="post_title" name="post[title]" type="hidden" value="Hello World" />',
hidden_field("post", "title")
assert_dom_equal '<input id="post_secret" name="post[secret]" type="hidden" value="1" />',
hidden_field("post", "secret?")
end

def test_hidden_field_with_escapes
Expand Down Expand Up @@ -172,6 +177,10 @@ def test_check_box
'<input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" /><input name="post[secret]" type="hidden" value="0" />',
check_box("post", "secret")
)
assert_dom_equal(
'<input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" /><input name="post[secret]" type="hidden" value="0" />',
check_box("post", "secret?")
)
end

def test_check_box_with_explicit_checked_and_unchecked_values
Expand Down
Expand Up @@ -295,6 +295,12 @@ def index_name(table_name, options) #:nodoc:
def structure_dump
end

def dump_schema_information #:nodoc:
sm_table = ActiveRecord::Migrator.schema_migrations_table_name
migrated = select_values("SELECT version FROM #{sm_table}")
migrated.map { |v| "INSERT INTO #{sm_table} (version) VALUES ('#{v}');" }.join("\n")
end

# Should not be called normally, but this operation is non-destructive.
# The migrations module handles this automatically.
def initialize_schema_migrations_table
Expand Down
2 changes: 2 additions & 0 deletions activesupport/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*

* Added Ruby 1.8 implementation of Process.daemon

* Duration #since and #ago with no argument (e.g., 5.days.ago) return TimeWithZone when config.time_zone is set. Introducing Time.current, which returns Time.zone.now if config.time_zone is set, otherwise just returns Time.now [Geoff Buesing]

* Time#since behaves correctly when passed a Duration. Closes #11527 [kemiller]
Expand Down
12 changes: 2 additions & 10 deletions activesupport/lib/active_support/core_ext/kernel/daemonizing.rb
Expand Up @@ -2,14 +2,6 @@ module Kernel
# Turns the current script into a daemon process that detaches from the console.
# It can be shut down with a TERM signal.
def daemonize
exit if fork # Parent exits, child continues.
Process.setsid # Become session leader.
exit if fork # Zap session leader. See [1].
Dir.chdir "/" # Release old working directory.
File.umask 0000 # Ensure sensible umask. Adjust as needed.
STDIN.reopen "/dev/null" # Free file descriptors and
STDOUT.reopen "/dev/null", "a" # point them somewhere sensible.
STDERR.reopen STDOUT # STDOUT/ERR should better go to a logfile.
trap("TERM") { exit }
Process.daemon
end
end
end
1 change: 1 addition & 0 deletions activesupport/lib/active_support/core_ext/process.rb
@@ -0,0 +1 @@
require 'active_support/core_ext/process/daemon'
25 changes: 25 additions & 0 deletions activesupport/lib/active_support/core_ext/process/daemon.rb
@@ -0,0 +1,25 @@
if RUBY_VERSION < "1.9"
module Process
def self.daemon(nochdir = nil, noclose = nil)
exit if fork # Parent exits, child continues.
Process.setsid # Become session leader.
exit if fork # Zap session leader. See [1].

unless nochdir
Dir.chdir "/" # Release old working directory.
end

File.umask 0000 # Ensure sensible umask. Adjust as needed.

unless noclose
STDIN.reopen "/dev/null" # Free file descriptors and
STDOUT.reopen "/dev/null", "a" # point them somewhere sensible.
STDERR.reopen '/dev/null', 'a'
end

trap("TERM") { exit }

return 0
end
end
end
6 changes: 6 additions & 0 deletions activesupport/lib/active_support/ordered_options.rb
Expand Up @@ -18,6 +18,12 @@ def [](key)
pair = assoc(key)
pair ? pair.last : nil
end

def delete(key)
pair = assoc(key)
pair ? array_index = index(pair) : nil
array_index ? delete_at(array_index).last : nil
end

def keys
collect { |key, value| key }
Expand Down

1 comment on commit a08004a

@rmm5t
Copy link
Contributor

@rmm5t rmm5t commented on a08004a May 6, 2008

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Koz, As I understand things, these “Merge branch ‘master’” commits can be avoided if you git-fetch && git-rebase instead of git-pull. git-pull calls merge instead of rebase by default, but can be told to rebase instead with the —rebase option.

More info:
http://lists.freedesktop.org/archives/xorg/2006-November/019737.html

I ran into a similar issue with my repos. I’m thinking of using aliases to help:

alias gl=“git pull”
alias glr=“git pull —rebase”

More info on rebase vs merge (I’m still trying to grok all of this myself):
http://kerneltrap.org/mailarchive/git/2007/10/27/361274

Please sign in to comment.