From aa38c1123cd80338cb5864642cb461d959492c6a Mon Sep 17 00:00:00 2001 From: gconsidine Date: Fri, 10 Nov 2017 15:59:38 -0500 Subject: [PATCH] Check for null resource and update e2e model usage --- awx/ui/client/lib/models/Base.js | 8 ++++++-- awx/ui/test/e2e/tests/test-credentials-add-edit-aws.js | 2 +- awx/ui/test/e2e/tests/test-credentials-add-edit-custom.js | 2 +- awx/ui/test/e2e/tests/test-credentials-add-edit-gce.js | 2 +- .../test/e2e/tests/test-credentials-add-edit-insights.js | 2 +- .../test/e2e/tests/test-credentials-add-edit-machine.js | 2 +- .../test/e2e/tests/test-credentials-add-edit-network.js | 2 +- awx/ui/test/e2e/tests/test-credentials-add-edit-scm.js | 2 +- awx/ui/test/e2e/tests/test-credentials-add-edit-vault.js | 2 +- 9 files changed, 14 insertions(+), 10 deletions(-) diff --git a/awx/ui/client/lib/models/Base.js b/awx/ui/client/lib/models/Base.js index 171c046a41..be8e97426f 100644 --- a/awx/ui/client/lib/models/Base.js +++ b/awx/ui/client/lib/models/Base.js @@ -447,13 +447,17 @@ function parseRequestConfig (method, resource, config) { if (Array.isArray(method)) { if (Array.isArray(resource)) { req.resource = resource; + } else if (resource === null) { + req.resource = undefined; } else if (typeof resource === 'object') { req = resource; } req.method = method; } else if (typeof method === 'string') { - if (typeof resource === 'object') { + if (resource === null) { + req.resource = undefined; + } else if (typeof resource === 'object') { req = resource; } else { req.resource = resource; @@ -465,7 +469,7 @@ function parseRequestConfig (method, resource, config) { } else { req = config; req.method = method; - req.resource = resource; + req.resource = resource === null ? undefined : resource; } return req; diff --git a/awx/ui/test/e2e/tests/test-credentials-add-edit-aws.js b/awx/ui/test/e2e/tests/test-credentials-add-edit-aws.js index d7a3bec3f2..5da3e727ae 100644 --- a/awx/ui/test/e2e/tests/test-credentials-add-edit-aws.js +++ b/awx/ui/test/e2e/tests/test-credentials-add-edit-aws.js @@ -20,7 +20,7 @@ module.exports = { client.inject( [store, 'OrganizationModel'], - (_store_, Model) => new Model().http.post(_store_.organization), + (_store_, Model) => new Model().http.post({ data: _store_.organization }), ({ data }) => { store.organization = data; } ); diff --git a/awx/ui/test/e2e/tests/test-credentials-add-edit-custom.js b/awx/ui/test/e2e/tests/test-credentials-add-edit-custom.js index 7f3caee6a4..9e4238cd6a 100644 --- a/awx/ui/test/e2e/tests/test-credentials-add-edit-custom.js +++ b/awx/ui/test/e2e/tests/test-credentials-add-edit-custom.js @@ -92,7 +92,7 @@ module.exports = { client.inject( [store.credentialType, 'CredentialTypeModel'], - (data, Model) => new Model().http.post(data), + (data, Model) => new Model().http.post({ data }), ({ data }) => { store.credentialType.response = data; } ); diff --git a/awx/ui/test/e2e/tests/test-credentials-add-edit-gce.js b/awx/ui/test/e2e/tests/test-credentials-add-edit-gce.js index a7d64ffdba..b7457d81b6 100644 --- a/awx/ui/test/e2e/tests/test-credentials-add-edit-gce.js +++ b/awx/ui/test/e2e/tests/test-credentials-add-edit-gce.js @@ -23,7 +23,7 @@ module.exports = { client.inject( [store, 'OrganizationModel'], - (_store_, Model) => new Model().http.post(_store_.organization), + (_store_, Model) => new Model().http.post({ data: _store_.organization }), ({ data }) => { store.organization = data; } ); diff --git a/awx/ui/test/e2e/tests/test-credentials-add-edit-insights.js b/awx/ui/test/e2e/tests/test-credentials-add-edit-insights.js index b85e0a9592..b4798df500 100644 --- a/awx/ui/test/e2e/tests/test-credentials-add-edit-insights.js +++ b/awx/ui/test/e2e/tests/test-credentials-add-edit-insights.js @@ -23,7 +23,7 @@ module.exports = { client.inject( [store, 'OrganizationModel'], - (_store_, Model) => new Model().http.post(_store_.organization), + (_store_, Model) => new Model().http.post({ data: _store_.organization }), ({ data }) => { store.organization = data; } ); diff --git a/awx/ui/test/e2e/tests/test-credentials-add-edit-machine.js b/awx/ui/test/e2e/tests/test-credentials-add-edit-machine.js index c16a76a0a5..7ed3514c23 100644 --- a/awx/ui/test/e2e/tests/test-credentials-add-edit-machine.js +++ b/awx/ui/test/e2e/tests/test-credentials-add-edit-machine.js @@ -23,7 +23,7 @@ module.exports = { client.inject( [store, 'OrganizationModel'], - (_store_, Model) => new Model().http.post(_store_.organization), + (_store_, Model) => new Model().http.post({ data: _store_.organization }), ({ data }) => { store.organization = data; } ); diff --git a/awx/ui/test/e2e/tests/test-credentials-add-edit-network.js b/awx/ui/test/e2e/tests/test-credentials-add-edit-network.js index 6b025924b4..63669b543b 100644 --- a/awx/ui/test/e2e/tests/test-credentials-add-edit-network.js +++ b/awx/ui/test/e2e/tests/test-credentials-add-edit-network.js @@ -23,7 +23,7 @@ module.exports = { client.inject( [store, 'OrganizationModel'], - (_store_, Model) => new Model().http.post(_store_.organization), + (_store_, Model) => new Model().http.post({ data: _store_.organization }), ({ data }) => { store.organization = data; } ); diff --git a/awx/ui/test/e2e/tests/test-credentials-add-edit-scm.js b/awx/ui/test/e2e/tests/test-credentials-add-edit-scm.js index 8a452bbc70..744a98b14f 100644 --- a/awx/ui/test/e2e/tests/test-credentials-add-edit-scm.js +++ b/awx/ui/test/e2e/tests/test-credentials-add-edit-scm.js @@ -23,7 +23,7 @@ module.exports = { client.inject( [store, 'OrganizationModel'], - (_store_, Model) => new Model().http.post(_store_.organization), + (_store_, Model) => new Model().http.post({ data: _store_.organization }), ({ data }) => { store.organization = data; } ); diff --git a/awx/ui/test/e2e/tests/test-credentials-add-edit-vault.js b/awx/ui/test/e2e/tests/test-credentials-add-edit-vault.js index ad8d38fff8..b017651de3 100644 --- a/awx/ui/test/e2e/tests/test-credentials-add-edit-vault.js +++ b/awx/ui/test/e2e/tests/test-credentials-add-edit-vault.js @@ -23,7 +23,7 @@ module.exports = { client.inject( [store, 'OrganizationModel'], - (_store_, Model) => new Model().http.post(_store_.organization), + (_store_, Model) => new Model().http.post({ data: _store_.organization }), ({ data }) => { store.organization = data; } );