mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 18:51:08 +08:00
FIX: Return a 404 when the draft_key
is missing
Previously if `draft_key` was missing you'd get a 500 error in the logs.
This commit is contained in:
@ -11,6 +11,8 @@ class DraftController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
raise Discourse::NotFound.new if params[:draft_key].blank?
|
||||||
|
|
||||||
sequence =
|
sequence =
|
||||||
begin
|
begin
|
||||||
Draft.set(
|
Draft.set(
|
||||||
|
@ -21,6 +21,12 @@ describe DraftController do
|
|||||||
expect(Draft.get(user, 'xyz', 0)).to eq(%q({"my":"data"}))
|
expect(Draft.get(user, 'xyz', 0)).to eq(%q({"my":"data"}))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "returns 404 when the key is missing" do
|
||||||
|
user = sign_in(Fabricate(:user))
|
||||||
|
post "/draft.json", params: { data: { my: "data" }.to_json, sequence: 0 }
|
||||||
|
expect(response.status).to eq(404)
|
||||||
|
end
|
||||||
|
|
||||||
it 'checks for an conflict on update' do
|
it 'checks for an conflict on update' do
|
||||||
user = sign_in(Fabricate(:user))
|
user = sign_in(Fabricate(:user))
|
||||||
post = Fabricate(:post, user: user)
|
post = Fabricate(:post, user: user)
|
||||||
|
Reference in New Issue
Block a user