Merge branch '962-check-blog-subscription-when-removing-contact' into 'master'

Check personal blog subscription when removing contact

See merge request !549
This commit is contained in:
Torsten Grote
2017-06-30 20:57:52 +00:00
2 changed files with 22 additions and 1 deletions

View File

@@ -116,7 +116,7 @@ class BlogManagerImpl extends BdfIncomingMessageHook implements BlogManager,
@Override
public void removingContact(Transaction txn, Contact c) throws DbException {
Blog b = blogFactory.createBlog(c.getAuthor());
removeBlog(txn, b);
if (db.containsGroup(txn, b.getId())) removeBlog(txn, b);
}
@Override

View File

@@ -157,6 +157,8 @@ public class BlogManagerImplTest extends BriarTestCase {
context.checking(new Expectations() {{
oneOf(blogFactory).createBlog(blog2.getAuthor());
will(returnValue(blog2));
oneOf(db).containsGroup(txn, blog2.getId());
will(returnValue(true));
oneOf(identityManager).getLocalAuthor(txn);
will(returnValue(blog1.getAuthor()));
oneOf(db).removeGroup(txn, blog2.getGroup());
@@ -166,6 +168,25 @@ public class BlogManagerImplTest extends BriarTestCase {
context.assertIsSatisfied();
}
@Test
public void testRemovingContactAfterRemovingBlog() throws DbException {
final Transaction txn = new Transaction(null, false);
final ContactId contactId = new ContactId(0);
Contact contact = new Contact(contactId, blog2.getAuthor(),
blog1.getAuthor().getId(), true, true);
context.checking(new Expectations() {{
oneOf(blogFactory).createBlog(blog2.getAuthor());
will(returnValue(blog2));
oneOf(db).containsGroup(txn, blog2.getId());
will(returnValue(false));
}});
blogManager.removingContact(txn, contact);
context.assertIsSatisfied();
}
@Test
public void testIncomingMessage() throws DbException, FormatException {
final Transaction txn = new Transaction(null, false);