use of org.mamute.model.Tag in project mamute by caelum.
the class ListController method withTag.
@Get
public void withTag(String tagName, Integer p, boolean semRespostas) {
Integer page = getPage(p);
Tag tag = tags.findByName(tagName);
if (tag == null) {
result.notFound();
return;
}
List<Question> questionsWithTag = questions.withTagVisible(tag, page, semRespostas);
result.include("totalPages", questions.numberOfPages(tag));
result.include("tag", tag);
result.include("recentTags", recentTagsContainer.getRecentTagsUsage());
result.include("questions", questionsWithTag);
result.include("currentPage", page);
result.include("hasAbout", tags.hasAbout(tag));
if (semRespostas) {
result.include("unansweredActive", true);
result.include("noDefaultActive", true);
result.include("unansweredTagLinks", true);
}
}
use of org.mamute.model.Tag in project mamute by caelum.
the class TagPageDAOTest method should_get_tag_page_by_tag.
@Test
public void should_get_tag_page_by_tag() {
TagPageDAO tagPages = new TagPageDAO(session);
Tag java = tag("java");
session.save(java);
tagPages.save(new TagPage(java, notMarked("aboutaboutaboutaboutaboutaboutaboutaboutaboutaboutaboutaboutaboutaboutaboutaboutaboutaboutaboutabout")));
TagPage javaPage = tagPages.findByTag(java.getName());
assertEquals(java.getName(), javaPage.getTagName());
}
use of org.mamute.model.Tag in project mamute by caelum.
the class AttachmentRepositoryTest method should_detach_from_answer.
@Test
public void should_detach_from_answer() {
final User author = user("question owner", "question@owner.local");
session.save(author);
final Attachment attachment = createAttachment("test");
attachmentRepository.save(attachment);
final Tag tag = tag("testtag");
session.save(tag);
final Question question = question(author, tag);
session.save(question);
final Answer answer = answer("answer answer answer answer answer", question, author);
answer.getAttachments().add(attachment);
session.save(answer);
attachmentRepository.delete(answer.getAttachments());
assertEquals(0, answer.getAttachments().size());
}
use of org.mamute.model.Tag in project mamute by caelum.
the class AttachmentRepositoryTest method should_detach_from_question.
@Test
public void should_detach_from_question() {
final User author = user("question owner", "question@owner.local");
session.save(author);
final Attachment attachment = createAttachment("test");
attachmentRepository.save(attachment);
final Tag tag = tag("testtag");
session.save(tag);
final Question question = question(author, tag);
question.getAttachments().add(attachment);
session.save(question);
attachmentRepository.delete(question.getAttachments());
assertEquals(0, question.getAttachments().size());
}
use of org.mamute.model.Tag 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());
}
Aggregations