Principal.not_member_of scope does not accept ActiveRecord::Relation (#28243).

git-svn-id: https://svn.redmine.org/redmine/trunk@22697 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA
2024-02-08 00:57:07 +00:00
parent 34f1c52e23
commit b61ee85e4d
2 changed files with 8 additions and 2 deletions

View File

@@ -76,6 +76,12 @@ class PrincipalTest < ActiveSupport::TestCase
end
end
def test_not_member_of_scope_should_accept_active_record_relation
projects = Project.where(id: [1, 2])
expected = (Principal.all - projects.map(&:memberships).flatten.map(&:principal)).sort
assert_equal expected, Principal.not_member_of(projects).sort
end
def test_not_member_of_scope_should_be_empty_for_no_projects
assert_equal [], Principal.not_member_of([]).sort
end