Skip to content

Commit

Permalink
fix incorrect detection of include shorthand
Browse files Browse the repository at this point in the history
  • Loading branch information
seanCodes authored and gr0uch committed Jul 16, 2017
1 parent 323c873 commit ce58597
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/dispatch/include.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ module.exports = function include (context) {
}

// Cast `include` into an array if it's using shorthand.
if (!Array.isArray(include[0])) include = [ include ]
if (include[0] && !Array.isArray(include[0])) include = [ include ]

return Promise.all(map(include, function (fields) {
return new Promise(function (resolve, reject) {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"postcss-cssnext": "^2.11.0",
"postcss-import": "^10.0.0",
"rimraf": "^2.6.1",
"spy": "^1.0.0",
"tapdance": "^5.0.4",
"tape-run": "^3.0.0",
"uglify-js": "^3.0.22"
Expand Down
11 changes: 11 additions & 0 deletions test/integration/methods/find.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict'

const run = require('tapdance')
const spy = require('spy')

const testInstance = require('../test_instance')
const stderr = require('../../stderr')
Expand All @@ -14,6 +15,12 @@ const primaryKey = constants.primary
run((assert, comment) => {
comment('get collection')
return findTest({
before: store => spy(store.adapter, 'find'),
after: store => {
assert(store.adapter.find.callCount === 1,
'gets records using a single fetch')
store.adapter.find.restore()
},
request: [ 'user' ],
response: response => {
assert(response.payload.records.length === 3, 'gets all records')
Expand Down Expand Up @@ -92,12 +99,16 @@ function findTest (o) {
.then(instance => {
store = instance

if (o.before) o.before(store)

return store.find.apply(store, o.request)
})

.then(response => {
o.response(response)

if (o.after) o.after(store)

return store.disconnect()
})

Expand Down

0 comments on commit ce58597

Please sign in to comment.