mirror of
https://github.com/discourse/discourse.git
synced 2025-05-28 13:51:18 +08:00
FEATURE: Display pending posts on user’s page
Currently when a user creates posts that are moderated (for whatever reason), a popup is displayed saying the post needs approval and the total number of the user’s pending posts. But then this piece of information is kind of lost and there is nowhere for the user to know what are their pending posts or how many there are. This patch solves this issue by adding a new “Pending” section to the user’s activity page when there are some pending posts to display. When there are none, then the “Pending” section isn’t displayed at all.
This commit is contained in:

committed by
Loïc Guitaut

parent
6e603799eb
commit
a5fbb90df4
@ -261,4 +261,27 @@ describe UserStat do
|
||||
expect(user.user_stat.draft_count).to eq(3)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#update_pending_posts" do
|
||||
subject(:update_pending_posts) { stat.update_pending_posts }
|
||||
|
||||
let!(:reviewable) { Fabricate(:reviewable_queued_post) }
|
||||
let(:user) { reviewable.created_by }
|
||||
let(:stat) { user.user_stat }
|
||||
|
||||
before do
|
||||
stat.update!(pending_posts_count: 0) # the reviewable callback will have set this to 1 already.
|
||||
end
|
||||
|
||||
it "sets 'pending_posts_count'" do
|
||||
expect { update_pending_posts }.to change { stat.pending_posts_count }.to 1
|
||||
end
|
||||
|
||||
it "publishes a message to clients" do
|
||||
MessageBus.expects(:publish).with("/u/#{user.username_lower}/counters",
|
||||
{ pending_posts_count: 1 },
|
||||
user_ids: [user.id], group_ids: [Group::AUTO_GROUPS[:staff]])
|
||||
update_pending_posts
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user