Skip to content

Commit

Permalink
Account add wasn't adding include to options, but instead properties.…
Browse files Browse the repository at this point in the history
… Also added test for user add with profile
  • Loading branch information
jameswestnz committed Jun 15, 2016
1 parent 95c58d2 commit f69ffa9
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
3 changes: 2 additions & 1 deletion routes/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ function accountRoutes (server, options, next) {
username: username,
password: password,
profile: profile,
include: query.include,
id: id
}, {
include: query.include || null
})

.then(serialise)
Expand Down
30 changes: 30 additions & 0 deletions tests/integration/routes/account/put-account-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,36 @@ getServer(function (error, server) {
})
})

group.test('User added with profile', function (t) {
var couchdb = mockCouchDbPutUser
.reply(201, [{
id: 'org.couchdb.user:pat-doe',
rev: '1-234'
}])

var options = _.defaultsDeep({
url: '/session/account?include=profile'
}, routeOptions)

var accountWithProfileFixture = require('../../fixtures/account-with-profile.json')

server.inject(options, function (response) {
t.is(couchdb.pendingMocks()[0], undefined, 'CouchDB received request')
delete response.result.meta

t.is(response.statusCode, 201, 'returns 201 status')
response.result.data.id = 'userid123'
response.result.data.relationships.profile.data.id = 'userid123-profile'
response.result.included[0].id = 'userid123-profile'
response.result.included[0].attributes = {
fullName: 'pat Doe',
email: 'pat@example.com'
}
t.deepEqual(response.result, accountWithProfileFixture, 'returns account in right format')
t.end()
})
})

group.test('CouchDB User already exists', function (t) {
var couchdb = mockCouchDbPutUser
.reply(201, [{
Expand Down

0 comments on commit f69ffa9

Please sign in to comment.