use of org.mamute.vraptor.environment.MamuteEnvironment in project mamute by caelum.
the class UpdaterTest method before_test.
@Before
public void before_test() throws IOException {
ServletContext ctx = mock(ServletContext.class);
EnvironmentKarma env = new EnvironmentKarma(new MamuteEnvironment(ctx));
this.updater = new Updater(env);
author = user("author", "author@gmail", nextId());
myQuestion = question.withTitle("titel").withDescription("description").withAuthor(author).build();
}
use of org.mamute.vraptor.environment.MamuteEnvironment in project mamute by caelum.
the class UserTest method user_with_enough_karma_should_approve_question_information.
@Test
public void user_with_enough_karma_should_approve_question_information() throws Exception {
Information approvedInfo = new QuestionInformation("edited title", notMarked("edited desc"), new LoggedUser(otherUser, null), new ArrayList<Tag>(), "comment");
ServletContext ctx = mock(ServletContext.class);
EnvironmentKarma env = new EnvironmentKarma(new MamuteEnvironment(ctx));
moderatorWannabe.approve(myQuestion, approvedInfo, env);
assertEquals(approvedInfo, myQuestion.getInformation());
assertTrue(myQuestion.getInformation().isModerated());
}
use of org.mamute.vraptor.environment.MamuteEnvironment in project mamute by caelum.
the class UserTest method user_with_enough_karma_should_approve_answer_information.
@Test
public void user_with_enough_karma_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));
moderatorWannabe.approve(answer, approvedInfo, env);
assertEquals(approvedInfo, answer.getInformation());
assertTrue(answer.getInformation().isModerated());
}
use of org.mamute.vraptor.environment.MamuteEnvironment in project mamute by caelum.
the class UserTest method moderator_should_approve_question_information.
@Test
public void moderator_should_approve_question_information() throws Exception {
Information approvedInfo = new QuestionInformation("edited title", notMarked("edited desc"), new LoggedUser(otherUser, null), new ArrayList<Tag>(), "comment");
ServletContext ctx = mock(ServletContext.class);
EnvironmentKarma env = new EnvironmentKarma(new MamuteEnvironment(ctx));
moderator.approve(myQuestion, approvedInfo, env);
assertEquals(approvedInfo, myQuestion.getInformation());
assertTrue(myQuestion.getInformation().isModerated());
}
use of org.mamute.vraptor.environment.MamuteEnvironment 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));
}
Aggregations