Search in sources :

Example 1 with EditQuestionRule

use of org.mamute.brutauth.auth.rules.EditQuestionRule 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));
}
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 2 with EditQuestionRule

use of org.mamute.brutauth.auth.rules.EditQuestionRule in project mamute by caelum.

the class EditQuestionRuleTest method moderator_should_be_allowed_to_edit.

@Test
public void moderator_should_be_allowed_to_edit() throws IOException {
    LoggedUser moderator = loggedUser("moderator", "moderator@brutal.com", 2l);
    moderator.getCurrent().asModerator();
    ServletContext ctx = mock(ServletContext.class);
    EnvironmentKarma env = new EnvironmentKarma(new MamuteEnvironment(ctx));
    assertTrue(new EditQuestionRule(moderator, 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 3 with EditQuestionRule

use of org.mamute.brutauth.auth.rules.EditQuestionRule in project mamute by caelum.

the class EditQuestionRuleTest 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 EditQuestionRule(author, 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) Test(org.junit.Test)

Example 4 with EditQuestionRule

use of org.mamute.brutauth.auth.rules.EditQuestionRule 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)

Aggregations

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