expect to forbid, rather than expect not to permit (#14390)
I noticed a warning from rspec when this policy spec ran:
Using expect { }.not_to permit_actions could produce
confusing results. Please use `.to forbid_actions` instead. To
clarify, `.not_to permit_actions` will look at all of the actions and
checks if ANY actions fail, not if all actions fail. Therefore, you
could result in something like this:
it { is_expected.to permit_actions([:new, :create, :edit]) }
it { is_expected.not_to permit_actions([:edit, :destroy]) }
In this case, edit would be true and destroy would be false, but both
tests would pass.
I just follow the helpful advice.
This commit is contained in:
parent
7567e77132
commit
9b5512bd9f
1 changed files with 1 additions and 1 deletions
|
|
@ -12,7 +12,7 @@ RSpec.describe PinnedArticlePolicy, type: :policy do
|
|||
context "when user is signed in as a regular user" do
|
||||
let(:user) { build_stubbed(:user) }
|
||||
|
||||
it { is_expected.not_to permit_actions(%i[show update destroy]) }
|
||||
it { is_expected.to forbid_actions(%i[show update destroy]) }
|
||||
end
|
||||
|
||||
context "when user is signed in as an admin" do
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue