mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-07 07:04:12 +08:00
This PR adds a new site setting for configuring a community moderation topic that will be linked from the reviewable sidebar. It involves adding a new site setting type "topic" which uses the TopicChooser component in the front-end.
26 lines
739 B
Ruby
26 lines
739 B
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe TopicSettingValidator do
|
|
describe "#valid_value?" do
|
|
subject(:validator) { described_class.new }
|
|
|
|
fab!(:topic)
|
|
|
|
it "has a valid error message" do
|
|
expect(validator.error_message).to eq(I18n.t("site_settings.errors.invalid_topic"))
|
|
end
|
|
|
|
it "returns true for blank values" do
|
|
expect(validator.valid_value?("")).to eq(true)
|
|
expect(validator.valid_value?(nil)).to eq(true)
|
|
end
|
|
|
|
it "returns true if value matches an existing topic ID" do
|
|
expect(validator.valid_value?(topic.id)).to eq(true)
|
|
end
|
|
|
|
it "returns false if value does not match an existing topic ID" do
|
|
expect(validator.valid_value?(1337)).to eq(false)
|
|
end
|
|
end
|
|
end
|