-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:caelum/brutal
- Loading branch information
Showing
32 changed files
with
897 additions
and
234 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,3 +27,4 @@ src/main/webapp/font/ | |
src/main/webapp/js/jquery/jquery-plugins*.js | ||
versions.txt | ||
/target | ||
jsp-compilation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 0 additions & 75 deletions
75
src/integration/java/br/com/caelum/brutal/integration/scene/EditAnswerTest.java
This file was deleted.
Oops, something went wrong.
81 changes: 81 additions & 0 deletions
81
src/integration/java/br/com/caelum/brutal/integration/scene/vraptor/AnswerQuestionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package br.com.caelum.brutal.integration.scene.vraptor; | ||
|
||
import static br.com.caelum.vraptor.test.http.Parameters.initWith; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.jsoup.select.Elements; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import br.com.caelum.brutal.model.Answer; | ||
import br.com.caelum.brutal.model.AnswerAndVotes; | ||
import br.com.caelum.brutal.model.Question; | ||
import br.com.caelum.vraptor.test.VRaptorTestResult; | ||
import br.com.caelum.vraptor.test.requestflow.UserFlow; | ||
|
||
public class AnswerQuestionTest extends CustomVRaptorIntegration { | ||
|
||
@Test | ||
public void should_answer_when_logged_in() { | ||
Question question = createQuestionWithDao(moderator(), | ||
"Titulo da questao hahaha", | ||
"Descricao da questao longa demais", tag("java")); | ||
|
||
String description = "Resposta da questao do teste de edicao"; | ||
|
||
UserFlow navigation = login(navigate(), "karma.nigga@caelum.com.br"); | ||
navigation = answerQuestionWithFlow(navigation, question, description, false); | ||
|
||
VRaptorTestResult questionAnswered = navigation.followRedirect().execute(); | ||
questionAnswered.wasStatus(200).isValid(); | ||
|
||
AnswerAndVotes answerAndVotes = questionAnswered.getObject("answers"); | ||
List<Answer> answers = new ArrayList<Answer>(answerAndVotes.getVotes().keySet()); | ||
Assert.assertEquals(description, answers.get(0).getDescription()); | ||
} | ||
|
||
@Test | ||
public void should_not_display_answer_form_when_not_logged_in() { | ||
Question question = createQuestionWithDao(moderator(), | ||
"Titulo da questao hahaha", | ||
"Descricao da questao longa demais", tag("java")); | ||
|
||
UserFlow navigation = goToQuestionPage(navigate(), question); | ||
|
||
VRaptorTestResult questionPage = navigation.followRedirect().execute(); | ||
questionPage.wasStatus(200).isValid(); | ||
|
||
Elements answerForm = getElementsByClass(questionPage.getResponseBody(), "answer-form"); | ||
assertTrue(answerForm.isEmpty()); | ||
} | ||
|
||
@Test | ||
public void should_not_display_answer_form_when_already_answered() { | ||
Question question = createQuestionWithDao(moderator(), | ||
"Titulo da questao hahaha", | ||
"Descricao da questao longa demais", tag("java")); | ||
|
||
answerQuestionWithDao(karmaNigga(), question, | ||
"Resposta da questao do teste de edicao", false); | ||
|
||
UserFlow navigation = login(navigate(), "karma.nigga@caelum.com.br"); | ||
navigation = goToQuestionPage(navigation, question); | ||
|
||
VRaptorTestResult questionPage = navigation.followRedirect().execute(); | ||
questionPage.wasStatus(200).isValid(); | ||
|
||
Elements answerForm = getElementsByClass(questionPage.getResponseBody(), "answer-form"); | ||
assertTrue(answerForm.isEmpty()); | ||
} | ||
|
||
private UserFlow goToQuestionPage(UserFlow navigation, Question question) { | ||
String url = String.format("/%s-mock", question.getId()); | ||
return navigation.get(url, | ||
initWith("question", question) | ||
.add("sluggedTitle", question.getSluggedTitle())); | ||
} | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
src/integration/java/br/com/caelum/brutal/integration/scene/vraptor/CommentAnswerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package br.com.caelum.brutal.integration.scene.vraptor; | ||
|
||
import org.junit.Test; | ||
|
||
public class CommentAnswerTest extends CustomVRaptorIntegration { | ||
|
||
@Test | ||
public void should_comment_answer_after_login() throws Exception { | ||
|
||
} | ||
} |
Oops, something went wrong.