discourse/spec/support/common_basic_reviewable_serializer.rb
Osama Sayegh 4d05e3edab
DEV: Include pending reviewables in the main tab in the user menu (#18471)
This commit makes pending reviewables show up in the main tab (a.k.a. "all notifications" tab). Pending reviewables along with unread notifications are always shown first and they're sorted based on their creation date (most recent comes first).

The dismiss button currently only shows up if there are unread notifications and it doesn't dismiss pending reviewables. We may follow up with another change soon that allows makes the dismiss button work with reviewables and remove them from the list without taking any action on them. 

Follow-up to 079450c9e4.
2022-10-05 12:30:02 +03:00

50 lines
1.3 KiB
Ruby

# frozen_string_literal: true
shared_examples "basic reviewable attributes" do
describe "#id" do
it "equals the reviewable's id" do
expect(subject[:id]).to eq(reviewable.id)
end
end
describe "#type" do
it "is the reviewable's type" do
expect(subject[:type]).to eq(reviewable.type)
end
end
describe "#pending" do
it "is false if the reviewable is approved" do
reviewable.update!(status: Reviewable.statuses[:approved])
expect(subject[:pending]).to eq(false)
end
it "is false if the reviewable is rejected" do
reviewable.update!(status: Reviewable.statuses[:rejected])
expect(subject[:pending]).to eq(false)
end
it "is true if the reviewable is pending" do
reviewable.update!(status: Reviewable.statuses[:pending])
expect(subject[:pending]).to eq(true)
end
end
describe "#flagger_username" do
it "equals to the username of the user who created the reviewable" do
reviewable.update!(
created_by: Fabricate(:user, username: "gg.osama")
)
expect(subject[:flagger_username]).to eq("gg.osama")
end
end
describe "#created_at" do
it "serializes the reviewable's created_at field correctly" do
time = 10.minutes.ago
reviewable.update!(created_at: time)
expect(subject[:created_at]).to eq(time)
end
end
end