use of org.mamute.model.Question in project mamute by caelum.
the class QuestionTest method should_verify_that_a_user_already_flagged_question.
@Test
public void should_verify_that_a_user_already_flagged_question() throws Exception {
Question q = question.build();
User author = user("author", "author@brutal.com", 1l);
User other = user("other", "other@brutal.com", 2l);
Flag flag = flag(FlagType.OTHER, author);
q.add(flag);
assertTrue(q.alreadyFlaggedBy(author));
assertFalse(q.alreadyFlaggedBy(other));
}
use of org.mamute.model.Question in project mamute by caelum.
the class QuestionTest method should_update_information_and_tag_usage_count.
@Test
public void should_update_information_and_tag_usage_count() throws Exception {
Tag ruby = tag("ruby");
Tag java = tag("java");
Question q = question.withTag(ruby).build();
QuestionInformation approved = new QuestionInformationBuilder().withTag(java).build();
q.updateApproved(approved);
assertEquals(0l, ruby.getUsageCount().longValue());
assertEquals(1l, java.getUsageCount().longValue());
}
use of org.mamute.model.Question in project mamute by caelum.
the class QuestionTest method should_verify_show_mark_as_solution_rules_for_author.
@Test
public void should_verify_show_mark_as_solution_rules_for_author() throws Exception {
User author = user("Fernanda", "bla@bla.com", 1l);
Question question = question(author);
assertFalse(question.canMarkAsSolution(author));
question.add(answer("", question, author));
assertTrue(question.canMarkAsSolution(author));
}
use of org.mamute.model.Question in project mamute by caelum.
the class QuestionTest method should_be_touched_by_original_author_after_edit.
@Test
public void should_be_touched_by_original_author_after_edit() throws Exception {
User artur = user("artur", "artur@x.com");
artur.setId(1l);
Question comoFaz = question.withTitle("titulo").withDescription("descricao").withAuthor(artur).build();
User leo = user("leo", "leo@x.com");
leo.setId(2l);
QuestionInformation info = new QuestionInformationBuilder().with(leo).build();
comoFaz.updateWith(info, updater);
assertEquals(comoFaz.getLastTouchedBy().getId(), artur.getId());
}
use of org.mamute.model.Question in project mamute by caelum.
the class QuestionTest method should_trim_big_meta.
@Test
public void should_trim_big_meta() throws Exception {
String title = bigString('a', 100);
String description = bigString('b', 10000);
Question q = question.withTitle(title).withDescription(description).build();
assertTrue(q.getMetaDescription().contains(title));
assertFalse(q.getMetaDescription().contains(description));
}
Aggregations