aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorAndrew White <andyw@pixeltrix.co.uk>2008-05-29 12:59:29 +0100
committerPratik Naik <pratiknaik@gmail.com>2008-05-29 14:10:24 +0100
commit235d635708dd72bee0828457af5397c79750483a (patch)
tree51f09f956b8f4d84d6f0e81dd697d577ffcd7f92 /activerecord/test/cases
parentcf6299dbd73a8cb6d74265df03d01abe885e686a (diff)
downloadrails-235d635708dd72bee0828457af5397c79750483a.tar.gz
rails-235d635708dd72bee0828457af5397c79750483a.tar.bz2
rails-235d635708dd72bee0828457af5397c79750483a.zip
Ensure :select passed in options overrides the one from the scope. [#239 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/method_scoping_test.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/activerecord/test/cases/method_scoping_test.rb b/activerecord/test/cases/method_scoping_test.rb
index 4b5bd6c951..1a9a875730 100644
--- a/activerecord/test/cases/method_scoping_test.rb
+++ b/activerecord/test/cases/method_scoping_test.rb
@@ -50,6 +50,22 @@ class MethodScopingTest < ActiveRecord::TestCase
end
end
+ def test_scoped_find_select
+ Developer.with_scope(:find => { :select => "id, name" }) do
+ developer = Developer.find(:first, :conditions => "name = 'David'")
+ assert_equal "David", developer.name
+ assert !developer.has_attribute?(:salary)
+ end
+ end
+
+ def test_options_select_replaces_scope_select
+ Developer.with_scope(:find => { :select => "id, name" }) do
+ developer = Developer.find(:first, :select => 'id, salary', :conditions => "name = 'David'")
+ assert_equal 80000, developer.salary
+ assert !developer.has_attribute?(:name)
+ end
+ end
+
def test_scoped_count
Developer.with_scope(:find => { :conditions => "name = 'David'" }) do
assert_equal 1, Developer.count