1
0
Fork 0
Dieser Commit ist enthalten in:
Angus McLeod 2023-02-07 13:17:40 +01:00
Ursprung 8f8c6d50c6
Commit 1eefd99c6a
3 geänderte Dateien mit 13 neuen und 3 gelöschten Zeilen

Datei anzeigen

@ -10,9 +10,9 @@ import discourseComputed from "discourse-common/utils/decorators";
const GUEST_GROUP_ID = -1;
const CustomWizardAdmin = EmberObject.extend({
@discourseComputed("permitted.@each")
@discourseComputed("permitted.@each.output")
allowGuests(permitted) {
return permitted.filter((p) => p.output === GUEST_GROUP_ID).length;
return permitted.filter((p) => p.output.includes(GUEST_GROUP_ID)).length;
},
save(opts) {

Datei anzeigen

@ -83,7 +83,7 @@ class CustomWizard::TemplateValidator
def validate_action(action)
guests_permitted = @data[:permitted] && @data[:permitted].any? do |m|
m[:output] === CustomWizard::Wizard::GUEST_GROUP_ID
m["output"].include?(CustomWizard::Wizard::GUEST_GROUP_ID)
end
if guests_permitted && CustomWizard::Action::REQUIRES_USER.include?(action[:type])

Datei anzeigen

@ -7,6 +7,7 @@ describe CustomWizard::TemplateValidator do
let(:user_condition) { get_wizard_fixture("condition/user_condition") }
let(:permitted_json) { get_wizard_fixture("wizard/permitted") }
let(:composer_preview) { get_wizard_fixture("field/composer_preview") }
let(:guests_permitted) { get_wizard_fixture("wizard/guests_permitted") }
let(:valid_liquid_template) {
<<-LIQUID.strip
@ -146,6 +147,15 @@ describe CustomWizard::TemplateValidator do
).to eq(true)
end
it "validates restrictions on wizards that permit guests" do
template[:permitted] = guests_permitted['permitted']
validator = CustomWizard::TemplateValidator.new(template)
expect(validator.perform).to eq(false)
expect(validator.errors.first.type).to eq(
I18n.t("wizard.validation.not_permitted_for_guests", object_id: "action_1")
)
end
it "validates step attributes" do
template[:steps][0][:condition] = user_condition['condition']
expect(