mirror of
https://github.com/discourse/discourse.git
synced 2025-02-17 01:22:44 +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:
parent
aad46a1aba
commit
bfdd42c53a
|
@ -11,6 +11,8 @@ class DraftController < ApplicationController
|
|||
end
|
||||
|
||||
def update
|
||||
raise Discourse::NotFound.new if params[:draft_key].blank?
|
||||
|
||||
sequence =
|
||||
begin
|
||||
Draft.set(
|
||||
|
|
|
@ -21,6 +21,12 @@ describe DraftController do
|
|||
expect(Draft.get(user, 'xyz', 0)).to eq(%q({"my":"data"}))
|
||||
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
|
||||
user = sign_in(Fabricate(:user))
|
||||
post = Fabricate(:post, user: user)
|
||||
|
|
Loading…
Reference in New Issue
Block a user