Search in sources :

Example 1 with EditAnswerRule

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

Example 2 with EditAnswerRule

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

Example 3 with EditAnswerRule

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

Example 4 with EditAnswerRule

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));
}
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) Test(org.junit.Test)

Aggregations

ServletContext (javax.servlet.ServletContext)4 Test (org.junit.Test)4 EditAnswerRule (org.mamute.brutauth.auth.rules.EditAnswerRule)4 EnvironmentKarma (org.mamute.brutauth.auth.rules.EnvironmentKarma)4 MamuteEnvironment (org.mamute.vraptor.environment.MamuteEnvironment)4 LoggedUser (org.mamute.model.LoggedUser)3