use of org.mamute.model.LoggedUser in project mamute by caelum.
the class RemoveAnythingFlaggedByModeratorTest method should_not_handle_normal_user.
@Test
public void should_not_handle_normal_user() throws Exception {
User normal = user("normal", "normal@brutal.com");
RemoveAnythingFlaggedByModerator removeFlaggedByModerator = new RemoveAnythingFlaggedByModerator(new LoggedUser(normal, null));
Comment comment = comment(author, "blablablablba");
assertFalse(removeFlaggedByModerator.shouldHandle(comment));
assertTrue(comment.isVisible());
}
use of org.mamute.model.LoggedUser in project mamute by caelum.
the class RemoveAnythingFlaggedByModeratorTest method should_not_handle_not_logged_user.
@Test
public void should_not_handle_not_logged_user() throws Exception {
RemoveAnythingFlaggedByModerator removeFlaggedByModerator = new RemoveAnythingFlaggedByModerator(new LoggedUser(null, null));
Comment comment = comment(author, "blablablablba");
assertFalse(removeFlaggedByModerator.shouldHandle(comment));
assertTrue(comment.isVisible());
}
use of org.mamute.model.LoggedUser in project mamute by caelum.
the class AnswerTest method should_approve_answer_info.
@Test
public void should_approve_answer_info() throws Exception {
Question myQuestion = question.withTitle("question title").withDescription("description").withAuthor(author).build();
Answer answer = answer("blablablab", myQuestion, author);
Information approved = new AnswerInformation(notMarked("blablabalblab"), new LoggedUser(editUser, null), answer, "");
answer.approve(approved);
assertEquals(approved, answer.getInformation());
assertEquals(editUser, answer.getLastTouchedBy());
}
use of org.mamute.model.LoggedUser in project mamute by caelum.
the class AnswerTest method return_true_if_answer_has_pending_edits.
@Test
public void return_true_if_answer_has_pending_edits() throws Exception {
Question myQuestion = question.withTitle("question title").withDescription("description").withAuthor(author).build();
Answer answer = answer("blablablab", myQuestion, author);
assertFalse(answer.hasPendingEdits());
AnswerInformation approved = new AnswerInformation(notMarked("blablabalblab"), new LoggedUser(editUser, null), answer, "");
answer.enqueueChange(approved, PENDING);
assertTrue(answer.hasPendingEdits());
}
use of org.mamute.model.LoggedUser in project mamute by caelum.
the class EditAnswerRuleTest method loggedUser_with_enough_karma_should_be_allowed_to_edit.
@Test
public void loggedUser_with_enough_karma_should_be_allowed_to_edit() throws IOException {
LoggedUser loggedUserWithEnoughKarma = loggedUser("loggedUser", "loggedUser@brutal.com", NOT_AUTHOR);
loggedUserWithEnoughKarma.getCurrent().increaseKarma(20);
ServletContext ctx = mock(ServletContext.class);
EnvironmentKarma env = new EnvironmentKarma(new MamuteEnvironment(ctx));
assertTrue(new EditAnswerRule(loggedUserWithEnoughKarma, env).isAllowed(answer));
}
Aggregations