Search in sources :

Example 11 with EnvironmentKarma

use of org.mamute.brutauth.auth.rules.EnvironmentKarma 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 12 with EnvironmentKarma

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

Example 13 with EnvironmentKarma

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

the class QuestionTest method setup.

@Before
public void setup() throws IOException {
    ServletContext ctx = mock(ServletContext.class);
    EnvironmentKarma env = new EnvironmentKarma(new MamuteEnvironment(ctx));
    this.updater = new Updater(env);
}
Also used : EnvironmentKarma(org.mamute.brutauth.auth.rules.EnvironmentKarma) MamuteEnvironment(org.mamute.vraptor.environment.MamuteEnvironment) ServletContext(javax.servlet.ServletContext) Before(org.junit.Before)

Example 14 with EnvironmentKarma

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

the class UserTest method moderator_should_approve_answer_information.

@Test
public void moderator_should_approve_answer_information() throws Exception {
    Answer answer = answer("answer description", myQuestion, author);
    AnswerInformation approvedInfo = answerInformation("new description", otherUser, answer);
    ServletContext ctx = mock(ServletContext.class);
    EnvironmentKarma env = new EnvironmentKarma(new MamuteEnvironment(ctx));
    moderator.approve(answer, approvedInfo, env);
    assertEquals(approvedInfo, answer.getInformation());
    assertTrue(answer.getInformation().isModerated());
}
Also used : EnvironmentKarma(org.mamute.brutauth.auth.rules.EnvironmentKarma) MamuteEnvironment(org.mamute.vraptor.environment.MamuteEnvironment) ServletContext(javax.servlet.ServletContext) Test(org.junit.Test)

Aggregations

ServletContext (javax.servlet.ServletContext)14 EnvironmentKarma (org.mamute.brutauth.auth.rules.EnvironmentKarma)14 MamuteEnvironment (org.mamute.vraptor.environment.MamuteEnvironment)14 Test (org.junit.Test)12 LoggedUser (org.mamute.model.LoggedUser)6 EditAnswerRule (org.mamute.brutauth.auth.rules.EditAnswerRule)4 EditQuestionRule (org.mamute.brutauth.auth.rules.EditQuestionRule)4 Before (org.junit.Before)2 Updater (org.mamute.model.Updater)1