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

Add support for passing in request params via connect #41

Closed
wants to merge 1 commit into from

Conversation

mlwilkerson
Copy link

My app uses request params to configure the ActionCable connection. This PR adds params as a key to connect so those params can be provided by the test code to test the connection. If there's an existing preferable way to do this with action-cable-testing I couldn't find it. I could also add a test for this params feature, but I couldn't seem to figure out how to get the tests to run in this repo. If someone could give me a hint as to how to get the development environment fully set up for running the tests in this repo, I could add testing for params.

@palkan
Copy link
Owner

palkan commented Jan 2, 2019

Thanks for PR!

If there's an existing preferable way to do this with action-cable-testing I couldn't find it.

The way it can be achieved right now is the following:

connect "/cable?my_param=value"
# ...

Thus you can specify the connection URL (including params).

Having params: ... API makes sense to (this looks similar to request specs).

If someone could give me a hint as to how to get the development environment fully set up for running the tests in this repo, I could add testing for params.

Check out this PR on how you can add tests for the feature: #35

@mlwilkerson
Copy link
Author

Oh wait, I see that I just needed to run rake as bundle exec rake to get all the environment stuff to work as expected for executing the tests.

I see the test failure in Travis CI. When I can come back to this, I'll dig into that failure, see if I can fix it, and then add a test for params.

@mlwilkerson
Copy link
Author

Yes, I saw that I could pass in params via the GET url. But the particular thing I'm passing in here is a token as part of an authentication mechanism and I prefer to keep that out of the URL.

@palkan
Copy link
Owner

palkan commented Jan 2, 2019

I prefer to keep that out of the URL

And how do you to pass it then? I mean, in your app?

@mlwilkerson
Copy link
Author

I'm using graphql-ruby which uses ActionCable for the GraphQL subscriptions. There's a connectionParams object that can be optionally provided to the ActionCableLink object (which connects the GraphQL stuff to the ActionCable stuff). That connectionParams gets passed through to subscriptions.create().

@mlwilkerson
Copy link
Author

mlwilkerson commented Jan 2, 2019

Hang on, I think I'm confused with too many cobwebs in my mind from the holiday break.

I think that connectionParams feature only provides the params to the Channel on the sever side. I did end up having to use GET params to pass in the token that the Connection reads.

So this whole PR is maybe just a big exercise in forgetfulness on my part.

I just re-read some of my own comments about how I've been going about this which has jogged my memory.

Sorry for the spam here.

@palkan
Copy link
Owner

palkan commented Jan 2, 2019

Thanks for the clarification.

I've added params: ... support in the Rails version (not yet merged rails/rails#34845).

I'll backport all the changes from Rails master to the gem as soon as the first Rails 6 RC will be released.

@palkan palkan closed this Jan 2, 2019
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

Successfully merging this pull request may close these issues.

2 participants