diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-12-18 09:35:06 -0800 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2011-12-18 09:35:06 -0800 |
commit | 81c67c1441c5aa86c92b5db87cbbc7ca1cbd8a44 (patch) | |
tree | 4a6ff17736ab46b6f90097480dec2f4a2a928943 /activerecord/test | |
parent | 1214e16640cb193747f3181f1f6a795140a0c902 (diff) | |
parent | 04cea56d89e71dbb25dc888d8f855ba18025ccca (diff) | |
download | rails-81c67c1441c5aa86c92b5db87cbbc7ca1cbd8a44.tar.gz rails-81c67c1441c5aa86c92b5db87cbbc7ca1cbd8a44.tar.bz2 rails-81c67c1441c5aa86c92b5db87cbbc7ca1cbd8a44.zip |
Merge pull request #4011 from lest/scope-with-lambda-duplicates
call scope within unscoped to prevent duplication of where values
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/named_scope_test.rb | 5 | ||||
-rw-r--r-- | activerecord/test/models/topic.rb | 2 |
2 files changed, 7 insertions, 0 deletions
diff --git a/activerecord/test/cases/named_scope_test.rb b/activerecord/test/cases/named_scope_test.rb index 4a09a87322..0eb3d900bd 100644 --- a/activerecord/test/cases/named_scope_test.rb +++ b/activerecord/test/cases/named_scope_test.rb @@ -337,6 +337,11 @@ class NamedScopeTest < ActiveRecord::TestCase end end + def test_should_not_duplicates_where_values + where_values = Topic.where("1=1").scope_with_lambda.where_values + assert_equal ["1=1"], where_values + end + def test_chaining_with_duplicate_joins join = "INNER JOIN comments ON comments.post_id = posts.id" post = Post.find(1) diff --git a/activerecord/test/models/topic.rb b/activerecord/test/models/topic.rb index fe424e61b2..ede662450e 100644 --- a/activerecord/test/models/topic.rb +++ b/activerecord/test/models/topic.rb @@ -8,6 +8,8 @@ class Topic < ActiveRecord::Base scope :approved, :conditions => {:approved => true} scope :rejected, :conditions => {:approved => false} + scope :scope_with_lambda, lambda { scoped } + scope :by_lifo, :conditions => {:author_name => 'lifo'} scope :approved_as_hash_condition, :conditions => {:topics => {:approved => true}} |