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

use_middleware on development with edge Rails #65

Closed
coolsoftwaretyler opened this issue Jul 13, 2020 · 2 comments
Closed

use_middleware on development with edge Rails #65

coolsoftwaretyler opened this issue Jul 13, 2020 · 2 comments

Comments

@coolsoftwaretyler
Copy link

Hey everyone,

I'm not entirely sure if I found a bug, if I shot myself in the foot, or if things were accidentally working before when they should not have.

I'm building an app and bundling edge rails with gem 'rails', github: 'rails/rails' in my Gemfile.

I'm using cypress-on-rails in test and development. Perhaps this is where I initially went wrong. One way or another, I was using the gem and it was working as recently as Jul 11, 2020 at 04:40pm MT.

Today I ran bundle update this morning to fix a Sprockets bug. Then I ran cypress-on-rails and started receiving this error in my development server log:

ActionController::RoutingError (No route matches [POST] "/__cypress__/command"):

My first assumption was that something with edge rails (v6.0.3.2 as of today) was breaking something and y'all weren't yet aware of it. So I rolled back through versions and continued to get the same issue. I wanted to pinpoint it so I could bring it to your attention and let you know if a specific version of Rails might break your gem.

I went one-by-one all the way back down to Rails 6.0.0 and still got the issues. At that point I thought maybe it wasn't Rails, but something in the gem. I jumped back up to edge rails and ran bin/rails g cypress_on_rails:update to see if I was missing some updated necessary config. Still no luck.

I looked through the files the installer writes through, and figured that config/initializers/cypress_on_rails.rb is probably the place where those routes are added. I noticed the line:

    c.use_middleware = Rails.env.test?

And I monkey-patched it locally to

    c.use_middleware = Rails.env.test? || Rails.env.development?

And everything is working. Using Rails 6.1.0.alpha, bundled from edge. Looks like the cypress-on-rails version is 1.7.0.

Looking through recent PRs to your gem, it looks like maybe #62 changed the prior behavior. Again, I think I shouldn't be running this in development, I just kind of am because I made a bad choice. It used to work, now it does not. Is that the intended effect, to lock it down to test environments only? If so, I'll go and fix up my project to work the way you intended. But if it's supposed to be available in development, then maybe there is a bug.

Thanks for your time and the great gem. Really appreciate it!

@grantspeelman
Copy link
Collaborator

thanks @ogdenstudios for all the details and apologizes for causing any issues.

use_middleware is a flag that is suppose to make it possible to effectively turn off cypress-on-rails even though the gem is loaded.
#62 actually made it start working. So i guess in a sense the right answer could of been to rather deprecate it as it was never working in the first place, maybe if it gave it a bit more thought i would of opted for this.

I use cypress-on-rails in development on my local and in test on CI, I have already update my config to:

c.use_middleware = true

I'll update the generators to the above as well.

hope this clears everything up.

@coolsoftwaretyler
Copy link
Author

It does! I've got a good sense of what happened. Thanks, again!

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