Fixing namespace bug with creating feeds.
diff --git a/lib/feeds.js b/lib/feeds.js
index 8bc55b3..7a92adf 100644
--- a/lib/feeds.js
+++ b/lib/feeds.js
@@ -39,7 +39,7 @@
if (!options.trigger) return
if (options.trigger.startsWith('/')) return options.trigger
- const ns = options.namespace || this.client.options.namespace || names.default_namespace()
+ const ns = this.client.options.namespace || names.default_namespace()
return `/${ns}/${options.trigger}`
}
@@ -49,6 +49,7 @@
const invoke_options = {
name: this.feed_name(options),
+ namespace: options.namespace,
blocking: true,
params
}
diff --git a/test/unit/feeds.test.js b/test/unit/feeds.test.js
index 23fdf22..ac57c19 100644
--- a/test/unit/feeds.test.js
+++ b/test/unit/feeds.test.js
@@ -121,19 +121,19 @@
const client = {}
client.options = { api_key }
- const ns = '_'
+ const ns = 'custom'
const feeds = new Feeds(client)
client.request = (method, path, options) => {
t.is(method, 'POST')
t.is(path, `namespaces/${ns}/actions/${feed_name}`)
t.deepEqual(options.qs, {blocking: true})
- t.deepEqual(options.body, {authKey: client.options.api_key, lifecycleEvent: 'CREATE', triggerName: `/ns/${trigger_name}`})
+ t.deepEqual(options.body, {authKey: client.options.api_key, lifecycleEvent: 'CREATE', triggerName: `/_/${trigger_name}`})
}
t.plan(4)
- return feeds.create({name: feed_name, namespace: 'ns', trigger: trigger_name})
+ return feeds.create({name: feed_name, namespace: ns, trigger: trigger_name})
})
test('should be able to create trigger ignoring options namespace', t => {
@@ -148,7 +148,7 @@
client.request = (method, path, options) => {
t.is(method, 'POST')
- t.is(path, `namespaces/${ns}/actions/${feed_name}`)
+ t.is(path, `namespaces/ns/actions/${feed_name}`)
t.deepEqual(options.qs, {blocking: true})
t.deepEqual(options.body, {authKey: client.options.api_key, lifecycleEvent: 'CREATE', triggerName: `${trigger_name}`})
}
@@ -180,7 +180,6 @@
return feeds.create({name: feed_name, namespace: 'ns', trigger: trigger_name})
})
-
test('should be able to create feed using feedName with params', t => {
const feed_name = 'feed_name'
const api_key = 'username:password'