WIP: Tags which are not allowed in a category showing in drop down.

This commit is contained in:
Guo Xiang Tan
2016-07-07 21:17:56 +08:00
parent 323efcab71
commit 8fd0414cdf
9 changed files with 70 additions and 28 deletions

View File

@@ -36,4 +36,28 @@ describe TopicList do
expect(topic_list.preloaded_custom_fields).to eq(Set.new([DiscourseTagging::TAGS_FIELD_NAME]))
end
end
describe '#tags' do
let(:tag) { Fabricate(:tag, topics: [topic]) }
let(:other_tag) { Fabricate(:tag, topics: [topic]) }
it 'should return the right tags' do
output = [tag.name, other_tag.name]
expect(topic_list.tags.sort).to eq(output.sort)
end
describe 'when topic list is filtered by category' do
let(:category) { Fabricate(:category) }
let(:topic) { Fabricate(:topic, category: category) }
let(:tag) { Fabricate(:tag, topics: [topic], categories: [category]) }
let(:topic_list) { TopicList.new('latest', topic.user, [topic], { category: category.id, category_id: category.id }) }
it 'should only return tags allowed in the category' do
other_tag
output = [tag.name]
expect(topic_list.tags).to eq(output)
end
end
end
end