use of org.mamute.model.LoggedUser in project mamute by caelum.
the class EditAnswerRuleTest method moderator_should_be_allowed_to_edit.
@Test
public void moderator_should_be_allowed_to_edit() throws IOException {
LoggedUser loggedUser = loggedUser("moderator", "moderator@brutal.com", NOT_AUTHOR);
loggedUser.getCurrent().asModerator();
ServletContext ctx = mock(ServletContext.class);
EnvironmentKarma env = new EnvironmentKarma(new MamuteEnvironment(ctx));
assertTrue(new EditAnswerRule(loggedUser, env).isAllowed(answer));
}
use of org.mamute.model.LoggedUser in project mamute by caelum.
the class EditQuestionRuleTest method user_with_low_karma_should_not_be_allowed_to_edit.
@Test
public void user_with_low_karma_should_not_be_allowed_to_edit() throws IOException {
LoggedUser other = loggedUser("other", "other@brutal.com", 3l);
ServletContext ctx = mock(ServletContext.class);
EnvironmentKarma env = new EnvironmentKarma(new MamuteEnvironment(ctx));
assertFalse(new EditQuestionRule(other, env).isAllowed(question));
}
use of org.mamute.model.LoggedUser in project mamute by caelum.
the class NewsBuilder method build.
public News build() {
if (loggedUser == null) {
loggedUser = new LoggedUser(author, null);
}
NewsInformation newsInformation = new NewsInformation(title, description, loggedUser, comment);
News news = new News(newsInformation, author);
setId(news, id);
return news;
}
use of org.mamute.model.LoggedUser in project mamute by caelum.
the class BrutalAdsTest method should_return_true_if_user_have_less_then_50_karma.
@Test
public void should_return_true_if_user_have_less_then_50_karma() {
User user = user("Leo", "leo@leo.com");
user.increaseKarma(20);
LoggedUser loggedUser = new LoggedUser(user, null);
BrutalAds brutalAds = new BrutalAds(loggedUser);
assertTrue(brutalAds.shouldShowAds());
}
use of org.mamute.model.LoggedUser in project mamute by caelum.
the class AuthTest method should_log_in.
@Test
public void should_log_in() {
User user = randomUser();
UserFlow navigation = login(navigate(), user.getEmail());
VRaptorTestResult loginResult = navigation.followRedirect().execute();
loginResult.wasStatus(200).isValid();
LoggedUser loggedUser = loginResult.getObject("currentUser");
User currentUser = loggedUser.getCurrent();
assertThat(currentUser.getId(), equalTo(user.getId()));
}
Aggregations