use of org.mamute.model.User in project mamute by caelum.
the class AuthTest method should_not_log_in_with_invalid_user.
@Test
public void should_not_log_in_with_invalid_user() {
UserFlow navigation = login(navigate(), "invalidEmail");
VRaptorTestResult loginResult = navigation.followRedirect().execute();
loginResult.wasStatus(200).isValid();
LoggedUser loggedUser = loginResult.getObject("currentUser");
User currentUser = loggedUser.getCurrent();
assertThat(currentUser, equalTo(User.GHOST));
}
use of org.mamute.model.User in project mamute by caelum.
the class CommentAnswerTest method should_comment_answer_after_login.
@Test
public void should_comment_answer_after_login() throws Exception {
User moderator = moderator();
Question question = createQuestionWithDao(moderator, "Should comment answer after login", "Yeah, definitely should, who're you to say otherwise?", tag("java"));
Answer answer = answerQuestionWithDao(karmaNigga(), question, "I'm de guy with lots of karma, nigga! So get over here!", false);
String comment = "Oh, right, then I can't do a thing about it.";
UserFlow navigation = login(navigate(), moderator.getEmail());
navigation = commentWithFlow(navigation, answer, comment, false);
VRaptorTestResult commentResult = navigation.followRedirect().execute();
// COULD NOT COMPILE JSP
commentResult.wasStatus(200).isValid();
navigation = login(navigate(), moderator.getEmail());
navigation = goToQuestionPage(navigation, question);
VRaptorTestResult commentedAnswer = navigation.followRedirect().execute();
commentedAnswer.wasStatus(200).isValid();
Elements commentElement = getElementsByClass(commentedAnswer.getResponseBody(), "comment-container");
Elements commentSpan = getElementsByTag(commentElement.html(), "span");
Elements commentParagraph = getElementsByTag(commentSpan.html(), "p");
assertEquals(comment, commentParagraph.html());
}
use of org.mamute.model.User in project mamute by caelum.
the class EditQuestionTest method should_touch_question.
@Test
public void should_touch_question() throws Exception {
User user = new DaoManager().randomUser();
Question question = createQuestionWithDao(user(user.getEmail()), "Question question question question question", "Description description description description description", tag("java"));
UserFlow navigation = login(navigate(), user.getEmail());
navigation = editQuestionWithFlow(navigation, question, "ASdoA sodi aosido iasod iOASIDoIASOdi", "asd oiasudo iausdoi uasoid uaosiduasoduoasi udaiosud oiasud oiasud oisa", "so diaos diaosi d", "java");
VRaptorTestResult editedQuestion = navigation.followRedirect().execute();
editedQuestion.wasStatus(200).isValid();
Elements questionElements = getElementsByClass(editedQuestion.getResponseBody(), "edited-touch");
Elements touchImage = getElementsByTag(questionElements.html(), "img");
assertTrue(touchImage.isEmpty());
navigation = login(navigate(), moderator().getEmail());
navigation = editQuestionWithFlow(navigation, question, "Question question question question question", "Description description description description description", "new comment", "java");
editedQuestion = navigation.followRedirect().execute();
editedQuestion.wasStatus(200).isValid();
questionElements = getElementsByClass(editedQuestion.getResponseBody(), "edited-touch");
touchImage = getElementsByTag(questionElements.html(), "img");
assertFalse(touchImage.isEmpty());
}
use of org.mamute.model.User in project mamute by caelum.
the class EditQuestionTest method should_edit_and_automatically_approve_author_edit.
@Test
public void should_edit_and_automatically_approve_author_edit() throws Exception {
User karmaNigga = karmaNigga();
Question question = createQuestionWithDao(karmaNigga, "Title title title title title title title", "Description description description description description", tag("java"));
String newTitle = "NEW title title title title title title title";
String newDescription = "NEW description description description description description";
UserFlow navigation = login(navigate(), karmaNigga.getEmail());
navigation = editQuestionWithFlow(navigation, question, newTitle, newDescription, "edited question woots!", "java");
VRaptorTestResult editedQuestion = navigation.followRedirect().execute();
editedQuestion.wasStatus(200).isValid();
List<String> messagesList = messagesList(editedQuestion);
assertTrue(messagesList.contains(message("status.no_need_to_approve")));
Question fetchQuestion = editedQuestion.getObject("question");
assertEquals(newTitle, fetchQuestion.getTitle());
assertEquals(newDescription, fetchQuestion.getDescription());
}
use of org.mamute.model.User in project mamute by caelum.
the class SignupController method signup.
@Post
public void signup(String email, String password, SanitizedText name, String passwordConfirmation) {
checkSignup();
User newUser = new User(name, email);
LoginMethod brutalLogin = LoginMethod.brutalLogin(newUser, email, password);
newUser.add(brutalLogin);
validator.validate(newUser, password, passwordConfirmation);
result.include("email", email);
result.include("name", name);
validator.onErrorRedirectTo(this).signupForm();
users.save(newUser);
loginMethods.save(brutalLogin);
result.include("mamuteMessages", asList(messageFactory.build("confirmation", "signup.confirmation")));
linker.linkTo(ListController.class).home(null);
result.forwardTo(AuthController.class).login(email, password, linker.get());
}
Aggregations