From 9aea51fe7e0c2647a477be8edf6b4882c9a1c1f9 Mon Sep 17 00:00:00 2001 From: hideack Date: Sun, 13 Apr 2014 10:30:10 +0900 Subject: [PATCH 1/2] =?UTF-8?q?Comment=E3=83=A2=E3=83=87=E3=83=AB=E6=96=B0?= =?UTF-8?q?=E8=A8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/comment.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 app/models/comment.js diff --git a/app/models/comment.js b/app/models/comment.js new file mode 100644 index 0000000..5467925 --- /dev/null +++ b/app/models/comment.js @@ -0,0 +1,13 @@ +var Base = require('./base'); + +module.exports = Base.extend({ + validate: function(attrs, options) { + if (attrs.comment.length > 512) { + return "comment length too large."; + } + }, + url: '/castoapi/comment/:unique', + api: 'storyboards', + idAttribute: 'unique' +}); +module.exports.id = 'Comment'; From b028e8b07d6288092cbdd6662c764853682a2617 Mon Sep 17 00:00:00 2001 From: hideack Date: Sun, 13 Apr 2014 10:30:30 +0900 Subject: [PATCH 2/2] =?UTF-8?q?Comment=E3=83=A2=E3=83=87=E3=83=AB=E7=94=A8?= =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/app/models/comment_model_test.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 test/app/models/comment_model_test.js diff --git a/test/app/models/comment_model_test.js b/test/app/models/comment_model_test.js new file mode 100644 index 0000000..a0ea7ca --- /dev/null +++ b/test/app/models/comment_model_test.js @@ -0,0 +1,23 @@ +var Comment = require('../../../app/models/comment'), + should = require('should'); + +describe('Comment model spec', function() { + it('should be settable code.', function() { + var comment = new Comment({comment: "test comment"}); + comment.get("comment").should.equal('test comment'); + }); + + it('should be raise error set long comment.', function() { + var longComment = "", + i=0, + maxLength = 1024; + + for(i=0; i