Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-25 18:50:27 +01:00
Minor fixes
Dieser Commit ist enthalten in:
Ursprung
8f8c6d50c6
Commit
1eefd99c6a
3 geänderte Dateien mit 13 neuen und 3 gelöschten Zeilen
|
@ -10,9 +10,9 @@ import discourseComputed from "discourse-common/utils/decorators";
|
||||||
const GUEST_GROUP_ID = -1;
|
const GUEST_GROUP_ID = -1;
|
||||||
|
|
||||||
const CustomWizardAdmin = EmberObject.extend({
|
const CustomWizardAdmin = EmberObject.extend({
|
||||||
@discourseComputed("permitted.@each")
|
@discourseComputed("permitted.@each.output")
|
||||||
allowGuests(permitted) {
|
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) {
|
save(opts) {
|
||||||
|
|
|
@ -83,7 +83,7 @@ class CustomWizard::TemplateValidator
|
||||||
|
|
||||||
def validate_action(action)
|
def validate_action(action)
|
||||||
guests_permitted = @data[:permitted] && @data[:permitted].any? do |m|
|
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
|
end
|
||||||
|
|
||||||
if guests_permitted && CustomWizard::Action::REQUIRES_USER.include?(action[:type])
|
if guests_permitted && CustomWizard::Action::REQUIRES_USER.include?(action[:type])
|
||||||
|
|
|
@ -7,6 +7,7 @@ describe CustomWizard::TemplateValidator do
|
||||||
let(:user_condition) { get_wizard_fixture("condition/user_condition") }
|
let(:user_condition) { get_wizard_fixture("condition/user_condition") }
|
||||||
let(:permitted_json) { get_wizard_fixture("wizard/permitted") }
|
let(:permitted_json) { get_wizard_fixture("wizard/permitted") }
|
||||||
let(:composer_preview) { get_wizard_fixture("field/composer_preview") }
|
let(:composer_preview) { get_wizard_fixture("field/composer_preview") }
|
||||||
|
let(:guests_permitted) { get_wizard_fixture("wizard/guests_permitted") }
|
||||||
|
|
||||||
let(:valid_liquid_template) {
|
let(:valid_liquid_template) {
|
||||||
<<-LIQUID.strip
|
<<-LIQUID.strip
|
||||||
|
@ -146,6 +147,15 @@ describe CustomWizard::TemplateValidator do
|
||||||
).to eq(true)
|
).to eq(true)
|
||||||
end
|
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
|
it "validates step attributes" do
|
||||||
template[:steps][0][:condition] = user_condition['condition']
|
template[:steps][0][:condition] = user_condition['condition']
|
||||||
expect(
|
expect(
|
||||||
|
|
Laden …
In neuem Issue referenzieren