-
Notifications
You must be signed in to change notification settings - Fork 336
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
Consecutive tests fail when using custom table names #378
Comments
|
Thanks for your reply.
The second test is the testDoesNotExist() method. Dumping the
Regardless of what I'm testing in the second, third, etc. methods the response is always 403 - the admin user is not authorized.
If I comment out the table name definitions then all the tests pass:
|
I created a demo to test this issue, but I couldn't reproduce it. All tests seem to pass. Look at this commit, which basically tries to recreate your setup. To try it yourself:
All tests pass. |
Thanks Joseph. It seems it's something to do with the 'everything()' method. My test user is someone who has access to everything. I created a fork of your demo repo and pushed some changes to it, please see the commit here: pszucs/bouncer-issue-378-demo@faab920
If you comment out the 'superadmin' lines and put the 'read-users' ability back, the tests pass. If the 'superadmin' lines are uncommented, the first test passes, the second one fails. |
I'm thinking of maybe automatically registering the morph map whenever a custom table mapping is added (and whenever a custom model is used) to prevent these kinds of issues. |
I just pushed an update with this. Please try it out on |
Re 2: Yep, tried it on both the sample project and on my 'real' project and your fix works on both of them. Many thanks! |
Would like to comment on this as I am facing this exact issue but with Dusk tests. I am using a custom model and am registering it with The first test will run and complete successfully while creating permissions in the permissions table as entity_type |
Can confirm @zanechua's case. When creating a new role and ability like this:
Updating permissions for that role using:
fills Updating to |
The first test in the class passes and then the rest of the tests fail. I believe this issue is related to this one here: #306
The difference is that I'm not using custom roles, I'm just adding prefixes to the Bouncer table names in the AppServiceProvider's boot method:
The tests are really simple:
These tests pass if I use the default table names.
Any help would be much appreciated.
The text was updated successfully, but these errors were encountered: