DEV: Add test for list_group_topics_assigned (#338)

Follow up to commit c8fc42b60f.
This commit is contained in:
Bianca Nenciu 2022-05-18 17:57:58 +03:00 committed by GitHub
parent 35842bf5ab
commit efeb7ad511
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 39 additions and 0 deletions

View File

@ -0,0 +1,39 @@
# frozen_string_literal: true
require 'topic_view'
describe TopicQuery do
fab!(:user) { Fabricate(:user) }
fab!(:admin) { Fabricate(:admin) }
fab!(:other_admin) { Fabricate(:admin) }
fab!(:user_pm) { Fabricate(:private_message_topic, user: user) }
fab!(:admin_pm) { Fabricate(:private_message_topic, user: admin) }
fab!(:other_admin_pm) { Fabricate(:private_message_topic, user: other_admin) }
fab!(:group) { Fabricate(:group) }
describe '#list_group_topics_assigned' do
before do
SiteSetting.assign_enabled = true
[user, admin, other_admin].each do |user|
group.add(user)
end
[user_pm, admin_pm, other_admin_pm].each do |topic|
Fabricate(:post, topic: topic)
end
Assigner.new(user_pm, Discourse.system_user).assign(admin)
Assigner.new(admin_pm, Discourse.system_user).assign(admin)
Assigner.new(other_admin_pm, Discourse.system_user).assign(other_admin)
end
it "includes PMs from all users" do
expect(TopicQuery.new(user).list_group_topics_assigned(group).topics).to contain_exactly(user_pm)
expect(TopicQuery.new(admin).list_group_topics_assigned(group).topics).to contain_exactly(user_pm, admin_pm, other_admin_pm)
expect(TopicQuery.new(other_admin).list_group_topics_assigned(group).topics).to contain_exactly(user_pm, admin_pm, other_admin_pm)
end
end
end