Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commentモデル新設 #66

Merged
merged 2 commits into from
Apr 13, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
});
});