Add tests for our policies - #989
Conversation
dc18516 to
cc894bc
Compare
There was a problem hiding this comment.
All for hardening and testing the policies! I'll keep this open, until we resolve the PR earlier in the stack.
A few open suggestions:
- There's a gem (that I wrote) that provides some custom assertions for policies, so we can just write
assert_permitted .... Though I also understand not wanting to add a gem for rather trivial things like this - I would avoid the confusion of
anonymous userand use something likeguest(since an anonymous user is in fact the absence of a user) - I have the habit of checking all user types for each action/scope/method, just for clarity. So often do something like:
test 'should allow index for users and moderators' do assert_predicate Pundit.policy!(@user, Album), :index? assert_predicate Pundit.policy!(@moderator, Album), :index? assert_not_predicate Pundit.policy!(nil, Album), :index?
9ddea37 to
0ca9e46
Compare
fb27792 to
5ac792a
Compare
|
@robbevp I updated the |
5ac792a to
79ad1f6
Compare
0ca9e46 to
ac16eef
Compare
79ad1f6 to
577037b
Compare
577037b to
def507c
Compare
Yes, I think is going in the right direction. I don't have a strong opinion about which assertions to group together, but I can now better orientate myself in the test file than before |
d813a25 to
80bcb10
Compare
robbevp
left a comment
There was a problem hiding this comment.
👍 I'd just split off the changes in the workflows and flake to keep the PR focused on one thing
80bcb10 to
a950ed8
Compare
The only changes to our actual app code is some hardening in the permitted attributes. This shouldn't result in any behaviour changes.