mirror of
https://github.com/Govor-team/Govor.git
synced 2026-11-16 20:56:03 +00:00
Add forwarding, friend controls, and benefits
Add message forwarding and reply lookup, friend removal and blocking endpoints, and database-backed Govor+ privileges with customizable profile tags. Include migrations, integration tests, and updated API and operations documentation.
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
using Govor.API.Controllers;
|
||||
using Govor.API.Hubs;
|
||||
using Govor.Application.Infrastructure.Extensions;
|
||||
using Govor.Application.Profiles;
|
||||
using Govor.Contracts.Requests;
|
||||
using Govor.Domain.Models.Users;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
using Moq;
|
||||
|
||||
namespace Govor.API.Tests.Integration.Controllers;
|
||||
|
||||
[TestFixture]
|
||||
public sealed class UserBenefitsControllerTests
|
||||
{
|
||||
[Test]
|
||||
public async Task BroadcastFailureKeepsCommittedGrantSuccessfulAndReadable()
|
||||
{
|
||||
using var db = new TestDatabase();
|
||||
var proxy = new Mock<IClientProxy>();
|
||||
proxy.Setup(x => x.SendCoreAsync("UserBenefitsUpdated", It.IsAny<object[]>(), It.IsAny<CancellationToken>()))
|
||||
.ThrowsAsync(new IOException("SignalR unavailable"));
|
||||
var hub = new Mock<IHubContext<ProfileHub>>();
|
||||
hub.Setup(x => x.Clients.All).Returns(proxy.Object);
|
||||
var benefits = new UserBenefitsService(db.Context);
|
||||
var controller = new UserBenefitsController(benefits, Mock.Of<ICurrentUserService>(), hub.Object,
|
||||
NullLogger<UserBenefitsController>.Instance);
|
||||
var result = await controller.SetPrivileges(db.Alice, new SetPrivilegesRequest(UserPrivileges.GovorPlus));
|
||||
Assert.That(result, Is.TypeOf<OkObjectResult>());
|
||||
Assert.That((await benefits.GetAsync(db.Alice)).IsGovorPlus, Is.True);
|
||||
proxy.Verify(x => x.SendCoreAsync("UserBenefitsUpdated", It.IsAny<object[]>(), It.IsAny<CancellationToken>()), Times.Once);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user