Skip to content
This repository has been archived by the owner on Feb 26, 2021. It is now read-only.

Commit

Permalink
Made changes to the methods w/ new security model
Browse files Browse the repository at this point in the history
  • Loading branch information
tmeasday authored and Sashko Stubailo committed Dec 9, 2015
1 parent 3c09268 commit 8655e4d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
3 changes: 1 addition & 2 deletions packages/lists/lists-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,12 @@ describe('lists', () => {
function assertListAndTodoArePrivate() {
assert.equal(Lists.findOne(listId).userId, userId);
assert.isTrue(Lists.findOne(listId).isPrivate());
assert.equal(Todos.findOne(todoId).userId, userId);
assert.isTrue(Todos.findOne(todoId).editableBy(userId));
assert.isFalse(Todos.findOne(todoId).editableBy(Random.id()));
}

it('makes a list private and updates the todos', () => {
// Check initial state is public
assert.isUndefined(Todos.findOne(todoId).userId);
assert.isFalse(Lists.findOne(listId).isPrivate());

// Set up method arguments and context
Expand Down
10 changes: 2 additions & 8 deletions packages/todos/todos.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,10 @@ Factory.define('todo', Todos, {
});

Todos.helpers({
getList() {
list() {
return Lists.findOne(this.listId);
},
editableBy(userId) {
if (! this.userId) {
// This todo is in a public list
return true;
}

// This todo is in a private list, but the list is owned by the relevant user
return this.userId === userId;
return this.list().editableBy(userId);
}
});

0 comments on commit 8655e4d

Please sign in to comment.