Update Post query for blockedByUsers

- Admin/Moderators see Posts even if they are blocked
This commit is contained in:
mattwr18 2019-10-01 17:45:09 +02:00
parent 13ba93eecd
commit 8aa7f376b6
4 changed files with 46 additions and 7 deletions

View File

@ -30,6 +30,7 @@ export const getBlockedByUsers = async context => {
.relationship(userModel.relationships().get('blocked'))
.to('blocked', userModel)
.where('blocked.id', context.user.id)
.where('blocked.user', 'user')
.return('user')
blockedByUsers = await blockedByUsers.execute()
blockedByUsers = blockedByUsers.records.map(r => r.get('user').properties)

View File

@ -116,7 +116,7 @@ When(/^I confirm the reporting dialog .*:$/, message => {
Given('somebody reported the following posts:', table => {
table.hashes().forEach(({ id }) => {
const submitter = {
email: `submitter${id}@example.org`,
email: `submitter${id}@example.org`,
password: '1234'
}
cy.factory()
@ -143,3 +143,12 @@ Then('each list item links to the post page', () => {
cy.contains(davidIrvingPostTitle).click()
cy.location('pathname').should('contain', '/post')
})
When("they have a post someone has reported", () => {
cy.factory()
.create("Post", {
authorId: 'annnoying-user',
title,
});
})

View File

@ -410,6 +410,21 @@ Given("there is an annoying user called {string}", name => {
});
});
Given("there is an annoying user who has blocked me", () => {
cy.login({ email: 'i-blocked-a-moderator-ha-ha-ha@example.org', password: '1234' })
.neode()
.first("User", {
role: 'moderator'
})
.then(blocked => {
cy.neode()
.first("User", {
name
})
.relateTo(blocked, "blocked");
});
});
Given("I am on the profile page of the annoying user", name => {
cy.openPage("/profile/annoying-user/spammy-spammer");
});

View File

@ -8,13 +8,15 @@ Feature: Report and Moderate
So I can look into it and decide what to do
Background:
Given we have this user in our database:
| id | name |
| u67 | David Irving|
Given we have the following user accounts:
| id | name | email | password |
| u67 | David Irving | david-irving@example.org | 1234 |
| annoying-user | I'm gonna block Moderators and Admins HA HA HA | i-blocked-a-moderator-ha-ha-ha@example.org | 1234 |
Given we have the following posts in our database:
| authorId | id | title | content |
| u67 | p1 | The Truth about the Holocaust | It never existed! |
| authorId | id | title | content |
| u67 | p1 | The Truth about the Holocaust | It never existed! |
| annoying-user | p2 | Fake news | This content is demonstratably infactual in some way |
Scenario Outline: Report a post from various pages
Given I am logged in with a "user" role
When I see David Irving's post on the <Page>
@ -56,6 +58,18 @@ Feature: Report and Moderate
Then I see all the reported posts including the one from above
And each list item links to the post page
Scenario: Even if a user has blocked me, I can see their reported posts
Given somebody reported the following posts:
| id |
| p2 |
And my user account has the role "moderator"
And there is an annoying user who has blocked me
And I am logged in
When I click on the avatar menu in the top right corner
And I click on "Moderation"
Then I see all the reported posts including the one from above
And each list item links to the post page
Scenario: Normal user can't see the moderation page
Given I am logged in with a "user" role
When I click on the avatar menu in the top right corner