Re: [Rails-core] Unit testing ActionCable

2016-11-22 Thread Rafael Mendonça França
https://github.com/rails/rails/pull/23211
On Tue, Nov 22, 2016 at 12:55 PM Roman Snitko 
wrote:

> 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.
>
> --
> 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-core+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-core@googlegroups.com.
> Visit this group at https://groups.google.com/group/rubyonrails-core.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.


[Rails-core] Unit testing ActionCable

2016-11-22 Thread Roman Snitko
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.

-- 
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-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.