-
Notifications
You must be signed in to change notification settings - Fork 27
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
Lots of failures with rolify gem after 4.1 -> 5.0 bump #203
Comments
Do you use Queue Mode? The only significant change I can think of is using by default RAILS_ENV=test/RACK_ENV=test List of changes for the knapsack_pro 5.0.0 @geoffharcourt Is the bug happening also when you try to run knapsack_pro on your local machine or only in CI? Can you share your Gemfile? Is Can you share what command do you use to run Knapsack Pro? Do you pass any options or use non standard prefix etc. FYI @3v0k4 if you have any ideas what we could check to debug this feel free to chime in. Thanks. |
Thanks for the issue @geoffharcourt and sorry for the trouble. I assume in local testing you are using the test runner directly without Knapsack, correct? Could you please try to add It would be super useful if you could try to run on CI the following and let me know if the problems go away (notice the # pick the appropriate test runner
bundle exec rake knapsack_pro:queue:rspec_go
bundle exec rake knapsack_pro:queue:cucumber_go
bundle exec rake knapsack_pro:minitest_go Also, the answers to @ArturT's question would be useful for me to investigate deeper. |
Hi, we're using RSpec in Queue Mode. I tried adding the |
The stacktrace for these failures almost always looks like this:
So FactoryBot has a callback, and that method's missing on the model in CI but not in other environments as far as we can tell. The only change that causes this failure to start appearing is bumping knapsack_pro from 4.1.0 -> 5.0.0 (there are no other changes in Gemfile.lock). |
@3v0k4 running with the |
@geoffharcourt thanks for all the info, please hold on 4.1.x for now. |
The difference between task :rspec, [:rspec_args] do |_, args|
Kernel.system("RAILS_ENV=test RACK_ENV=test #{$PROGRAM_NAME} 'knapsack_pro:queue:rspec_go[#{args[:rspec_args]}]'")
Kernel.exit($?.exitstatus)
end
task :rspec_go, [:rspec_args] do |_, args|
KnapsackPro::Runners::Queue::RSpecRunner.run(args[:rspec_args])
end In other words, If you use Is it the case? Also, can you please paste your CI config here? (or send via email at support (at) knapsackpro.com). I assume you call Rolify.dynamic_shortcuts = false
Rolify.dynamic_shortcuts = true When include Role
extend Dynamic if Rolify.dynamic_shortcuts where In your stacktrace, I see
which is self.class.define_dynamic_method(role_name, resource) if Rolify.dynamic_shortcuts which is the line that triggers the error:
But RolifyCommunity/rolify#455 describes a similar problem. Though, I cannot see why upgrading knapsack_pro from 4.1 to 5.x would trigger it (given that we identified the issue in Do you see the same failures if you run Knapsack 5.x locally? |
I noticed a couple of things that probably won't fix this issue but you may want to consider:
I try to create a new Rails app from scratch with RSpec, FactoryBot, and Rolify, however I cannot reproduce this issue. I know it's a big ask, but is there any chance you could share a reproducible example. If not, I'll try to dig deeper as soon as you have a chance to take a look at my last comment. Thanks for your help, Geoff! 🙏 |
@3v0k4 I'm deeply appreciative of the time you've already spent here. I'm working tracking some of the possible variables contributing to our case here. One thing we're doing that might be relevant is that we're calling |
OK, I tried moving |
An update: we saw that the |
@geoffharcourt you're welcome. This actually taught me a few things, so thank you! |
Hi,
We're still not 100% sure what the root cause is, but when we tried to upgrade to 5.0.0 after the recent release, nearly every spec that involved the use of functionality from the rolify gem (v6.0.1) started failing for one of two reasons.
The first and most common is that when we try to apply a role to a user we're now seeing:
These specs do not fail in local testing. I am assuming from the rolify issues and the differences between CI and local development that this has something to do with loading order that's somehow different with CI doing eager loading and using Knapsack vs. not.
I can't tell from the code changes in the new release what exactly would cause this, but I wanted to file this issue in case anyone else sees similar behavior.
The text was updated successfully, but these errors were encountered: