mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 11:11:13 +08:00
DEV: Do not show handled reviewables in the user menu (#18402)
Currently, the reviewables tab in the user menu shows pending reviewables at the top of the menu and fills the remaining space in the menu with old/handled reviewables. This PR makes the revieables tab show only pending reviewables and hides the tab altogether from the menu if there are no pending reviewables. We're going to follow-up with another change soon that will show pending reviewables in the main tab of the user menu. Internal topic: t/73220.
This commit is contained in:
@ -300,87 +300,6 @@ RSpec.describe Reviewable, type: :model do
|
||||
end
|
||||
end
|
||||
|
||||
describe ".recent_list_with_pending_first" do
|
||||
fab!(:pending_reviewable1) do
|
||||
Fabricate(
|
||||
:reviewable,
|
||||
score: 150,
|
||||
created_at: 7.minutes.ago,
|
||||
status: Reviewable.statuses[:pending]
|
||||
)
|
||||
end
|
||||
fab!(:pending_reviewable2) do
|
||||
Fabricate(
|
||||
:reviewable,
|
||||
score: 100,
|
||||
status: Reviewable.statuses[:pending]
|
||||
)
|
||||
end
|
||||
fab!(:approved_reviewable1) do
|
||||
Fabricate(
|
||||
:reviewable,
|
||||
created_at: 1.minutes.ago,
|
||||
score: 300,
|
||||
status: Reviewable.statuses[:approved]
|
||||
)
|
||||
end
|
||||
fab!(:approved_reviewable2) do
|
||||
Fabricate(
|
||||
:reviewable,
|
||||
created_at: 5.minutes.ago,
|
||||
score: 200,
|
||||
status: Reviewable.statuses[:approved]
|
||||
)
|
||||
end
|
||||
|
||||
fab!(:admin) { Fabricate(:admin) }
|
||||
|
||||
it "returns a list of reviewables with pending items first" do
|
||||
list = Reviewable.recent_list_with_pending_first(admin)
|
||||
expect(list.map(&:id)).to eq([
|
||||
pending_reviewable1.id,
|
||||
pending_reviewable2.id,
|
||||
approved_reviewable1.id,
|
||||
approved_reviewable2.id
|
||||
])
|
||||
|
||||
pending_reviewable1.update!(status: Reviewable.statuses[:rejected])
|
||||
rejected_reviewable = pending_reviewable1
|
||||
|
||||
list = Reviewable.recent_list_with_pending_first(admin)
|
||||
expect(list.map(&:id)).to eq([
|
||||
pending_reviewable2.id,
|
||||
approved_reviewable1.id,
|
||||
approved_reviewable2.id,
|
||||
rejected_reviewable.id,
|
||||
])
|
||||
end
|
||||
|
||||
it "only includes reviewables whose score is above the minimum or are forced for review" do
|
||||
SiteSetting.reviewable_default_visibility = 'high'
|
||||
Reviewable.set_priorities({ high: 200 })
|
||||
|
||||
list = Reviewable.recent_list_with_pending_first(admin)
|
||||
expect(list.map(&:id)).to eq([
|
||||
approved_reviewable1.id,
|
||||
approved_reviewable2.id,
|
||||
])
|
||||
|
||||
pending_reviewable1.update!(force_review: true)
|
||||
|
||||
list = Reviewable.recent_list_with_pending_first(admin)
|
||||
expect(list.map(&:id)).to eq([
|
||||
pending_reviewable1.id,
|
||||
approved_reviewable1.id,
|
||||
approved_reviewable2.id,
|
||||
])
|
||||
end
|
||||
|
||||
it "accepts a limit argument to limit the number of returned records" do
|
||||
expect(Reviewable.recent_list_with_pending_first(admin, limit: 2).size).to eq(2)
|
||||
end
|
||||
end
|
||||
|
||||
it "valid_types returns the appropriate types" do
|
||||
expect(Reviewable.valid_type?('ReviewableUser')).to eq(true)
|
||||
expect(Reviewable.valid_type?('ReviewableQueuedPost')).to eq(true)
|
||||
|
Reference in New Issue
Block a user