Search in sources :

Example 31 with LoggedUser

use of org.mamute.model.LoggedUser in project mamute by caelum.

the class EditQuestionRuleTest method user_with_enough_karma_should_be_allowed_to_edit.

@Test
public void user_with_enough_karma_should_be_allowed_to_edit() throws IOException {
    LoggedUser userWithEnoughKarma = loggedUser("user", "user@brutal.com", 2l);
    userWithEnoughKarma.getCurrent().increaseKarma(20);
    ServletContext ctx = mock(ServletContext.class);
    EnvironmentKarma env = new EnvironmentKarma(new MamuteEnvironment(ctx));
    assertTrue(new EditQuestionRule(userWithEnoughKarma, env).isAllowed(question));
}
Also used : EnvironmentKarma(org.mamute.brutauth.auth.rules.EnvironmentKarma) MamuteEnvironment(org.mamute.vraptor.environment.MamuteEnvironment) ServletContext(javax.servlet.ServletContext) EditQuestionRule(org.mamute.brutauth.auth.rules.EditQuestionRule) LoggedUser(org.mamute.model.LoggedUser) Test(org.junit.Test)

Example 32 with LoggedUser

use of org.mamute.model.LoggedUser in project mamute by caelum.

the class IndexSyncJob method generateUser.

private InvisibleForUsersRule generateUser() {
    User user = new User(fromTrustedText("System"), "system");
    LoggedUser loggedUser = new LoggedUser(user, null);
    return new InvisibleForUsersRule(loggedUser);
}
Also used : User(org.mamute.model.User) LoggedUser(org.mamute.model.LoggedUser) LoggedUser(org.mamute.model.LoggedUser) InvisibleForUsersRule(org.mamute.dao.InvisibleForUsersRule)

Example 33 with LoggedUser

use of org.mamute.model.LoggedUser in project mamute by caelum.

the class BrutalAdsTest method should_return_true_if_user_not_logged.

@Test
public void should_return_true_if_user_not_logged() {
    LoggedUser loggedUser = new LoggedUser(null, null);
    BrutalAds brutalAds = new BrutalAds(loggedUser);
    assertTrue(brutalAds.shouldShowAds());
}
Also used : BrutalAds(org.mamute.ads.BrutalAds) LoggedUser(org.mamute.model.LoggedUser) Test(org.junit.Test)

Example 34 with LoggedUser

use of org.mamute.model.LoggedUser in project mamute by caelum.

the class UpdaterTest method should_update_if_is_the_author.

@Test
public void should_update_if_is_the_author() {
    QuestionInformation newInformation = new QuestionInformation("title", notMarked("description"), new LoggedUser(author, null));
    UpdateStatus update = updater.update(myQuestion, newInformation);
    assertEquals(UpdateStatus.NO_NEED_TO_APPROVE, update);
    assertTrue(myQuestion.getHistory().contains(newInformation));
}
Also used : UpdateStatus(org.mamute.model.UpdateStatus) LoggedUser(org.mamute.model.LoggedUser) QuestionInformation(org.mamute.model.QuestionInformation) Test(org.junit.Test)

Example 35 with LoggedUser

use of org.mamute.model.LoggedUser in project mamute by caelum.

the class UpdaterTest method should_update_if_is_moderator.

@Test
public void should_update_if_is_moderator() {
    User moderator = user("moderator", "moderator@brutal", nextId()).asModerator();
    QuestionInformation newInformation = new QuestionInformation("title", notMarked("description"), new LoggedUser(moderator, null));
    UpdateStatus update = updater.update(myQuestion, newInformation);
    assertEquals(UpdateStatus.NO_NEED_TO_APPROVE, update);
    assertTrue(myQuestion.getHistory().contains(newInformation));
}
Also used : User(org.mamute.model.User) LoggedUser(org.mamute.model.LoggedUser) UpdateStatus(org.mamute.model.UpdateStatus) LoggedUser(org.mamute.model.LoggedUser) QuestionInformation(org.mamute.model.QuestionInformation) 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