Frontend: fix warnings in withoutAssignedUsers filter
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
committed by
Julius Härtl
parent
a322c7a3b5
commit
090d99a360
@@ -20,10 +20,13 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
/* global app */
|
||||
/* global angular */
|
||||
|
||||
/*
|
||||
* Remove all assignedUsers from users list
|
||||
*/
|
||||
app.filter('withoutAssignedUsers', function ($filter) {
|
||||
app.filter('withoutAssignedUsers', function () {
|
||||
return function (users, assignedUsers) {
|
||||
var _result = [];
|
||||
angular.forEach(users, function (user) {
|
||||
@@ -33,8 +36,9 @@ app.filter('withoutAssignedUsers', function ($filter) {
|
||||
_found = true;
|
||||
}
|
||||
});
|
||||
if (_found === false)
|
||||
if (_found === false) {
|
||||
_result.push(user);
|
||||
}
|
||||
});
|
||||
return _result;
|
||||
};
|
||||
|
||||
@@ -102,6 +102,9 @@ class AssignedUsersMapperTest extends \Test\TestCase {
|
||||
$this->stacks = $stacks;
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
*/
|
||||
public function testConstructor() {
|
||||
$this->assertAttributeInstanceOf(IDBConnection::class, 'db', $this->assignedUsersMapper);
|
||||
$this->assertAttributeEquals(AssignedUsers::class, 'entityClass', $this->assignedUsersMapper);
|
||||
|
||||
@@ -24,10 +24,12 @@
|
||||
namespace OCA\Deck\Service;
|
||||
|
||||
|
||||
use OCA\Deck\Db\AssignedUsers;
|
||||
use OCA\Deck\Db\AssignedUsersMapper;
|
||||
use OCA\Deck\Db\Card;
|
||||
use OCA\Deck\Db\CardMapper;
|
||||
use OCA\Deck\Db\StackMapper;
|
||||
use OCA\Deck\NotFoundException;
|
||||
use OCA\Deck\StatusException;
|
||||
use Test\TestCase;
|
||||
|
||||
@@ -240,5 +242,74 @@ class CardServiceTest extends TestCase {
|
||||
$this->cardService->removeLabel(123, 999);
|
||||
}
|
||||
|
||||
public function testAssignUser() {
|
||||
$assignments = [];
|
||||
$this->assignedUsersMapper->expects($this->once())
|
||||
->method('find')
|
||||
->with(123)
|
||||
->willReturn($assignments);
|
||||
$assignment = new AssignedUsers();
|
||||
$assignment->setCardId(123);
|
||||
$assignment->setParticipant('admin');
|
||||
$this->assignedUsersMapper->expects($this->once())
|
||||
->method('insert')
|
||||
->with($assignment)
|
||||
->willReturn($assignment);
|
||||
$actual = $this->cardService->assignUser(123, 'admin');
|
||||
$this->assertEquals($assignment, $actual);
|
||||
}
|
||||
|
||||
public function testAssignUserExisting() {
|
||||
$assignment = new AssignedUsers();
|
||||
$assignment->setCardId(123);
|
||||
$assignment->setParticipant('admin');
|
||||
$assignments = [
|
||||
$assignment
|
||||
];
|
||||
$this->assignedUsersMapper->expects($this->once())
|
||||
->method('find')
|
||||
->with(123)
|
||||
->willReturn($assignments);
|
||||
$actual = $this->cardService->assignUser(123, 'admin');
|
||||
$this->assertFalse($actual);
|
||||
}
|
||||
|
||||
public function testUnassignUserExisting() {
|
||||
$assignment = new AssignedUsers();
|
||||
$assignment->setCardId(123);
|
||||
$assignment->setParticipant('admin');
|
||||
$assignments = [
|
||||
$assignment
|
||||
];
|
||||
$this->assignedUsersMapper->expects($this->once())
|
||||
->method('find')
|
||||
->with(123)
|
||||
->willReturn($assignments);
|
||||
$this->assignedUsersMapper->expects($this->once())
|
||||
->method('delete')
|
||||
->with($assignment)
|
||||
->willReturn($assignment);
|
||||
$actual = $this->cardService->unassignUser(123, 'admin');
|
||||
$this->assertEquals($assignment, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \OCA\Deck\NotFoundException
|
||||
*/
|
||||
public function testUnassignUserNotExisting() {
|
||||
$assignment = new AssignedUsers();
|
||||
$assignment->setCardId(123);
|
||||
$assignment->setParticipant('admin');
|
||||
$assignments = [
|
||||
$assignment
|
||||
];
|
||||
$this->assignedUsersMapper->expects($this->once())
|
||||
->method('find')
|
||||
->with(123)
|
||||
->willReturn($assignments);
|
||||
$actual = $this->cardService->unassignUser(123, 'user');
|
||||
$this->assertEquals($assignment, $actual);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user