mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
Users can see their pending posts
This commit is contained in:
parent
26693c16ac
commit
5bf8c31af4
17 changed files with 225 additions and 101 deletions
|
@ -1,4 +1,5 @@
|
|||
require 'spec_helper'
|
||||
require_dependency 'post_enqueuer'
|
||||
|
||||
describe UserActionsController do
|
||||
context 'index' do
|
||||
|
@ -22,5 +23,35 @@ describe UserActionsController do
|
|||
expect(action["email"]).to eq(nil)
|
||||
expect(action["post_number"]).to eq(1)
|
||||
end
|
||||
|
||||
context "queued posts" do
|
||||
context "without access" do
|
||||
let(:user) { Fabricate(:user) }
|
||||
it "raises an exception" do
|
||||
xhr :get, :index, username: user.username, filter: UserAction::PENDING
|
||||
expect(response).to_not be_success
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
context "with access" do
|
||||
let(:user) { log_in }
|
||||
|
||||
it 'finds queued posts' do
|
||||
queued_post = PostEnqueuer.new(user, 'default').enqueue(raw: 'this is the raw enqueued content')
|
||||
|
||||
xhr :get, :index, username: user.username, filter: UserAction::PENDING
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
parsed = JSON.parse(response.body)
|
||||
actions = parsed["user_actions"]
|
||||
expect(actions.length).to eq(1)
|
||||
|
||||
action = actions.first
|
||||
expect(action['username']).to eq(user.username)
|
||||
expect(action['excerpt']).to be_present
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue