mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #33102 from bogdanvlviv/refactor-actioncable-tests
Refactor actioncable's tests
This commit is contained in:
commit
9204c0c5fa
18 changed files with 12 additions and 45 deletions
|
@ -5,7 +5,7 @@ require "minitest/mock"
|
|||
require "stubs/test_connection"
|
||||
require "stubs/room"
|
||||
|
||||
class ActionCable::Channel::BaseTest < ActiveSupport::TestCase
|
||||
class ActionCable::Channel::BaseTest < ActionCable::TestCase
|
||||
class ActionCable::Channel::Base
|
||||
def kick
|
||||
@last_action = [ :kick ]
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require "test_helper"
|
||||
require "active_support/testing/method_call_assertions"
|
||||
require "stubs/test_connection"
|
||||
require "stubs/room"
|
||||
|
||||
class ActionCable::Channel::BroadcastingTest < ActiveSupport::TestCase
|
||||
include ActiveSupport::Testing::MethodCallAssertions
|
||||
|
||||
class ActionCable::Channel::BroadcastingTest < ActionCable::TestCase
|
||||
class ChatChannel < ActionCable::Channel::Base
|
||||
end
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require "test_helper"
|
||||
|
||||
class ActionCable::Channel::NamingTest < ActiveSupport::TestCase
|
||||
class ActionCable::Channel::NamingTest < ActionCable::TestCase
|
||||
class ChatChannel < ActionCable::Channel::Base
|
||||
end
|
||||
|
||||
|
|
|
@ -4,11 +4,8 @@ require "test_helper"
|
|||
require "stubs/test_connection"
|
||||
require "stubs/room"
|
||||
require "active_support/time"
|
||||
require "active_support/testing/method_call_assertions"
|
||||
|
||||
class ActionCable::Channel::PeriodicTimersTest < ActiveSupport::TestCase
|
||||
include ActiveSupport::Testing::MethodCallAssertions
|
||||
|
||||
class ActionCable::Channel::PeriodicTimersTest < ActionCable::TestCase
|
||||
class ChatChannel < ActionCable::Channel::Base
|
||||
# Method name arg
|
||||
periodically :send_updates, every: 1
|
||||
|
|
|
@ -5,7 +5,7 @@ require "minitest/mock"
|
|||
require "stubs/test_connection"
|
||||
require "stubs/room"
|
||||
|
||||
class ActionCable::Channel::RejectionTest < ActiveSupport::TestCase
|
||||
class ActionCable::Channel::RejectionTest < ActionCable::TestCase
|
||||
class SecretChannel < ActionCable::Channel::Base
|
||||
def subscribed
|
||||
reject if params[:id] > 0
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require "test_helper"
|
||||
require "active_support/testing/method_call_assertions"
|
||||
require "minitest/mock"
|
||||
require "stubs/test_connection"
|
||||
require "stubs/room"
|
||||
|
@ -164,8 +163,6 @@ module ActionCable::StreamTests
|
|||
end
|
||||
|
||||
class StreamFromTest < ActionCable::TestCase
|
||||
include ActiveSupport::Testing::MethodCallAssertions
|
||||
|
||||
setup do
|
||||
@server = TestServer.new(subscription_adapter: ActionCable::SubscriptionAdapter::Async)
|
||||
@server.config.allowed_request_origins = %w( http://rubyonrails.com )
|
||||
|
|
|
@ -7,7 +7,6 @@ require "websocket-client-simple"
|
|||
require "json"
|
||||
|
||||
require "active_support/hash_with_indifferent_access"
|
||||
require "active_support/testing/method_call_assertions"
|
||||
|
||||
####
|
||||
# 😷 Warning suppression 😷
|
||||
|
@ -28,8 +27,6 @@ WebSocket::Frame::Data.prepend Module.new {
|
|||
####
|
||||
|
||||
class ClientTest < ActionCable::TestCase
|
||||
include ActiveSupport::Testing::MethodCallAssertions
|
||||
|
||||
WAIT_WHEN_EXPECTING_EVENT = 2
|
||||
WAIT_WHEN_NOT_EXPECTING_EVENT = 0.5
|
||||
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require "test_helper"
|
||||
require "active_support/testing/method_call_assertions"
|
||||
require "stubs/test_server"
|
||||
|
||||
class ActionCable::Connection::AuthorizationTest < ActionCable::TestCase
|
||||
include ActiveSupport::Testing::MethodCallAssertions
|
||||
|
||||
class Connection < ActionCable::Connection::Base
|
||||
attr_reader :websocket
|
||||
|
||||
|
|
|
@ -3,11 +3,8 @@
|
|||
require "test_helper"
|
||||
require "stubs/test_server"
|
||||
require "active_support/core_ext/object/json"
|
||||
require "active_support/testing/method_call_assertions"
|
||||
|
||||
class ActionCable::Connection::BaseTest < ActionCable::TestCase
|
||||
include ActiveSupport::Testing::MethodCallAssertions
|
||||
|
||||
class Connection < ActionCable::Connection::Base
|
||||
attr_reader :websocket, :subscriptions, :message_buffer, :connected
|
||||
|
||||
|
|
|
@ -2,11 +2,8 @@
|
|||
|
||||
require "test_helper"
|
||||
require "stubs/test_server"
|
||||
require "active_support/testing/method_call_assertions"
|
||||
|
||||
class ActionCable::Connection::ClientSocketTest < ActionCable::TestCase
|
||||
include ActiveSupport::Testing::MethodCallAssertions
|
||||
|
||||
class Connection < ActionCable::Connection::Base
|
||||
attr_reader :connected, :websocket, :errors
|
||||
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require "test_helper"
|
||||
require "active_support/testing/method_call_assertions"
|
||||
require "stubs/test_server"
|
||||
require "stubs/user"
|
||||
|
||||
class ActionCable::Connection::IdentifierTest < ActionCable::TestCase
|
||||
include ActiveSupport::Testing::MethodCallAssertions
|
||||
|
||||
class Connection < ActionCable::Connection::Base
|
||||
identified_by :current_user
|
||||
attr_reader :websocket
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require "test_helper"
|
||||
require "active_support/testing/method_call_assertions"
|
||||
require "minitest/mock"
|
||||
require "stubs/test_server"
|
||||
|
||||
class ActionCable::Connection::StreamTest < ActionCable::TestCase
|
||||
include ActiveSupport::Testing::MethodCallAssertions
|
||||
|
||||
class Connection < ActionCable::Connection::Base
|
||||
attr_reader :connected, :websocket, :errors
|
||||
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require "test_helper"
|
||||
require "active_support/testing/method_call_assertions"
|
||||
|
||||
class ActionCable::Connection::SubscriptionsTest < ActionCable::TestCase
|
||||
include ActiveSupport::Testing::MethodCallAssertions
|
||||
|
||||
class Connection < ActionCable::Connection::Base
|
||||
attr_reader :websocket
|
||||
|
||||
|
|
|
@ -3,11 +3,8 @@
|
|||
require "test_helper"
|
||||
require "stubs/test_server"
|
||||
require "active_support/core_ext/hash/indifferent_access"
|
||||
require "active_support/testing/method_call_assertions"
|
||||
|
||||
class BaseTest < ActiveSupport::TestCase
|
||||
include ActiveSupport::Testing::MethodCallAssertions
|
||||
|
||||
class BaseTest < ActionCable::TestCase
|
||||
def setup
|
||||
@server = ActionCable::Server::Base.new
|
||||
@server.config.cable = { adapter: "async" }.with_indifferent_access
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
require "test_helper"
|
||||
require "stubs/test_server"
|
||||
|
||||
class BroadcastingTest < ActiveSupport::TestCase
|
||||
class BroadcastingTest < ActionCable::TestCase
|
||||
test "fetching a broadcaster converts the broadcasting queue to a string" do
|
||||
broadcasting = :test_queue
|
||||
server = TestServer.new
|
||||
|
|
|
@ -4,7 +4,6 @@ require "test_helper"
|
|||
require_relative "common"
|
||||
require_relative "channel_prefix"
|
||||
|
||||
require "active_support/testing/method_call_assertions"
|
||||
require "action_cable/subscription_adapter/redis"
|
||||
|
||||
class RedisAdapterTest < ActionCable::TestCase
|
||||
|
@ -30,9 +29,7 @@ class RedisAdapterTest::AlternateConfiguration < RedisAdapterTest
|
|||
end
|
||||
end
|
||||
|
||||
class RedisAdapterTest::Connector < ActiveSupport::TestCase
|
||||
include ActiveSupport::Testing::MethodCallAssertions
|
||||
|
||||
class RedisAdapterTest::Connector < ActionCable::TestCase
|
||||
test "slices url, host, port, db, and password from config" do
|
||||
config = { url: 1, host: 2, port: 3, db: 4, password: 5 }
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
require "action_cable"
|
||||
require "active_support/testing/autorun"
|
||||
require "active_support/testing/method_call_assertions"
|
||||
|
||||
require "puma"
|
||||
require "rack/mock"
|
||||
|
@ -15,6 +16,8 @@ end
|
|||
Dir[File.expand_path("stubs/*.rb", __dir__)].each { |file| require file }
|
||||
|
||||
class ActionCable::TestCase < ActiveSupport::TestCase
|
||||
include ActiveSupport::Testing::MethodCallAssertions
|
||||
|
||||
def wait_for_async
|
||||
wait_for_executor Concurrent.global_io_executor
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require "test_helper"
|
||||
|
||||
class WorkerTest < ActiveSupport::TestCase
|
||||
class WorkerTest < ActionCable::TestCase
|
||||
class Receiver
|
||||
attr_accessor :last_action
|
||||
|
||||
|
|
Loading…
Reference in a new issue