From 6d488a22d361d19e3de98c603d98e64ccea8a2f3 Mon Sep 17 00:00:00 2001 From: Ryan Castner Date: Sun, 31 Mar 2019 13:41:12 -0400 Subject: feat(js): Dynamic ActionCable URL (#35579) * Failing test case * feat: Dynamic Url Generation Change createWebSocketURL to be a closure that allows url to be evaluated at the time the webSocket is established * refactor: createWebSocketURL to Consumer, remove need for closure Move initial call to createWebSocketURL in createConsumer * docs: Add documentation for dynamic url and string args to createConsumer Co-Authored-By: rmacklin [Ryan Castner, rmacklin] --- actioncable/test/javascript/src/unit/action_cable_test.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'actioncable/test/javascript/src/unit/action_cable_test.js') diff --git a/actioncable/test/javascript/src/unit/action_cable_test.js b/actioncable/test/javascript/src/unit/action_cable_test.js index c9d34abc6d..2181f955e3 100644 --- a/actioncable/test/javascript/src/unit/action_cable_test.js +++ b/actioncable/test/javascript/src/unit/action_cable_test.js @@ -43,11 +43,14 @@ module("ActionCable", () => { }) test("uses function to generate URL", assert => { + let dynamicURL = testURL const generateURL = () => { - return testURL + return dynamicURL } + + dynamicURL = `${testURL}foo` const consumer = ActionCable.createConsumer(generateURL) - assert.equal(consumer.url, testURL) + assert.equal(consumer.url, `${testURL}foo`) }) }) }) -- cgit v1.2.3