DEV: Add test for list_group_topics_assigned (#338)
Follow up to commit c8fc42b60f
.
This commit is contained in:
parent
35842bf5ab
commit
efeb7ad511
|
@ -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
|
Loading…
Reference in New Issue