FEATURE: Can sort reviewable queue

Choices are Priority / Created At (and desc versions.)
This commit is contained in:
Robin Ward
2019-06-05 13:19:57 -04:00
parent de013262a7
commit d902c4eb9f
7 changed files with 67 additions and 8 deletions

View File

@ -151,11 +151,30 @@ RSpec.describe Reviewable, type: :model do
it 'Does not filter by status when status parameter is set to all' do
rejected_reviewable = Fabricate(:reviewable, target: post, status: Reviewable.statuses[:rejected])
reviewables = Reviewable.list_for(user, status: :all)
expect(reviewables).to match_array [reviewable, rejected_reviewable]
end
it "supports sorting" do
r0 = Fabricate(:reviewable, score: 100, created_at: 3.months.ago)
r1 = Fabricate(:reviewable, score: 999, created_at: 1.month.ago)
list = Reviewable.list_for(user, sort_order: 'priority')
expect(list[0].id).to eq(r1.id)
expect(list[1].id).to eq(r0.id)
list = Reviewable.list_for(user, sort_order: 'priority_asc')
expect(list[0].id).to eq(r0.id)
expect(list[1].id).to eq(r1.id)
list = Reviewable.list_for(user, sort_order: 'created_at')
expect(list[0].id).to eq(r1.id)
expect(list[1].id).to eq(r0.id)
list = Reviewable.list_for(user, sort_order: 'created_at_asc')
expect(list[0].id).to eq(r0.id)
expect(list[1].id).to eq(r1.id)
end
end
end