Don't show articles from blocked users in the feed (#13752)

* Update element identifier for blocked articles

* Update confirmation wording

* Add specs
This commit is contained in:
Alex 2021-05-14 03:41:50 -04:00 committed by GitHub
parent 3db711db70
commit 795cf7b10a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 2 deletions

View file

@ -2,7 +2,7 @@
export function hideBlockedContent() {
const contentUserElements = Array.from(
document.querySelectorAll('div[data-content-user-id]'),
document.querySelectorAll('article[data-content-user-id]'),
);
const user = userData(); //global var
const blockedUserIds = user ? user.blocked_user_ids : [];

View file

@ -48,7 +48,8 @@ export function initBlock() {
`Are you sure you want to block this person? This will:
- prevent them from commenting on your posts
- block all notifications from them
- prevent them from messaging you via DEV Connect`,
- prevent them from messaging you via Connect
- hide their posts from your feed`,
);
if (confirmBlock) {
fetch(`/user_blocks`, {

View file

@ -45,5 +45,15 @@ RSpec.describe Articles::Feeds::Basic, type: :service do
result = feed.feed
expect(result).not_to include(hot_story)
end
it "doesn't display blocked articles", type: :system, js: true do
selector = "article[data-content-user-id='#{hot_story.user_id}']"
sign_in user
visit root_path
expect(page).to have_selector(selector, visible: :visible)
create(:user_block, blocker: user, blocked: hot_story.user, config: "default")
visit root_path
expect(page).to have_selector(selector, visible: :hidden)
end
end
end

View file

@ -84,6 +84,16 @@ RSpec.describe Articles::Feeds::LargeForemExperimental, type: :service do
create(:user_block, blocker: user, blocked: second_user, config: "default")
expect(result).not_to include(hot_story)
end
it "doesn't display blocked articles", type: :system, js: true do
selector = "article[data-content-user-id='#{hot_story.user_id}']"
sign_in user
visit root_path
expect(page).to have_selector(selector, visible: :visible)
create(:user_block, blocker: user, blocked: hot_story.user, config: "default")
visit root_path
expect(page).to have_selector(selector, visible: :hidden)
end
end
context "when ranking is true" do