class HasAndBelongsToManyScopingTest

Public Instance Methods

setup() click to toggle source
# File activerecord/test/cases/scoping/relation_scoping_test.rb, line 382
def setup
  @welcome = Post.find(1)
end
test_forwarding_of_static_methods() click to toggle source
# File activerecord/test/cases/scoping/relation_scoping_test.rb, line 386
def test_forwarding_of_static_methods
  assert_equal "a category...", Category.what_are_you
  assert_equal "a category...", @welcome.categories.what_are_you
end
test_nested_scope_finder() click to toggle source
# File activerecord/test/cases/scoping/relation_scoping_test.rb, line 391
def test_nested_scope_finder
  Category.where("1=0").scoping do
    assert_equal 0, @welcome.categories.count
    assert_equal "a category...", @welcome.categories.what_are_you
  end

  Category.where("1=1").scoping do
    assert_equal 2, @welcome.categories.count
    assert_equal "a category...", @welcome.categories.what_are_you
  end
end