mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Merge pull request #5655 from techAPJ/pm-tags-dropdown
FEATURE: filter personal messages by tags
This commit is contained in:
@@ -96,6 +96,28 @@ describe Tag do
|
||||
end
|
||||
end
|
||||
|
||||
describe '#pm_tags' do
|
||||
before do
|
||||
@private_tags = []
|
||||
personal_message = Fabricate(:private_message_topic)
|
||||
2.times { |i| @private_tags << Fabricate(:tag, topics: [personal_message]) }
|
||||
end
|
||||
|
||||
it "returns nothing if user is not a staff" do
|
||||
expect(described_class.pm_tags.sort).to be_empty
|
||||
end
|
||||
|
||||
it "returns nothing if allow_staff_to_tag_pms setting is disabled" do
|
||||
SiteSetting.allow_staff_to_tag_pms = false
|
||||
expect(described_class.pm_tags(guardian: Guardian.new(Fabricate(:admin))).sort).to be_empty
|
||||
end
|
||||
|
||||
it "returns all pm tags if user is a staff and pm tagging is enabled" do
|
||||
SiteSetting.allow_staff_to_tag_pms = true
|
||||
expect(described_class.pm_tags(guardian: Guardian.new(Fabricate(:admin)))).to match_array(@private_tags.map(&:name))
|
||||
end
|
||||
end
|
||||
|
||||
context "topic counts" do
|
||||
it "should exclude private message topics" do
|
||||
topic
|
||||
|
||||
@@ -78,4 +78,28 @@ describe TopicList do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#pm_tags' do
|
||||
let(:admin) { Fabricate(:admin) }
|
||||
let(:personal_message) { Fabricate(:private_message_topic) }
|
||||
|
||||
before do
|
||||
SiteSetting.tagging_enabled = true
|
||||
SiteSetting.allow_staff_to_tag_pms = true
|
||||
@private_tags = []
|
||||
2.times { |i| @private_tags << Fabricate(:tag, topics: [personal_message]) }
|
||||
end
|
||||
|
||||
context 'when viewed as normal user' do
|
||||
it 'returns no tags' do
|
||||
expect(TopicList.new('liked', personal_message.user, [personal_message], show_pm_tags: true).pm_tags).to be_empty
|
||||
end
|
||||
end
|
||||
|
||||
context 'when viewed as admin' do
|
||||
it 'returns pm tags' do
|
||||
expect(TopicList.new('liked', admin, [personal_message], show_pm_tags: true).pm_tags).to match_array(@private_tags.map(&:name))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user