-
Notifications
You must be signed in to change notification settings - Fork 22
Description
The readme current states the following:
Warning: Currently, Pundit Matchers does not automatically check if the attribute is permitted by a
permitted_attributes_for_#{action}method, so even if you include aforbid_mass_assignment_of(:attribute)expectation in the policy spec, it's entirely possible that the attribute is being permitted through apermitted_attributes_for_#{action}method that is tested separately. For this reason, you should always explicitly test all implementedpermitted_attributes_for_#{action}methods, as demonstrated in the example.
However if an attribute is permitted or forbidden in all permitted_attributes methods in the policy, the spec code can become quite long winded. Here's an example from the readme:
it { is_expected.to permit_mass_assignment_of(:slug) }
it { is_expected.to permit_mass_assignment_of(:slug).for_action(:create) }
it { is_expected.to permit_mass_assignment_of(:slug).for_action(:update) }It would be useful to check do this test in a single statement. I propose that we add a for_all_actions compose matcher to do just that:
it { is_expected.to permit_mass_assignment_of(:slug).for_all_actions }This would also work for forbid_mass_assignment_of.