Merge pull request #5369 from vinothkannans/queued

FIX: Error if queued post not found while updating
This commit is contained in:
Guo Xiang Tan 2017-11-28 17:51:05 +08:00 committed by GitHub
commit 1d8b834301
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 0 deletions

View File

@ -20,6 +20,8 @@ class QueuedPostsController < ApplicationController
def update
qp = QueuedPost.where(id: params[:id]).first
return render_json_error I18n.t('queue.not_found') if qp.blank?
update_params = params[:queued_post]
qp.raw = update_params[:raw] if update_params[:raw].present?

View File

@ -264,6 +264,7 @@ en:
queue:
delete_reason: "Deleted via post moderation queue"
not_found: "Post not found or already updated."
groups:
success:

View File

@ -31,6 +31,20 @@ describe QueuedPostsController do
let!(:user) { log_in(:moderator) }
let(:qp) { Fabricate(:queued_post) }
context 'not found' do
it 'returns json error' do
qp.destroy!
put :update, params: {
id: qp.id, queued_post: { state: 'approved' }
}, format: :json
expect(response.status).to eq(422)
expect(eval(response.body)).to eq(described_class.new.create_errors_json(I18n.t('queue.not_found')))
end
end
context 'approved' do
it 'updates the post to approved' do