mirror of
https://github.com/discourse/discourse.git
synced 2026-08-14 06:55:03 -05:00
Categories page should not show invisible topics
This commit is contained in:
@@ -5,23 +5,33 @@ describe CategoryFeaturedTopic do
|
||||
it { should belong_to :category }
|
||||
it { should belong_to :topic }
|
||||
|
||||
it "should feature topics for a secure category" do
|
||||
context 'feature_topics_for' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:category) { Fabricate(:category) }
|
||||
let!(:category_post) { PostCreator.create(user, raw: "I put this post in the category", title: "categorize THIS", category: category.name) }
|
||||
|
||||
# so much dancing, I am thinking fixures make sense here.
|
||||
user = Fabricate(:user)
|
||||
user.change_trust_level!(:basic)
|
||||
it "should feature topics for a secure category" do
|
||||
|
||||
category = Fabricate(:category)
|
||||
category.deny(:all)
|
||||
category.allow(Group[:trust_level_1])
|
||||
category.save
|
||||
# so much dancing, I am thinking fixures make sense here.
|
||||
user.change_trust_level!(:basic)
|
||||
|
||||
uncategorized_post = PostCreator.create(user, raw: "this is my new post 123 post", title: "hello world")
|
||||
category_post = PostCreator.create(user, raw: "I put this post in the category", title: "categorize THIS", category: category.name)
|
||||
category.deny(:all)
|
||||
category.allow(Group[:trust_level_1])
|
||||
category.save
|
||||
|
||||
CategoryFeaturedTopic.feature_topics_for(category)
|
||||
CategoryFeaturedTopic.count.should == 1
|
||||
uncategorized_post = PostCreator.create(user, raw: "this is my new post 123 post", title: "hello world")
|
||||
|
||||
CategoryFeaturedTopic.feature_topics_for(category)
|
||||
CategoryFeaturedTopic.count.should == 1
|
||||
|
||||
end
|
||||
|
||||
it 'should not include invisible topics' do
|
||||
invisible_post = PostCreator.create(user, raw: "Don't look at this post because it's awful.", title: "not visible to anyone", category: category.name)
|
||||
invisible_post.topic.update_status('visible', false, Fabricate(:admin))
|
||||
CategoryFeaturedTopic.feature_topics_for(category)
|
||||
CategoryFeaturedTopic.count.should == 1
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user