Unit testing ActionCable

49 views
Skip to first unread message

Roman Snitko

unread,
Nov 22, 2016, 12:55:29 PM11/22/16
to Ruby on Rails: Core
It seems there currently is no easy (or hard even) way to unit test ActionCable channels, which makes me very sad. There is a bit of logic in my Channels which would be very nice to cover with tests. Ideally, I'd like to have something like this:

    it "rejects connection if current_user isn't the owner of the contract" do
      channel = create_channel(:contract)
      sign_in @unauthorized_user
      expect(channel.subscribe(params: {contract_id: 1}).to reject_connection
    end

Is this something even remotely likely to happen? I googled very hard and I also checked every ActionCable issue (opened & closed) and couldn't find anyone asking this question.

Rafael Mendonça França

unread,
Nov 22, 2016, 2:05:47 PM11/22/16
to Ruby on Rails: Core
https://github.com/rails/rails/pull/23211
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-co...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages