changeset 4:76e3d7881a20 draft

fix
author e085711
date Thu, 13 Sep 2012 01:55:14 +0900
parents cb113e610e08
children 64e58e66f793
files app/views/Application/tags/display.html eclipse/classes/BasicTest.class eclipse/classes/data.yml test/BasicTest.java test/data.yml tmp/bytecode/DEV/_app_views_Application_index.html
diffstat 6 files changed, 105 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/app/views/Application/tags/display.html	Thu Sep 13 01:44:23 2012 +0900
+++ b/app/views/Application/tags/display.html	Thu Sep 13 01:55:14 2012 +0900
@@ -1,4 +1,4 @@
-*{ Display a post in one of these modes: 'full','home'or'teaser' }#
+*{ Display a post in one of these modes: 'full','home'or'teaser' }*
 
 <div class="post ${_as == 'teaser' ? 'teaser' :''}">
 
Binary file eclipse/classes/BasicTest.class has changed
--- a/eclipse/classes/data.yml	Thu Sep 13 01:44:23 2012 +0900
+++ b/eclipse/classes/data.yml	Thu Sep 13 01:55:14 2012 +0900
@@ -1,7 +1,68 @@
-# you describe your data using the YAML notation here
-# and then load them using Fixtures.loadModels("data.yml")
+# Test data
+
+User(bob):
+    email:          bob@gmail.com
+    password:       secret
+    fullname:       Bob
+    isAdmin:        true
+    
+User(jeff):
+    email:          jeff@gmail.com
+    password:       secret
+    fullname:       Jeff    
+    
+Post(firstBobPost):
+    title:          About the model layer
+    postedAt:       2009-06-14
+    author:         bob
+    content:        >
+                    The model has a central position in a Play! application. It is the domain-specific 
+                    representation of the information on which the application operates.
+                    
+                    Martin fowler defines it as:
+                        
+                    Responsible for representing concepts of the business, information about the 
+                    business situation, and business rules. State that reflects the business situation 
+                    is controlled and used here, even though the technical details of storing it are 
+                    delegated to the infrastructure. This layer is the heart of business software.
 
-# User(bob):
-#   email: bob@gmail.com
-#   password: secret
-#   fullname: Bob
\ No newline at end of file
+Post(secondBobPost):
+    title:          Just a test of YABE
+    postedAt:       2009-03-25
+    author:         bob
+    content:        >
+                    Well, it's just a test.
+                    
+Post(jeffPost):
+    title:          The MVC application
+    postedAt:       2009-06-06
+    author:         jeff
+    content:        >
+                    A Play! application follows the MVC architectural pattern as applied to the 
+                    architecture of the Web.
+                    
+                    This pattern splits the application into separate layers: the Presentation 
+                    layer and the Model layer. The Presentation layer is further split into a 
+                    View and a Controller layer.
+                    
+Comment(c1):
+    author:         Guest
+    content:        >
+                    You are right !
+    postedAt:       2009-06-14
+    post:           firstBobPost
+    
+Comment(c2):
+    author:         Mike
+    content:        >
+                    I knew that ...
+    postedAt:       2009-06-15
+    post:           firstBobPost    
+    
+Comment(c3):
+    author:         Tom
+    content:        >
+                    This post is useless ?
+    postedAt:       2009-04-05
+    post:           secondBobPost    
+                 
\ No newline at end of file
--- a/test/BasicTest.java	Thu Sep 13 01:44:23 2012 +0900
+++ b/test/BasicTest.java	Thu Sep 13 01:55:14 2012 +0900
@@ -107,7 +107,43 @@
         	
     }
     
-    
+    @Test
+    public void fullTest() {
+    	Fixtures.loadModels("data.yml");
+    	
+        // Count things
+        assertEquals(2, User.count());
+        assertEquals(3, Post.count());
+        assertEquals(3, Comment.count());
+     
+        // Try to connect as users
+        assertNotNull(User.connect("bob@gmail.com", "secret"));
+        assertNotNull(User.connect("jeff@gmail.com", "secret"));
+        assertNull(User.connect("jeff@gmail.com", "badpassword"));
+        assertNull(User.connect("tom@gmail.com", "secret"));
+     
+        // Find all of Bob's posts
+        List<Post> bobPosts = Post.find("author.email", "bob@gmail.com").fetch();
+        assertEquals(2, bobPosts.size());
+     
+        // Find all comments related to Bob's posts
+        List<Comment> bobComments = Comment.find("post.author.email", "bob@gmail.com").fetch();
+        assertEquals(3, bobComments.size());
+     
+        // Find the most recent post
+        Post frontPost = Post.find("order by postedAt desc").first();
+        assertNotNull(frontPost);
+        assertEquals("About the model layer", frontPost.title);
+     
+        // Check that this post has two comments
+        assertEquals(2, frontPost.comments.size());
+     
+        // Post a new comment
+        frontPost.addComment("Jim", "Hello guys");
+        assertEquals(3, frontPost.comments.size());
+        assertEquals(4, Comment.count());
+    	
+    }
     
     
     
--- a/test/data.yml	Thu Sep 13 01:44:23 2012 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-# you describe your data using the YAML notation here
-# and then load them using Fixtures.loadModels("data.yml")
-
-# User(bob):
-#   email: bob@gmail.com
-#   password: secret
-#   fullname: Bob
\ No newline at end of file
Binary file tmp/bytecode/DEV/_app_views_Application_index.html has changed