diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-10-30 12:26:38 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-10-30 13:20:54 -0700 |
commit | cbca12f9086826dd7243c7c847deea89bbe026b1 (patch) | |
tree | 05e2106f4cdd36ae819270d27fbb7cb375101209 /activerecord | |
parent | 7d5762d2c2147f8240614997682e5e535a3e4f33 (diff) | |
download | rails-cbca12f9086826dd7243c7c847deea89bbe026b1.tar.gz rails-cbca12f9086826dd7243c7c847deea89bbe026b1.tar.bz2 rails-cbca12f9086826dd7243c7c847deea89bbe026b1.zip |
adding tests for #5234 and #5184. Tests were from Akira Matsuda. Thanks Akira!
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/test/cases/method_scoping_test.rb | 6 | ||||
-rw-r--r-- | activerecord/test/cases/relations_test.rb | 5 |
2 files changed, 11 insertions, 0 deletions
diff --git a/activerecord/test/cases/method_scoping_test.rb b/activerecord/test/cases/method_scoping_test.rb index f3d3d62830..0ffd0e2ab3 100644 --- a/activerecord/test/cases/method_scoping_test.rb +++ b/activerecord/test/cases/method_scoping_test.rb @@ -226,6 +226,12 @@ class MethodScopingTest < ActiveRecord::TestCase assert Post.find(1).comments.include?(new_comment) end + def test_scoped_create_with_join_and_merge + (Comment.where(:body => "but Who's Buying?").joins(:post) & Post.where(:body => 'Peace Sells...')).with_scope do + assert_equal({:body => "but Who's Buying?"}, Comment.scoped.scope_for_create) + end + end + def test_immutable_scope options = { :conditions => "name = 'David'" } Developer.send(:with_scope, :find => options) do diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index d2ccc1480a..f4f3dc4d5a 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -500,6 +500,11 @@ class RelationTest < ActiveRecord::TestCase end end + def test_relation_merging_with_joins + comments = Comment.joins(:post).where(:body => 'Thank you for the welcome') & Post.where(:body => 'Such a lovely day') + assert_equal 1, comments.count + end + def test_count posts = Post.scoped |