From 4c5d5b75abe85d59e5cc9de9904fdef3b23ec25b Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Fri, 15 Jan 2016 19:07:18 -0500 Subject: ActionCable::StorageAdapter ==> ActionCable::SubscriptionAdapter --- actioncable/test/storage_adapter/base_test.rb | 73 ---------------------- actioncable/test/stubs/test_adapter.rb | 2 +- actioncable/test/stubs/test_server.rb | 4 +- actioncable/test/subscription_adapter/base_test.rb | 73 ++++++++++++++++++++++ 4 files changed, 76 insertions(+), 76 deletions(-) delete mode 100644 actioncable/test/storage_adapter/base_test.rb create mode 100644 actioncable/test/subscription_adapter/base_test.rb (limited to 'actioncable/test') diff --git a/actioncable/test/storage_adapter/base_test.rb b/actioncable/test/storage_adapter/base_test.rb deleted file mode 100644 index 47632df387..0000000000 --- a/actioncable/test/storage_adapter/base_test.rb +++ /dev/null @@ -1,73 +0,0 @@ -require 'test_helper' -require 'stubs/test_server' - -class ActionCable::StorageAdapter::BaseTest < ActionCable::TestCase - ## TEST THAT ERRORS ARE RETURNED FOR INHERITORS THAT DON'T OVERRIDE METHODS - - class BrokenAdapter < ActionCable::StorageAdapter::Base - end - - setup do - @server = TestServer.new - @server.config.storage_adapter = BrokenAdapter - @server.config.allowed_request_origins = %w( http://rubyonrails.com ) - end - - test "#broadcast returns NotImplementedError by default" do - assert_raises NotImplementedError do - BrokenAdapter.new(@server).broadcast('channel', 'payload') - end - end - - test "#subscribe returns NotImplementedError by default" do - callback = lambda { puts 'callback' } - success_callback = lambda { puts 'success' } - - assert_raises NotImplementedError do - BrokenAdapter.new(@server).subscribe('channel', callback, success_callback) - end - end - - test "#unsubscribe returns NotImplementedError by default" do - callback = lambda { puts 'callback' } - - assert_raises NotImplementedError do - BrokenAdapter.new(@server).unsubscribe('channel', callback) - end - end - - # TEST METHODS THAT ARE REQUIRED OF THE ADAPTER'S BACKEND STORAGE OBJECT - - test "#broadcast is implemented" do - broadcast = SuccessAdapter.new(@server).broadcast('channel', 'payload') - - assert_respond_to(SuccessAdapter.new(@server), :broadcast) - - assert_nothing_raised NotImplementedError do - broadcast - end - end - - test "#subscribe is implemented" do - callback = lambda { puts 'callback' } - success_callback = lambda { puts 'success' } - subscribe = SuccessAdapter.new(@server).subscribe('channel', callback, success_callback) - - assert_respond_to(SuccessAdapter.new(@server), :subscribe) - - assert_nothing_raised NotImplementedError do - subscribe - end - end - - test "#unsubscribe is implemented" do - callback = lambda { puts 'callback' } - unsubscribe = SuccessAdapter.new(@server).unsubscribe('channel', callback) - - assert_respond_to(SuccessAdapter.new(@server), :unsubscribe) - - assert_nothing_raised NotImplementedError do - unsubscribe - end - end -end diff --git a/actioncable/test/stubs/test_adapter.rb b/actioncable/test/stubs/test_adapter.rb index c18ca5dc9d..bbd142b287 100644 --- a/actioncable/test/stubs/test_adapter.rb +++ b/actioncable/test/stubs/test_adapter.rb @@ -1,4 +1,4 @@ -class SuccessAdapter < ActionCable::StorageAdapter::Base +class SuccessAdapter < ActionCable::SubscriptionAdapter::Base def broadcast(channel, payload) end diff --git a/actioncable/test/stubs/test_server.rb b/actioncable/test/stubs/test_server.rb index e1eb9f113a..067266ed57 100644 --- a/actioncable/test/stubs/test_server.rb +++ b/actioncable/test/stubs/test_server.rb @@ -7,11 +7,11 @@ class TestServer def initialize @logger = ActiveSupport::TaggedLogging.new ActiveSupport::Logger.new(StringIO.new) - @config = OpenStruct.new(log_tags: [], storage_adapter: SuccessAdapter) + @config = OpenStruct.new(log_tags: [], subscription_adapter: SuccessAdapter) end def adapter - @config.storage_adapter.new(self) + @config.subscription_adapter.new(self) end def send_async diff --git a/actioncable/test/subscription_adapter/base_test.rb b/actioncable/test/subscription_adapter/base_test.rb new file mode 100644 index 0000000000..7a7ae131e6 --- /dev/null +++ b/actioncable/test/subscription_adapter/base_test.rb @@ -0,0 +1,73 @@ +require 'test_helper' +require 'stubs/test_server' + +class ActionCable::SubscriptionAdapter::BaseTest < ActionCable::TestCase + ## TEST THAT ERRORS ARE RETURNED FOR INHERITORS THAT DON'T OVERRIDE METHODS + + class BrokenAdapter < ActionCable::SubscriptionAdapter::Base + end + + setup do + @server = TestServer.new + @server.config.subscription_adapter = BrokenAdapter + @server.config.allowed_request_origins = %w( http://rubyonrails.com ) + end + + test "#broadcast returns NotImplementedError by default" do + assert_raises NotImplementedError do + BrokenAdapter.new(@server).broadcast('channel', 'payload') + end + end + + test "#subscribe returns NotImplementedError by default" do + callback = lambda { puts 'callback' } + success_callback = lambda { puts 'success' } + + assert_raises NotImplementedError do + BrokenAdapter.new(@server).subscribe('channel', callback, success_callback) + end + end + + test "#unsubscribe returns NotImplementedError by default" do + callback = lambda { puts 'callback' } + + assert_raises NotImplementedError do + BrokenAdapter.new(@server).unsubscribe('channel', callback) + end + end + + # TEST METHODS THAT ARE REQUIRED OF THE ADAPTER'S BACKEND STORAGE OBJECT + + test "#broadcast is implemented" do + broadcast = SuccessAdapter.new(@server).broadcast('channel', 'payload') + + assert_respond_to(SuccessAdapter.new(@server), :broadcast) + + assert_nothing_raised NotImplementedError do + broadcast + end + end + + test "#subscribe is implemented" do + callback = lambda { puts 'callback' } + success_callback = lambda { puts 'success' } + subscribe = SuccessAdapter.new(@server).subscribe('channel', callback, success_callback) + + assert_respond_to(SuccessAdapter.new(@server), :subscribe) + + assert_nothing_raised NotImplementedError do + subscribe + end + end + + test "#unsubscribe is implemented" do + callback = lambda { puts 'callback' } + unsubscribe = SuccessAdapter.new(@server).unsubscribe('channel', callback) + + assert_respond_to(SuccessAdapter.new(@server), :unsubscribe) + + assert_nothing_raised NotImplementedError do + unsubscribe + end + end +end -- cgit v1.2.3