FIX: Remove action buttons if post has already been reviewed (#20126)

* FIX: Remove action buttons if post has already been reviewed

* Change the approve to reject test to expect an error

* Adds a controller spec to ensure you can't edit a non-pending review item

* Remove unnessary conditional
This commit is contained in:
Blake Erickson
2023-02-06 11:55:52 -07:00
committed by GitHub
parent ec4ac1465e
commit c540167982
3 changed files with 35 additions and 16 deletions

View File

@ -394,14 +394,15 @@ RSpec.describe Reviewable, type: :model do
it "triggers a notification on approve -> reject to update status" do
reviewable = Fabricate(:reviewable_queued_post, status: Reviewable.statuses[:approved])
expect do reviewable.perform(moderator, :reject_post) end.to change {
Jobs::NotifyReviewable.jobs.size
}.by(1)
expect { reviewable.perform(moderator, :reject_post) }.to raise_error(
Reviewable::InvalidAction,
)
end
job = Jobs::NotifyReviewable.jobs.last
it "triggers a notification on approve -> edit to update status" do
reviewable = Fabricate(:reviewable_queued_post, status: Reviewable.statuses[:approved])
expect(job["args"].first["reviewable_id"]).to eq(reviewable.id)
expect(job["args"].first["updated_reviewable_ids"]).to contain_exactly(reviewable.id)
expect { reviewable.perform(moderator, :edit_post) }.to raise_error(Reviewable::InvalidAction)
end
it "triggers a notification on reject -> approve to update status" do