mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user