aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorMikel Lindsaar <raasdnil@gmail.com>2010-01-20 21:58:22 +1100
committerMikel Lindsaar <raasdnil@gmail.com>2010-01-20 21:58:22 +1100
commit8b37fee201bb3f41d3bc4557422c5f8b344f456c (patch)
tree5c24f3f85f10976b3407f557517dcccf0343cd72 /activerecord/test
parentc04baed627c85e586e337896d64f61f397554a46 (diff)
parent8a1be228491f433fa8d20be4f485e2159f5ebe59 (diff)
downloadrails-8b37fee201bb3f41d3bc4557422c5f8b344f456c.tar.gz
rails-8b37fee201bb3f41d3bc4557422c5f8b344f456c.tar.bz2
rails-8b37fee201bb3f41d3bc4557422c5f8b344f456c.zip
Merge branch 'master' of git://github.com/rails/rails
Conflicts: actionmailer/lib/action_mailer/base.rb
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb15
-rw-r--r--activerecord/test/cases/method_scoping_test.rb8
-rw-r--r--activerecord/test/cases/named_scope_test.rb6
3 files changed, 10 insertions, 19 deletions
diff --git a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
index 1bce45865f..004d0156e1 100644
--- a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
+++ b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
@@ -732,21 +732,6 @@ class HasAndBelongsToManyAssociationsTest < ActiveRecord::TestCase
assert_equal [projects(:active_record), projects(:action_controller)].map(&:id).sort, developer.project_ids.sort
end
- def test_select_limited_ids_array
- # Set timestamps
- Developer.transaction do
- Developer.find(:all, :order => 'id').each_with_index do |record, i|
- record.update_attributes(:created_at => 5.years.ago + (i * 5.minutes))
- end
- end
-
- join_base = ActiveRecord::Associations::ClassMethods::JoinDependency::JoinBase.new(Project)
- join_dep = ActiveRecord::Associations::ClassMethods::JoinDependency.new(join_base, :developers, nil)
- projects = Project.send(:select_limited_ids_array, {:order => 'developers.created_at'}, join_dep)
- assert !projects.include?("'"), projects
- assert_equal ["1", "2"], projects.sort
- end
-
def test_scoped_find_on_through_association_doesnt_return_read_only_records
tag = Post.find(1).tags.find_by_name("General")
diff --git a/activerecord/test/cases/method_scoping_test.rb b/activerecord/test/cases/method_scoping_test.rb
index 7ca5b5a988..fbd1adf088 100644
--- a/activerecord/test/cases/method_scoping_test.rb
+++ b/activerecord/test/cases/method_scoping_test.rb
@@ -11,7 +11,7 @@ class MethodScopingTest < ActiveRecord::TestCase
def test_set_conditions
Developer.send(:with_scope, :find => { :conditions => 'just a test...' }) do
- assert_equal '(just a test...)', Developer.scoped.send(:where_clause)
+ assert_equal '(just a test...)', Developer.scoped.arel.send(:where_clauses).join(' AND ')
end
end
@@ -257,7 +257,7 @@ class NestedScopingTest < ActiveRecord::TestCase
Developer.send(:with_scope, :find => { :conditions => 'salary = 80000' }) do
Developer.send(:with_scope, :find => { :limit => 10 }) do
devs = Developer.scoped
- assert_equal '(salary = 80000)', devs.send(:where_clause)
+ assert_equal '(salary = 80000)', devs.arel.send(:where_clauses).join(' AND ')
assert_equal 10, devs.taken
end
end
@@ -285,7 +285,7 @@ class NestedScopingTest < ActiveRecord::TestCase
Developer.send(:with_scope, :find => { :conditions => "name = 'David'" }) do
Developer.send(:with_scope, :find => { :conditions => 'salary = 80000' }) do
devs = Developer.scoped
- assert_equal "(name = 'David') AND (salary = 80000)", devs.send(:where_clause)
+ assert_equal "(name = 'David') AND (salary = 80000)", devs.arel.send(:where_clauses).join(' AND ')
assert_equal(1, Developer.count)
end
Developer.send(:with_scope, :find => { :conditions => "name = 'Maiha'" }) do
@@ -298,7 +298,7 @@ class NestedScopingTest < ActiveRecord::TestCase
Developer.send(:with_scope, :find => { :conditions => 'salary = 80000', :limit => 10 }) do
Developer.send(:with_scope, :find => { :conditions => "name = 'David'" }) do
devs = Developer.scoped
- assert_equal "(salary = 80000) AND (name = 'David')", devs.send(:where_clause)
+ assert_equal "(salary = 80000) AND (name = 'David')", devs.arel.send(:where_clauses).join(' AND ')
assert_equal 10, devs.taken
end
end
diff --git a/activerecord/test/cases/named_scope_test.rb b/activerecord/test/cases/named_scope_test.rb
index 3e2bd58f9a..2c34ab787d 100644
--- a/activerecord/test/cases/named_scope_test.rb
+++ b/activerecord/test/cases/named_scope_test.rb
@@ -379,6 +379,12 @@ class NamedScopeTest < ActiveRecord::TestCase
def test_deprecated_named_scope_method
assert_deprecated('named_scope has been deprecated') { Topic.named_scope :deprecated_named_scope }
end
+
+ def test_index_on_named_scope
+ approved = Topic.approved.order('id ASC')
+ assert_equal topics(:second), approved[0]
+ assert approved.loaded?
+ end
end
class DynamicScopeMatchTest < ActiveRecord::TestCase