Search in sources :

Example 6 with VRaptorTestResult

use of br.com.caelum.vraptor.test.VRaptorTestResult in project mamute by caelum.

the class EditQuestionTest method should_edit_question_of_other_author.

@Test
public void should_edit_question_of_other_author() throws Exception {
    Question question = createQuestionWithDao(moderator(), "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.pending")));
}
Also used : UserFlow(br.com.caelum.vraptor.test.requestflow.UserFlow) Question(org.mamute.model.Question) VRaptorTestResult(br.com.caelum.vraptor.test.VRaptorTestResult) Test(org.junit.Test)

Example 7 with VRaptorTestResult

use of br.com.caelum.vraptor.test.VRaptorTestResult 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());
}
Also used : User(org.mamute.model.User) UserFlow(br.com.caelum.vraptor.test.requestflow.UserFlow) Question(org.mamute.model.Question) VRaptorTestResult(br.com.caelum.vraptor.test.VRaptorTestResult) Test(org.junit.Test)

Example 8 with VRaptorTestResult

use of br.com.caelum.vraptor.test.VRaptorTestResult in project mamute by caelum.

the class ForgotPasswordTest method should_deny_recovery_for_inexistant_email.

@Test
public void should_deny_recovery_for_inexistant_email() {
    UserFlow navigation = tryToSendResetPasswordEmail("unexistant@brutal.com");
    VRaptorTestResult sentEmail = navigation.followRedirect().execute();
    sentEmail.wasStatus(200).isValid();
    List<String> errorsList = errorsList(sentEmail);
    assertTrue(errorsList.contains(message("forgot_password.invalid_email")));
}
Also used : UserFlow(br.com.caelum.vraptor.test.requestflow.UserFlow) VRaptorTestResult(br.com.caelum.vraptor.test.VRaptorTestResult) Test(org.junit.Test)

Example 9 with VRaptorTestResult

use of br.com.caelum.vraptor.test.VRaptorTestResult in project mamute by caelum.

the class SignupTest method should_not_sign_up_with_an_existent_email.

@Test
public void should_not_sign_up_with_an_existent_email() {
    UserFlow navigation = signUp(navigate(), "Marco", "invalidEmail", DEFAULT_PASSWORD, DEFAULT_PASSWORD);
    VRaptorTestResult notSignedUpUser = navigation.followRedirect().execute();
    notSignedUpUser.wasStatus(200).isValid();
    List<String> errorsList = errorsList(notSignedUpUser);
    assertTrue(errorsList.contains(message("user.errors.email.invalid")));
}
Also used : UserFlow(br.com.caelum.vraptor.test.requestflow.UserFlow) VRaptorTestResult(br.com.caelum.vraptor.test.VRaptorTestResult) Test(org.junit.Test)

Example 10 with VRaptorTestResult

use of br.com.caelum.vraptor.test.VRaptorTestResult in project mamute by caelum.

the class SignupTest method should_not_sign_up_with_different_passwords.

@Test
public void should_not_sign_up_with_different_passwords() {
    UserFlow navigation = signUp(navigate(), "Marco", randomEmail(), DEFAULT_PASSWORD, "misspelledPassword");
    VRaptorTestResult notSignedUpUser = navigation.followRedirect().execute();
    notSignedUpUser.wasStatus(200).isValid();
    List<String> errorsList = errorsList(notSignedUpUser);
    assertTrue(errorsList.contains(message("signup.errors.password_confirmation")));
}
Also used : UserFlow(br.com.caelum.vraptor.test.requestflow.UserFlow) VRaptorTestResult(br.com.caelum.vraptor.test.VRaptorTestResult) Test(org.junit.Test)

Aggregations

VRaptorTestResult (br.com.caelum.vraptor.test.VRaptorTestResult)28 UserFlow (br.com.caelum.vraptor.test.requestflow.UserFlow)27 Test (org.junit.Test)27 Question (org.mamute.model.Question)15 User (org.mamute.model.User)9 Elements (org.jsoup.select.Elements)5 Answer (org.mamute.model.Answer)5 LoggedUser (org.mamute.model.LoggedUser)4 ArrayList (java.util.ArrayList)3 AnswerAndVotes (org.mamute.model.AnswerAndVotes)3 DaoManager (org.mamute.integration.util.DaoManager)1 Tag (org.mamute.model.Tag)1