aboutsummaryrefslogtreecommitdiffstats
path: root/test/connection
diff options
context:
space:
mode:
authorJeremy Daer <jeremydaer@gmail.com>2015-10-16 01:02:22 -0700
committerJeremy Daer <jeremydaer@gmail.com>2015-10-16 09:06:44 -0700
commitacfdcf556888a88dc2d2026553d585f920fae105 (patch)
tree9e9bbe0a5b43170d3495653315fe396e546e6dd0 /test/connection
parentd7ab5c8f1ffd04acd2cf610f5756fc18fdfc6160 (diff)
downloadrails-acfdcf556888a88dc2d2026553d585f920fae105.tar.gz
rails-acfdcf556888a88dc2d2026553d585f920fae105.tar.bz2
rails-acfdcf556888a88dc2d2026553d585f920fae105.zip
Devolve blanket #require to reveal intent and responsibility
* Move specific requires close to where they're needed. * Use the private active_support/rails dep to wrap up common needs like eager autoload and module delegation. * Use a single Rails engine rather than an engine and a railtie. * Prefer `AS::JSON.encode` to `Object#to_json`.
Diffstat (limited to 'test/connection')
-rw-r--r--test/connection/identifier_test.rb4
-rw-r--r--test/connection/subscriptions_test.rb6
2 files changed, 5 insertions, 5 deletions
diff --git a/test/connection/identifier_test.rb b/test/connection/identifier_test.rb
index f34b66f9fd..02e6b21845 100644
--- a/test/connection/identifier_test.rb
+++ b/test/connection/identifier_test.rb
@@ -40,7 +40,7 @@ class ActionCable::Connection::IdentifierTest < ActionCable::TestCase
open_connection_with_stubbed_pubsub
@connection.websocket.expects(:close)
- message = { 'type' => 'disconnect' }.to_json
+ message = ActiveSupport::JSON.encode('type' => 'disconnect')
@connection.process_internal_message message
end
end
@@ -50,7 +50,7 @@ class ActionCable::Connection::IdentifierTest < ActionCable::TestCase
open_connection_with_stubbed_pubsub
@connection.websocket.expects(:close).never
- message = { 'type' => 'unknown' }.to_json
+ message = ActiveSupport::JSON.encode('type' => 'unknown')
@connection.process_internal_message message
end
end
diff --git a/test/connection/subscriptions_test.rb b/test/connection/subscriptions_test.rb
index 55ad74b962..4f6760827e 100644
--- a/test/connection/subscriptions_test.rb
+++ b/test/connection/subscriptions_test.rb
@@ -27,7 +27,7 @@ class ActionCable::Connection::SubscriptionsTest < ActionCable::TestCase
@server = TestServer.new
@server.stubs(:channel_classes).returns(ChatChannel.name => ChatChannel)
- @chat_identifier = { id: 1, channel: 'ActionCable::Connection::SubscriptionsTest::ChatChannel' }.to_json
+ @chat_identifier = ActiveSupport::JSON.encode(id: 1, channel: 'ActionCable::Connection::SubscriptionsTest::ChatChannel')
end
test "subscribe command" do
@@ -77,7 +77,7 @@ class ActionCable::Connection::SubscriptionsTest < ActionCable::TestCase
channel = subscribe_to_chat_channel
data = { 'content' => 'Hello World!', 'action' => 'speak' }
- @subscriptions.execute_command 'command' => 'message', 'identifier' => @chat_identifier, 'data' => data.to_json
+ @subscriptions.execute_command 'command' => 'message', 'identifier' => @chat_identifier, 'data' => ActiveSupport::JSON.encode(data)
assert_equal [ data ], channel.lines
end
@@ -89,7 +89,7 @@ class ActionCable::Connection::SubscriptionsTest < ActionCable::TestCase
channel1 = subscribe_to_chat_channel
- channel2_id = { id: 2, channel: 'ActionCable::Connection::SubscriptionsTest::ChatChannel' }.to_json
+ channel2_id = ActiveSupport::JSON.encode(id: 2, channel: 'ActionCable::Connection::SubscriptionsTest::ChatChannel')
channel2 = subscribe_to_chat_channel(channel2_id)
channel1.expects(:unsubscribe_from_channel)