Skip to content

Commit

Permalink
Merge pull request #66 from hikarock/add-comment-model
Browse files Browse the repository at this point in the history
Commentモデル新設
  • Loading branch information
hideack committed Apr 13, 2014
2 parents e3edeca + b028e8b commit deb4cdf
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
13 changes: 13 additions & 0 deletions app/models/comment.js
Original file line number Diff line number Diff line change
@@ -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';
23 changes: 23 additions & 0 deletions test/app/models/comment_model_test.js
Original file line number Diff line number Diff line change
@@ -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<maxLength + 1; i++) {
longComment += "A";
}

var comment = new Comment({comment: longComment});
comment.isValid().should.false;
});
});

0 comments on commit deb4cdf

Please sign in to comment.