From aa91bd61a7ad4cf393d896075eb8ef428187519b Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Fri, 16 Mar 2018 16:18:26 +0800 Subject: [PATCH] Improve specs for `TopicQuery#list_group_topics`. --- spec/components/topic_query_spec.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/spec/components/topic_query_spec.rb b/spec/components/topic_query_spec.rb index 98f162f77b9..17fc11def98 100644 --- a/spec/components/topic_query_spec.rb +++ b/spec/components/topic_query_spec.rb @@ -904,6 +904,8 @@ describe TopicQuery do user end + let(:user3) { Fabricate(:user) } + let(:private_category) do Fabricate(:private_category, group: group) end @@ -916,11 +918,13 @@ describe TopicQuery do let!(:topic5) { Fabricate(:topic, user: user, visible: false) } let!(:topic6) { Fabricate(:topic, user: user2) } - it 'should return the right list' do + it 'should return the right lists for anon user' do topics = TopicQuery.new.list_group_topics(group).topics expect(topics).to contain_exactly(topic1, topic2, topic6) + end + it 'should retun the right list for users in the same group' do topics = TopicQuery.new(user).list_group_topics(group).topics expect(topics).to contain_exactly(topic1, topic2, topic3, topic6) @@ -929,5 +933,11 @@ describe TopicQuery do expect(topics).to contain_exactly(topic1, topic2, topic3, topic6) end + + it 'should return the right list for user no in the group' do + topics = TopicQuery.new(user3).list_group_topics(group).topics + + expect(topics).to contain_exactly(topic1, topic2, topic6) + end end end