Example #1
0
 public static void show(Long forumId, Long topicId, Integer page) {
   Topic topic = Topic.findById(topicId);
   notFoundIfNull(topic);
   topic.views = 1;
   topic.save();
   render(topic, page);
 }
Example #2
0
 @SecureAdmin
 public static void createReply(Long forumId, Long topicId, String content) {
   Topic topic = Topic.findById(topicId);
   notFoundIfNull(topic);
   topic.reply(connectedUser(), content);
   show(forumId, topicId, null);
 }
Example #3
0
 @SecureAdmin(admin = true)
 public static void delete(Long forumId, Long topicId) {
   Topic topic = Topic.findById(topicId);
   notFoundIfNull(topic);
   topic.delete();
   flash.success("The topic has been deleted");
   Forums.show(forumId, null);
 }
Example #4
0
 @Test
 public void tryHelpTopic() {
   Topic help = Topic.find("bySubject", "I need help !").first();
   assertNotNull(help);
   assertEquals(3, help.posts.size());
   assertEquals(3L, (long) help.getPostsCount());
   assertEquals(2L, (long) help.getVoicesCount());
   assertEquals("It's ok for me ...", help.getLastPost().content);
   assertEquals("Play help", help.forum.name);
 }
Example #5
0
 @Test
 public void testCascadeDelete() {
   Forum help = Forum.find("byName", "Play help").first();
   assertEquals(4, Topic.count());
   assertEquals(7, Post.count());
   help.delete();
   assertEquals(1, Topic.count());
   assertEquals(1, Post.count());
   User guillaume = User.find("byName", "Guillaume").first();
   assertEquals(0L, (long) guillaume.getTopicsCount());
 }
Example #6
0
 @Test
 public void newTopic() {
   Forum test = new Forum("Test", "Yop");
   User guillaume = User.find("byName", "Guillaume").first();
   test.newTopic(guillaume, "Hello", "Yop ...");
   assertEquals(2L, (long) guillaume.getTopicsCount());
   assertEquals(1, test.topics.size());
   assertEquals(1, test.getTopicsCount());
   assertEquals(5, Topic.count());
 }
Example #7
0
 @Test
 public void countObjects() {
   assertEquals(4, Topic.count());
 }
Example #8
0
 @SecureAdmin
 public static void reply(Long forumId, Long topicId) {
   Topic topic = Topic.findById(topicId);
   notFoundIfNull(topic);
   render(topic);
 }