Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

params don't seem to be parsed out of connection requests #52

Open
nathan-eko opened this issue Apr 24, 2019 · 1 comment
Open

params don't seem to be parsed out of connection requests #52

nathan-eko opened this issue Apr 24, 2019 · 1 comment

Comments

@nathan-eko
Copy link

If I mount my ActionCable app as such:

mount ActionCable.server => "/socket(/:channel/:resource_id)"

My connection objects receive and have access to request.params[:channel] and request.params[:resource_id] much as I would expect.

If I then write a test to verify the behavior of my Connection class' authentication logic

expect { connect "/socket/somechannel/somebogusid" }.to have_rejected_connection

My Connection class receives empty params in the Request object. This basically means I cannot test anything I need to.

Am I missing something or is this a legitimate deficiency of this library?

@palkan
Copy link
Owner

palkan commented Apr 25, 2019

You can use params: ... like in controller tests:

expect { connect params: {channel: "somechannel", resource_id: "somebogusid"} }.to have_rejected_connection

If I mount my ActionCable app as such:
mount ActionCable.server => "/socket(/:channel/:resource_id)"

That's an interesting example (haven't thought about it, tbh); beware, that it relies on Rails router to populate the params and won't work if you decide to run Action Cable in a standalone mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants