Merge remote branch 'rails/master'

This commit is contained in:
Xavier Noria 2010-08-08 18:35:43 +02:00
commit 4d3b2ea68b
7 changed files with 65 additions and 9 deletions

@ -11,7 +11,7 @@ gem "rails", :path => File.dirname(__FILE__)
gem "rake", ">= 0.8.7"
gem "mocha", ">= 0.9.8"
gem "rdoc", ">= 2.5.9"
gem "horo"
gem "horo", ">= 1.0.1"
# AS
gem "memcache-client", ">= 1.8.5"

@ -5,6 +5,31 @@ require 'rake'
require 'rdoc/task'
require 'rake/gempackagetask'
# RDoc skips some files in the Rails tree due to its binary? predicate. This is a quick
# hack for edge docs, until we decide which is the correct way to address this issue.
# If not fixed in RDoc itself, via an option or something, we should probably move this
# to railties and use it also in doc:rails.
def hijack_rdoc!
require "rdoc/parser"
class << RDoc::Parser
def binary?(file)
s = File.read(file, 1024) or return false
if s[0, 2] == Marshal.dump('')[0, 2] then
true
elsif file =~ /erb\.rb$/ then
false
elsif s.index("\x00") then # ORIGINAL is s.scan(/<%|%>/).length >= 4 || s.index("\x00")
true
elsif 0.respond_to? :fdiv then
s.count("^ -~\t\r\n").fdiv(s.size) > 0.3
else # HACK 1.8.6
(s.count("^ -~\t\r\n").to_f / s.size) > 0.3
end
end
end
end
PROJECTS = %w(activesupport activemodel actionpack actionmailer activeresource activerecord railties)
desc 'Run all tests by default'
@ -63,6 +88,8 @@ end
desc "Generate documentation for the Rails framework"
RDoc::Task.new do |rdoc|
hijack_rdoc!
rdoc.rdoc_dir = 'doc/rdoc'
rdoc.title = "Ruby on Rails Documentation"
@ -90,6 +117,7 @@ RDoc::Task.new do |rdoc|
rdoc.rdoc_files.include('actionpack/README.rdoc')
rdoc.rdoc_files.include('actionpack/CHANGELOG')
rdoc.rdoc_files.include('actionpack/lib/abstract_controller/**/*.rb')
rdoc.rdoc_files.include('actionpack/lib/action_controller/**/*.rb')
rdoc.rdoc_files.include('actionpack/lib/action_dispatch/**/*.rb')
rdoc.rdoc_files.include('actionpack/lib/action_view/**/*.rb')

@ -103,8 +103,8 @@ def connection
# Signal that the thread is finished with the current connection.
# #release_connection releases the connection-thread association
# and returns the connection to the pool.
def release_connection
conn = @reserved_connections.delete(current_connection_id)
def release_connection(with_id = current_connection_id)
conn = @reserved_connections.delete(with_id)
checkin conn if conn
end
@ -112,10 +112,11 @@ def release_connection
# exists checkout a connection, yield it to the block, and checkin the
# connection when finished.
def with_connection
fresh_connection = true unless @reserved_connections[current_connection_id]
connection_id = current_connection_id
fresh_connection = true unless @reserved_connections[connection_id]
yield connection
ensure
release_connection if fresh_connection
release_connection(connection_id) if fresh_connection
end
# Returns true if a connection has already been opened.

@ -319,7 +319,9 @@ def to_sql
def scope_for_create
@scope_for_create ||= begin
@create_with_value || Hash[
@where_values.grep(Arel::Predicates::Equality).map { |where|
@where_values.find_all { |w|
w.respond_to?(:operator) && w.operator == :==
}.map { |where|
[where.operand1.name,
where.operand2.respond_to?(:value) ?
where.operand2.value : where.operand2]

@ -208,6 +208,13 @@ def test_scoped_count_include
end
end
def test_scope_for_create_only_uses_equal
table = VerySpecialComment.arel_table
relation = VerySpecialComment.scoped
relation.where_values << table[:id].not_eq(1)
assert_equal({:type => "VerySpecialComment"}, relation.send(:scope_for_create))
end
def test_scoped_create
new_comment = nil

@ -192,11 +192,23 @@ def test_scoped_responds_to_delegated_methods
end
end
def test_respond_to_private_arel_methods
def test_respond_to_delegates_to_relation
relation = Topic.scoped
fake_arel = Struct.new(:responds) {
def respond_to? method, access = false
responds << [method, access]
end
}.new []
assert ! relation.respond_to?(:matching_attributes)
assert relation.respond_to?(:matching_attributes, true)
relation.extend(Module.new { attr_accessor :arel })
relation.arel = fake_arel
relation.respond_to?(:matching_attributes)
assert_equal [:matching_attributes, false], fake_arel.responds.first
fake_arel.responds = []
relation.respond_to?(:matching_attributes, true)
assert_equal [:matching_attributes, true], fake_arel.responds.first
end
def test_respond_to_dynamic_finders

@ -762,6 +762,12 @@ formatted_users GET /users.:format {:controller=>"users", :action=>"index"}
POST /users.:format {:controller=>"users", :action=>"create"}
</pre>
You may restrict the listing to the routes that map to a particular controller setting the +CONTROLLER+ environment variable:
<shell>
$ CONTROLLER=users rake routes
</shell>
TIP: You'll find that the output from +rake routes+ is much more readable if you widen your terminal window until the output lines don't wrap.
h4. Testing Routes