Skip to content

Commit

Permalink
fix: default createdAt to now on account creation (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle Rhodes authored and gr2m committed Feb 8, 2018
1 parent 3ddd933 commit 76f8b26
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/accounts/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function addAccount (state, properties, options) {
type: 'user',
name: lowercaseUsername,
password: properties.password,
createdAt: properties.createdAt,
createdAt: properties.createdAt || new Date().toISOString(),
signedUpAt: properties.signedUpAt,
roles: [
'id:' + accountId
Expand Down
22 changes: 22 additions & 0 deletions test/unit/accounts/add-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,28 @@ test('addAccount', function (group) {
.catch(t.catch)
})

group.test('sets default createdAt', function (t) {
t.plan(1)

var state = {
cache: {
set: simple.stub().resolveWith({})
},
setupPromise: Promise.resolve()
}

addAccount(state, {
username: 'foo'
})

.then(function () {
var doc = state.cache.set.lastCall.arg
t.notEqual(doc.createdAt, undefined)
})

.catch(t.catch)
})

group.test('with existing username', function (t) {
t.plan(3)

Expand Down

0 comments on commit 76f8b26

Please sign in to comment.