aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorEmilio Tagua <miloops@gmail.com>2009-10-05 14:39:20 -0300
committerEmilio Tagua <miloops@gmail.com>2009-10-05 14:39:20 -0300
commit3747f896a1b727d67e6022001007e5f58b24a267 (patch)
tree1e72baf5128b9138be87089a4b88c3bab09e5f2c /activerecord
parentc01c21b31d590f7e8d12e3ae083fcdf0f0c6fd54 (diff)
downloadrails-3747f896a1b727d67e6022001007e5f58b24a267.tar.gz
rails-3747f896a1b727d67e6022001007e5f58b24a267.tar.bz2
rails-3747f896a1b727d67e6022001007e5f58b24a267.zip
Moved relation's test to relation_test.
Diffstat (limited to 'activerecord')
-rwxr-xr-xactiverecord/lib/active_record/base.rb3
-rw-r--r--activerecord/test/cases/method_scoping_test.rb4
-rw-r--r--activerecord/test/cases/relations_test.rb11
3 files changed, 14 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 1c12189e15..2fd3384877 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -667,7 +667,7 @@ module ActiveRecord #:nodoc:
options = args.extract_options!
- if options.empty? #&& !scoped?(:find)
+ if options.empty? && !scoped?(:find)
relation = arel_table
else
include_associations = merge_includes(scope(:find, :include), options[:include])
@@ -1751,7 +1751,6 @@ module ActiveRecord #:nodoc:
relation = relation.readonly if options[:readonly]
relation
-
end
def construct_finder_sql(options, scope = scope(:find))
diff --git a/activerecord/test/cases/method_scoping_test.rb b/activerecord/test/cases/method_scoping_test.rb
index 6dec474f7d..eb4ce0e774 100644
--- a/activerecord/test/cases/method_scoping_test.rb
+++ b/activerecord/test/cases/method_scoping_test.rb
@@ -593,12 +593,12 @@ class DefaultScopingTest < ActiveRecord::TestCase
end
def test_default_scope_with_conditions_string
- assert_equal Developer.find_all_by_name('David').map(&:id).sort, DeveloperCalledDavid.all.to_a.map(&:id).sort
+ assert_equal Developer.find_all_by_name('David').map(&:id).sort, DeveloperCalledDavid.find(:all).map(&:id).sort
assert_equal nil, DeveloperCalledDavid.create!.name
end
def test_default_scope_with_conditions_hash
- assert_equal Developer.find_all_by_name('Jamis').map(&:id).sort, DeveloperCalledJamis.all.to_a.map(&:id).sort
+ assert_equal Developer.find_all_by_name('Jamis').map(&:id).sort, DeveloperCalledJamis.find(:all).map(&:id).sort
assert_equal 'Jamis', DeveloperCalledJamis.create!.name
end
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb
index 6fb505ca36..17c228616b 100644
--- a/activerecord/test/cases/relations_test.rb
+++ b/activerecord/test/cases/relations_test.rb
@@ -114,5 +114,16 @@ class RelationTest < ActiveRecord::TestCase
posts.first.author
end
end
+
+ def test_default_scope_with_conditions_string
+ assert_equal Developer.find_all_by_name('David').map(&:id).sort, DeveloperCalledDavid.all.to_a.map(&:id).sort
+ assert_equal nil, DeveloperCalledDavid.create!.name
+ end
+
+ def test_default_scope_with_conditions_hash
+ assert_equal Developer.find_all_by_name('Jamis').map(&:id).sort, DeveloperCalledJamis.all.to_a.map(&:id).sort
+ assert_equal 'Jamis', DeveloperCalledJamis.create!.name
+ end
+
end