use of org.mamute.brutauth.auth.rules.EditAnswerRule 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));
}
use of org.mamute.brutauth.auth.rules.EditAnswerRule 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.brutauth.auth.rules.EditAnswerRule in project mamute by caelum.
the class EditAnswerRuleTest method loggedUser_with_low_karma_should_not_be_allowed_to_edit.
@Test
public void loggedUser_with_low_karma_should_not_be_allowed_to_edit() throws IOException {
LoggedUser other = loggedUser("other", "other@brutal.com", NOT_AUTHOR);
ServletContext ctx = mock(ServletContext.class);
EnvironmentKarma env = new EnvironmentKarma(new MamuteEnvironment(ctx));
assertFalse(new EditAnswerRule(other, env).isAllowed(answer));
}
use of org.mamute.brutauth.auth.rules.EditAnswerRule in project mamute by caelum.
the class EditAnswerRuleTest method author_should_be_allowed_to_edit_moderatable.
@Test
public void author_should_be_allowed_to_edit_moderatable() throws IOException {
ServletContext ctx = mock(ServletContext.class);
EnvironmentKarma env = new EnvironmentKarma(new MamuteEnvironment(ctx));
assertTrue(new EditAnswerRule(author, env).isAllowed(answer));
}
Aggregations