mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Merge branch 'master' of git@github.com:rails/rails
This commit is contained in:
@@ -1733,6 +1733,7 @@ module ActiveRecord
|
||||
case cond
|
||||
when nil then all
|
||||
when Array then all << cond.first
|
||||
when Hash then all << cond.keys
|
||||
else all << cond
|
||||
end
|
||||
end
|
||||
|
||||
@@ -385,12 +385,28 @@ class EagerAssociationTest < ActiveRecord::TestCase
|
||||
assert_equal count, posts.size
|
||||
end
|
||||
|
||||
def test_eager_with_has_many_and_limit_ond_high_offset
|
||||
def test_eager_with_has_many_and_limit_and_high_offset
|
||||
posts = Post.find(:all, :include => [ :author, :comments ], :limit => 2, :offset => 10, :conditions => [ "authors.name = ?", 'David' ])
|
||||
assert_equal 0, posts.size
|
||||
end
|
||||
|
||||
def test_count_eager_with_has_many_and_limit_ond_high_offset
|
||||
def test_eager_with_has_many_and_limit_and_high_offset_and_multiple_array_conditions
|
||||
assert_queries(1) do
|
||||
posts = Post.find(:all, :include => [ :author, :comments ], :limit => 2, :offset => 10,
|
||||
:conditions => [ "authors.name = ? and comments.body = ?", 'David', 'go crazy' ])
|
||||
assert_equal 0, posts.size
|
||||
end
|
||||
end
|
||||
|
||||
def test_eager_with_has_many_and_limit_and_high_offset_and_multiple_hash_conditions
|
||||
assert_queries(1) do
|
||||
posts = Post.find(:all, :include => [ :author, :comments ], :limit => 2, :offset => 10,
|
||||
:conditions => { 'authors.name' => 'David', 'comments.body' => 'go crazy' })
|
||||
assert_equal 0, posts.size
|
||||
end
|
||||
end
|
||||
|
||||
def test_count_eager_with_has_many_and_limit_and_high_offset
|
||||
posts = Post.count(:all, :include => [ :author, :comments ], :limit => 2, :offset => 10, :conditions => [ "authors.name = ?", 'David' ])
|
||||
assert_equal 0, posts
|
||||
end
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
*2.3.0 [Edge]*
|
||||
|
||||
* Added ActiveSupport::OrderedHash#each_key and ActiveSupport::OrderedHash#each_value #1410 [Christoffer Sawicki]
|
||||
|
||||
* Added ActiveSupport::MessageVerifier and MessageEncryptor to aid users who need to store signed and/or encrypted messages. [Koz]
|
||||
|
||||
* Added ActiveSupport::BacktraceCleaner to cut down on backtrace noise according to filters and silencers [DHH]
|
||||
|
||||
@@ -53,6 +53,14 @@ module ActiveSupport
|
||||
end
|
||||
|
||||
alias_method :value?, :has_value?
|
||||
|
||||
def each_key
|
||||
each { |key, value| yield key }
|
||||
end
|
||||
|
||||
def each_value
|
||||
each { |key, value| yield value }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -17,7 +17,7 @@ module XmlMini
|
||||
# string::
|
||||
# XML Document string to parse
|
||||
def parse(string)
|
||||
require 'rexml/document'
|
||||
require 'rexml/document' unless defined?(REXML::Document)
|
||||
doc = REXML::Document.new(string)
|
||||
merge_element!({}, doc.root)
|
||||
end
|
||||
|
||||
@@ -61,4 +61,16 @@ class OrderedHashTest < Test::Unit::TestCase
|
||||
assert_equal false, @ordered_hash.has_value?('ABCABC')
|
||||
assert_equal false, @ordered_hash.value?('ABCABC')
|
||||
end
|
||||
|
||||
def test_each_key
|
||||
keys = []
|
||||
@ordered_hash.each_key { |k| keys << k }
|
||||
assert_equal @keys, keys
|
||||
end
|
||||
|
||||
def test_each_value
|
||||
values = []
|
||||
@ordered_hash.each_value { |v| values << v }
|
||||
assert_equal @values, values
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user