Search in sources :

Example 11 with LoggedUser

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());
}
Also used : Comment(org.mamute.model.Comment) User(org.mamute.model.User) LoggedUser(org.mamute.model.LoggedUser) LoggedUser(org.mamute.model.LoggedUser) RemoveAnythingFlaggedByModerator(org.mamute.model.flag.RemoveAnythingFlaggedByModerator) Test(org.junit.Test)

Example 12 with LoggedUser

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());
}
Also used : Comment(org.mamute.model.Comment) LoggedUser(org.mamute.model.LoggedUser) RemoveAnythingFlaggedByModerator(org.mamute.model.flag.RemoveAnythingFlaggedByModerator) Test(org.junit.Test)

Example 13 with LoggedUser

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());
}
Also used : Answer(org.mamute.model.Answer) Question(org.mamute.model.Question) LoggedUser(org.mamute.model.LoggedUser) AnswerInformation(org.mamute.model.AnswerInformation) Information(org.mamute.model.Information) AnswerInformation(org.mamute.model.AnswerInformation) Test(org.junit.Test)

Example 14 with LoggedUser

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());
}
Also used : Answer(org.mamute.model.Answer) Question(org.mamute.model.Question) LoggedUser(org.mamute.model.LoggedUser) AnswerInformation(org.mamute.model.AnswerInformation) Test(org.junit.Test)

Example 15 with LoggedUser

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));
}
Also used : EnvironmentKarma(org.mamute.brutauth.auth.rules.EnvironmentKarma) MamuteEnvironment(org.mamute.vraptor.environment.MamuteEnvironment) EditAnswerRule(org.mamute.brutauth.auth.rules.EditAnswerRule) ServletContext(javax.servlet.ServletContext) LoggedUser(org.mamute.model.LoggedUser) Test(org.junit.Test)

Aggregations

LoggedUser (org.mamute.model.LoggedUser)36 Test (org.junit.Test)24 Before (org.junit.Before)9 User (org.mamute.model.User)9 InvisibleForUsersRule (org.mamute.dao.InvisibleForUsersRule)7 ServletContext (javax.servlet.ServletContext)6 EnvironmentKarma (org.mamute.brutauth.auth.rules.EnvironmentKarma)6 MamuteEnvironment (org.mamute.vraptor.environment.MamuteEnvironment)6 VRaptorTestResult (br.com.caelum.vraptor.test.VRaptorTestResult)4 Criterion (org.hibernate.criterion.Criterion)4 Answer (org.mamute.model.Answer)4 UserFlow (br.com.caelum.vraptor.test.requestflow.UserFlow)3 EditAnswerRule (org.mamute.brutauth.auth.rules.EditAnswerRule)3 EditQuestionRule (org.mamute.brutauth.auth.rules.EditQuestionRule)3 AnswerInformation (org.mamute.model.AnswerInformation)3 Comment (org.mamute.model.Comment)3 Question (org.mamute.model.Question)3 QuestionInformation (org.mamute.model.QuestionInformation)3 Tag (org.mamute.model.Tag)3 UpdateStatus (org.mamute.model.UpdateStatus)3