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

cancancan breaks spring + rspec on rails 3.2.x #405

Closed
vovimayhem opened this issue Apr 29, 2017 · 6 comments
Closed

cancancan breaks spring + rspec on rails 3.2.x #405

vovimayhem opened this issue Apr 29, 2017 · 6 comments
Assignees
Labels

Comments

@vovimayhem
Copy link

I'm having a problem running "springified" rspec on a rails 3.2.22.5 app, and through a process of elimination I isolated the problem to the cancancan gem.

This is the error I'm getting when running rspec with the app already preloaded with spring:

Failure/Error: DatabaseCleaner.clean_with(:truncation)

ActiveRecord::StatementInvalid:
  PG::ConnectionBad: PQsocket() can't get socket descriptor:           SELECT tablename
            FROM pg_tables
            WHERE schemaname = ANY (current_schemas(false))

I've setup a sample app running with docker compose to run the test in a reproduceable way:

https://github.com/IcaliaLabs/cancancan-test (Follow instructions on readme)

@vovimayhem
Copy link
Author

I'm suspecting attempting a connection on code load is to blame.

@vovimayhem
Copy link
Author

I found the problem to be how the module CanCan::ModelAdditions is loaded into ActiveRecord::Base on lib/cancan/model_adapters/active_record_adapter.rb:147

I remember this is better off done in a railtie - somehow.

I've also seen a related issue with exactly this same code location: #342

@vovimayhem
Copy link
Author

Dudes, your'e dropping support for Rails 3.x?

@vovimayhem
Copy link
Author

vovimayhem commented Apr 30, 2017

OK I saw it on #292 - Dropping support for 3.2.x for good.

Sad (for me) - Forking out & backporting #292 on my own for 1.x.

Let me know if your'e up for adding the backport onto a new 1.x release.

@coorasse
Copy link
Member

coorasse commented May 2, 2017

Up for a new 1.x release. PR is welcome!

@vovimayhem
Copy link
Author

There it is. I just cherry-pick'd @kuldeepaggarwal commit. Credit to whom credit is due :)

@coorasse coorasse self-assigned this May 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants