2013-02-05 13:16:51 -06:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe CategoryFeaturedTopic do
|
|
|
|
|
|
|
|
it { should belong_to :category }
|
|
|
|
it { should belong_to :topic }
|
2013-02-25 10:42:20 -06:00
|
|
|
|
2013-06-20 15:07:53 -05:00
|
|
|
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) }
|
2013-06-04 20:22:47 -05:00
|
|
|
|
2013-06-20 15:07:53 -05:00
|
|
|
it "should feature topics for a secure category" do
|
2013-06-04 20:22:47 -05:00
|
|
|
|
2013-06-20 15:07:53 -05:00
|
|
|
# so much dancing, I am thinking fixures make sense here.
|
|
|
|
user.change_trust_level!(:basic)
|
2013-06-04 20:22:47 -05:00
|
|
|
|
2013-06-20 15:07:53 -05:00
|
|
|
category.deny(:all)
|
|
|
|
category.allow(Group[:trust_level_1])
|
|
|
|
category.save
|
2013-06-04 20:22:47 -05:00
|
|
|
|
2013-06-20 15:07:53 -05:00
|
|
|
uncategorized_post = PostCreator.create(user, raw: "this is my new post 123 post", title: "hello world")
|
2013-06-04 20:22:47 -05:00
|
|
|
|
2013-06-20 15:07:53 -05:00
|
|
|
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
|
2013-06-04 20:22:47 -05:00
|
|
|
end
|
|
|
|
|
2013-02-05 13:16:51 -06:00
|
|
|
end
|
|
|
|
|