mirror of
https://github.com/discourse/discourse.git
synced 2024-12-24 00:03:55 +08:00
55bdab2b3b
Since the poll post handler runs very early in the post creation process, it's possible to run the handler on an obiviously invalid post. This change ensures the post's `raw` value is present before proceeding.
27 lines
585 B
Ruby
27 lines
585 B
Ruby
# frozen_string_literal: true
|
|
|
|
require "rails_helper"
|
|
|
|
RSpec.describe PostsController do
|
|
let(:admin) { Fabricate(:admin) }
|
|
|
|
describe "#create" do
|
|
it "fails gracefully without a post body" do
|
|
key = Fabricate(:api_key).key
|
|
|
|
expect do
|
|
post "/posts.json",
|
|
params: {
|
|
title: "this is test body",
|
|
},
|
|
headers: {
|
|
HTTP_API_USERNAME: admin.username,
|
|
HTTP_API_KEY: key,
|
|
}
|
|
end.not_to change { Topic.count }
|
|
|
|
expect(response.status).to eq(422)
|
|
end
|
|
end
|
|
end
|