Skip to content

Commit

Permalink
Fix generator; connects without identifiers by default
Browse files Browse the repository at this point in the history
  • Loading branch information
palkan committed Oct 22, 2017
1 parent 6330b5a commit fcef4e2
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 11 deletions.
6 changes: 5 additions & 1 deletion lib/action_cable/channel/test_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ module Behavior
included do
class_attribute :_channel_class

attr_reader :subscription, :connection
attr_reader :subscription
delegate :transmissions, to: :connection
delegate :streams, to: :subscription

Expand Down Expand Up @@ -204,6 +204,10 @@ def perform(action, data = {})
subscription.perform_action(data.stringify_keys.merge("action" => action.to_s))
end

def connection # :nodoc:
@connection ||= stub_connection
end

private
def check_subscribed!
raise "Must be subscribed!" if subscription.nil? || subscription.rejected?
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'test_helper'

<% module_namespacing do -%>
class <%= class_name %>ChannelTest < ActionCable::TestCase
class <%= class_name %>ChannelTest < ActionCable::Channel::TestCase
# test "the truth" do
# assert true
# end
Expand Down
2 changes: 1 addition & 1 deletion spec/generators/cable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@

it "creates script", :aggregate_failures do
is_expected.to exist
is_expected.to contain("class ChatChannelTest < ActionCable::TestCase")
is_expected.to contain("class ChatChannelTest < ActionCable::Channel::TestCase")
end
end
8 changes: 0 additions & 8 deletions test/channel/test_case_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@ def subscribed
end

class RejectionTestChannelTest < ActionCable::Channel::TestCase
def setup
stub_connection
end

def test_rejection
subscribe

Expand All @@ -94,10 +90,6 @@ def subscribed
end

class StreamsTestChannelTest < ActionCable::Channel::TestCase
def setup
stub_connection
end

def test_stream_without_params
subscribe

Expand Down

0 comments on commit fcef4e2

Please sign in to comment.