|
5 | 5 | it { should belong_to :category }
|
6 | 6 | it { should belong_to :topic }
|
7 | 7 |
|
8 |
| - it "should feature topics for a secure category" do |
| 8 | + context 'feature_topics_for' do |
| 9 | + let(:user) { Fabricate(:user) } |
| 10 | + let(:category) { Fabricate(:category) } |
| 11 | + let!(:category_post) { PostCreator.create(user, raw: "I put this post in the category", title: "categorize THIS", category: category.name) } |
9 | 12 |
|
10 |
| - # so much dancing, I am thinking fixures make sense here. |
11 |
| - user = Fabricate(:user) |
12 |
| - user.change_trust_level!(:basic) |
| 13 | + it "should feature topics for a secure category" do |
13 | 14 |
|
14 |
| - category = Fabricate(:category) |
15 |
| - category.deny(:all) |
16 |
| - category.allow(Group[:trust_level_1]) |
17 |
| - category.save |
| 15 | + # so much dancing, I am thinking fixures make sense here. |
| 16 | + user.change_trust_level!(:basic) |
18 | 17 |
|
19 |
| - uncategorized_post = PostCreator.create(user, raw: "this is my new post 123 post", title: "hello world") |
20 |
| - category_post = PostCreator.create(user, raw: "I put this post in the category", title: "categorize THIS", category: category.name) |
| 18 | + category.deny(:all) |
| 19 | + category.allow(Group[:trust_level_1]) |
| 20 | + category.save |
21 | 21 |
|
22 |
| - CategoryFeaturedTopic.feature_topics_for(category) |
23 |
| - CategoryFeaturedTopic.count.should == 1 |
| 22 | + uncategorized_post = PostCreator.create(user, raw: "this is my new post 123 post", title: "hello world") |
24 | 23 |
|
| 24 | + CategoryFeaturedTopic.feature_topics_for(category) |
| 25 | + CategoryFeaturedTopic.count.should == 1 |
| 26 | + |
| 27 | + end |
| 28 | + |
| 29 | + it 'should not include invisible topics' do |
| 30 | + invisible_post = PostCreator.create(user, raw: "Don't look at this post because it's awful.", title: "not visible to anyone", category: category.name) |
| 31 | + invisible_post.topic.update_status('visible', false, Fabricate(:admin)) |
| 32 | + CategoryFeaturedTopic.feature_topics_for(category) |
| 33 | + CategoryFeaturedTopic.count.should == 1 |
| 34 | + end |
25 | 35 | end
|
26 | 36 |
|
27 | 37 | end
|
|
0 commit comments