-
Notifications
You must be signed in to change notification settings - Fork 22
Description
Currently, to check that the mass assignment of one or more attributes is permitted or forbidden for different actions, we have to declare this as two seperate statements:
it { is_expected.to permit_mass_assignment_of(:publish).for_action(:create) }
it { is_expected.to permit_mass_assignment_of(:publish).for_action(:update) }But it would be nicer to check that the attribute is permitted with a single statement.
My proposal is that we add a new composite matcher to permit_mass_assignment_of and forbid_mass_assignment_of called for_actions which accepts an array of actions to permit/forbid the atttibute(s) in. E.g.
it { is_expected.to permit_mass_assignment_of(:publish).for_actions(%i[create update]) }or another example:
it { is_expected.to forbid_mass_assignment_of(%i[foo bar]).for_actions(%i[destroy]) }The spec should pass if and only if all of the listed attributes are permitted for all of the listed actions, or all of the listed attributes are forbidden for all of the listed actions, for the permit_mass_assignment_of and forbid_mass_assignment_of matchers respectively.