diff options
author | David Yip <yipdw@member.fsf.org> | 2018-06-12 19:28:08 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-12 19:28:08 -0500 |
commit | f1bfcb50f0baeecf445bfdcf2852b3826d0d3cc0 (patch) | |
tree | 83c564879534ea35f468ce319342e011773f24aa /spec/lib | |
parent | f6bb50b6ece555af138df164680189b1ec57da4b (diff) | |
parent | 5cff053944b4327477ca45882c9dd3b1a7a559e8 (diff) |
Merge pull request #531 from glitch-soc/454-allow-keyword-mutes-to-skip-mentions
Allow keyword mutes to skip mentions (#454)
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/feed_manager_spec.rb | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/spec/lib/feed_manager_spec.rb b/spec/lib/feed_manager_spec.rb index 3f91bba4e..db9bf12d1 100644 --- a/spec/lib/feed_manager_spec.rb +++ b/spec/lib/feed_manager_spec.rb @@ -175,7 +175,7 @@ RSpec.describe FeedManager do it 'returns true for a status with a tag that matches a muted keyword' do Fabricate('Glitch::KeywordMute', account: alice, keyword: 'jorts') status = Fabricate(:status, account: bob) - status.tags << Fabricate(:tag, name: 'jorts') + status.tags << Fabricate(:tag, name: 'jorts') expect(FeedManager.instance.filter?(:home, status, alice.id)).to be true end @@ -183,10 +183,18 @@ RSpec.describe FeedManager do it 'returns true for a status with a tag that matches an octothorpe-prefixed muted keyword' do Fabricate('Glitch::KeywordMute', account: alice, keyword: '#jorts') status = Fabricate(:status, account: bob) - status.tags << Fabricate(:tag, name: 'jorts') + status.tags << Fabricate(:tag, name: 'jorts') expect(FeedManager.instance.filter?(:home, status, alice.id)).to be true end + + it 'returns false if the status is muted by a keyword mute that does not apply to mentions' do + Fabricate('Glitch::KeywordMute', account: alice, keyword: 'take', apply_to_mentions: false) + status = Fabricate(:status, spoiler_text: 'This is a hot take', account: bob) + status.mentions.create!(account_id: alice.id) + + expect(FeedManager.instance.filter?(:home, status, alice.id)).to be false + end end context 'for mentions feed' do @@ -222,6 +230,13 @@ RSpec.describe FeedManager do bob.follow!(alice) expect(FeedManager.instance.filter?(:mentions, status, bob.id)).to be true end + + it 'returns false for a mention that contains a word muted by a keyword that does not apply to mentions' do + Fabricate('Glitch::KeywordMute', account: bob, keyword: 'take', apply_to_mentions: false) + status = Fabricate(:status, text: 'This is a hot take', account: alice) + bob.follow!(alice) + expect(FeedManager.instance.filter?(:mentions, status, bob.id)).to be false + end end end |