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

コメントモデルにownerフラグ追加 #73

Merged
merged 2 commits into from
Jun 1, 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
4 changes: 4 additions & 0 deletions app/models/comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ module.exports = Base.extend({
if (attrs.comment.length > 512) {
return "comment length too large.";
}

if (typeof attrs.owner != 'boolean') {
return "need owner flag.";
}
},
url: '/castoapi/comment/:unique',
api: 'storyboards',
Expand Down
8 changes: 7 additions & 1 deletion test/app/models/comment_model_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ var Comment = require('../../../app/models/comment'),

describe('Comment model spec', function() {
it('should be settable code.', function() {
var comment = new Comment({comment: "test comment"});
var comment = new Comment({comment: "test comment", owner: true});
comment.get("comment").should.equal('test comment');
comment.get("owner").should.equal(true);
});

it('should be raise error set long comment.', function() {
Expand All @@ -19,5 +20,10 @@ describe('Comment model spec', function() {
var comment = new Comment({comment: longComment});
comment.isValid().should.false;
});

it('need owner flag.', function() {
var comment = new Comment({comment: "Hi"});
comment.isValid().should.false;
});
});