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));
}
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);
}
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());
}
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));
}
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));
}
Aggregations