Search in sources :

Example 6 with MamuteEnvironment

use of org.mamute.vraptor.environment.MamuteEnvironment 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 7 with MamuteEnvironment

use of org.mamute.vraptor.environment.MamuteEnvironment 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 8 with MamuteEnvironment

use of org.mamute.vraptor.environment.MamuteEnvironment 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 9 with MamuteEnvironment

use of org.mamute.vraptor.environment.MamuteEnvironment 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)

Example 10 with MamuteEnvironment

use of org.mamute.vraptor.environment.MamuteEnvironment 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)

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