mirror of
https://github.com/discourse/discourse.git
synced 2024-12-03 16:41:00 +08:00
30990006a9
This reduces chances of errors where consumers of strings mutate inputs and reduces memory usage of the app. Test suite passes now, but there may be some stuff left, so we will run a few sites on a branch prior to merging
40 lines
1.2 KiB
Ruby
40 lines
1.2 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require "rails_helper"
|
|
|
|
describe NewPostManager do
|
|
let(:user) { Fabricate(:newuser) }
|
|
let(:admin) { Fabricate(:admin) }
|
|
|
|
describe "when new post containing a poll is queued for approval" do
|
|
before do
|
|
SiteSetting.poll_minimum_trust_level_to_create = 0
|
|
end
|
|
|
|
it "should render the poll upon approval" do
|
|
params = {
|
|
raw: "[poll]\n* 1\n* 2\n* 3\n[/poll]",
|
|
archetype: "regular",
|
|
category: "",
|
|
typing_duration_msecs: "2700",
|
|
composer_open_duration_msecs: "12556",
|
|
visible: true,
|
|
image_sizes: nil,
|
|
is_warning: false,
|
|
title: "This is a test post with a poll",
|
|
ip_address: "127.0.0.1",
|
|
user_agent: "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36",
|
|
referrer: "http://localhost:3000/",
|
|
first_post_checks: true
|
|
}
|
|
|
|
result = NewPostManager.new(user, params).perform
|
|
expect(result.action).to eq(:enqueued)
|
|
expect(result.reviewable).to be_present
|
|
|
|
review_result = result.reviewable.perform(admin, :approve_post)
|
|
expect(Poll.where(post: review_result.created_post).exists?).to eq(true)
|
|
end
|
|
end
|
|
end
|