{"action":"created","issue":{"url":"https://api.github.com/repos/rails/rails/issues/25168","repository_url":"https://api.github.com/repos/rails/rails","labels_url":"https://api.github.com/repos/rails/rails/issues/25168/labels{/name}","comments_url":"https://api.github.com/repos/rails/rails/issues/25168/comments","events_url":"https://api.github.com/repos/rails/rails/issues/25168/events","html_url":"https://github.com/rails/rails/pull/25168","id":157220614,"number":25168,"title":"Add Action Cable tests","user":{"login":"maclover7","id":3020626,"avatar_url":"https://avatars.githubusercontent.com/u/3020626?v=3","gravatar_id":"","url":"https://api.github.com/users/maclover7","html_url":"https://github.com/maclover7","followers_url":"https://api.github.com/users/maclover7/followers","following_url":"https://api.github.com/users/maclover7/following{/other_user}","gists_url":"https://api.github.com/users/maclover7/gists{/gist_id}","starred_url":"https://api.github.com/users/maclover7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maclover7/subscriptions","organizations_url":"https://api.github.com/users/maclover7/orgs","repos_url":"https://api.github.com/users/maclover7/repos","events_url":"https://api.github.com/users/maclover7/events{/privacy}","received_events_url":"https://api.github.com/users/maclover7/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rails/rails/labels/actioncable","name":"actioncable","color":"bfdadc"}],"state":"open","locked":false,"assignee":{"login":"javan","id":5355,"avatar_url":"https://avatars.githubusercontent.com/u/5355?v=3","gravatar_id":"","url":"https://api.github.com/users/javan","html_url":"https://github.com/javan","followers_url":"https://api.github.com/users/javan/followers","following_url":"https://api.github.com/users/javan/following{/other_user}","gists_url":"https://api.github.com/users/javan/gists{/gist_id}","starred_url":"https://api.github.com/users/javan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javan/subscriptions","organizations_url":"https://api.github.com/users/javan/orgs","repos_url":"https://api.github.com/users/javan/repos","events_url":"https://api.github.com/users/javan/events{/privacy}","received_events_url":"https://api.github.com/users/javan/received_events","type":"User","site_admin":false},"milestone":null,"comments":1,"created_at":"2016-05-27T14:35:48Z","updated_at":"2016-05-27T16:34:30Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/rails/rails/pulls/25168","html_url":"https://github.com/rails/rails/pull/25168","diff_url":"https://github.com/rails/rails/pull/25168.diff","patch_url":"https://github.com/rails/rails/pull/25168.patch"},"body":"r? @javan "},"comment":{"url":"https://api.github.com/repos/rails/rails/issues/comments/222193429","html_url":"https://github.com/rails/rails/pull/25168#issuecomment-222193429","issue_url":"https://api.github.com/repos/rails/rails/issues/25168","id":222193429,"user":{"login":"javan","id":5355,"avatar_url":"https://avatars.githubusercontent.com/u/5355?v=3","gravatar_id":"","url":"https://api.github.com/users/javan","html_url":"https://github.com/javan","followers_url":"https://api.github.com/users/javan/followers","following_url":"https://api.github.com/users/javan/following{/other_user}","gists_url":"https://api.github.com/users/javan/gists{/gist_id}","starred_url":"https://api.github.com/users/javan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javan/subscriptions","organizations_url":"https://api.github.com/users/javan/orgs","repos_url":"https://api.github.com/users/javan/repos","events_url":"https://api.github.com/users/javan/events{/privacy}","received_events_url":"https://api.github.com/users/javan/received_events","type":"User","site_admin":false},"created_at":"2016-05-27T16:34:30Z","updated_at":"2016-05-27T16:34:30Z","body":"Been thinking we should set up a simple adapter system to make testing more straightforward. Something like:\r\n```diff\r\ndiff --git a/actioncable/app/assets/javascripts/action_cable.coffee.erb b/actioncable/app/assets/javascripts/action_cable.coffee.erb\r\nindex 210a3ae..e0758da 100644\r\n--- a/actioncable/app/assets/javascripts/action_cable.coffee.erb\r\n+++ b/actioncable/app/assets/javascripts/action_cable.coffee.erb\r\n@@ -4,6 +4,8 @@\r\n \r\n @ActionCable =\r\n   INTERNAL: <%= ActionCable::INTERNAL.to_json %>\r\n+  WebSocket: window.WebSocket\r\n+  logger: window.console\r\n \r\n   createConsumer: (url) ->\r\n     url ?= @getConfig(\"url\") ? @INTERNAL.default_mount_path\r\n@@ -33,4 +35,4 @@\r\n   log: (messages...) ->\r\n     if @debugging\r\n       messages.push(Date.now())\r\n-      console.log(\"[ActionCable]\", messages...)\r\n+      @logger.log(\"[ActionCable]\", messages...)\r\ndiff --git a/actioncable/app/assets/javascripts/action_cable/connection.coffee b/actioncable/app/assets/javascripts/action_cable/connection.coffee\r\nindex d6a6397..29ad676 100644\r\n--- a/actioncable/app/assets/javascripts/action_cable/connection.coffee\r\n+++ b/actioncable/app/assets/javascripts/action_cable/connection.coffee\r\n@@ -27,7 +27,7 @@ class ActionCable.Connection\r\n     else\r\n       ActionCable.log(\"Opening WebSocket, current state is #{@getState()}, subprotocols: #{protocols}\")\r\n       @uninstallEventHandlers() if @webSocket?\r\n-      @webSocket = new WebSocket(@consumer.url, protocols)\r\n+      @webSocket = new ActionCable.WebSocket(@consumer.url, protocols)\r\n       @installEventHandlers()\r\n       @monitor.start()\r\n       true\r\n```\r\nTests can then set their own adapter instead of swapping / stubbing native APIs on `window`, like [we're already doing for `WebSocket`](https://github.com/rails/rails/blob/master/actioncable/test/javascript/src/test_helpers/mock_websocket.coffee). What do you think?"}}
{"actor":{"display_login":"javan"}}