Add spec for fix
Dieser Commit ist enthalten in:
Ursprung
805e934fdf
Commit
f908e5ec9d
3 geänderte Dateien mit 42 neuen und 0 gelöschten Zeilen
|
@ -47,6 +47,14 @@ describe CustomWizard::Builder do
|
|||
)
|
||||
}
|
||||
|
||||
let(:boolean_field_condition_json) {
|
||||
JSON.parse(
|
||||
File.open(
|
||||
"#{Rails.root}/plugins/discourse-custom-wizard/spec/fixtures/condition/boolean_field_condition.json"
|
||||
).read
|
||||
)
|
||||
}
|
||||
|
||||
before do
|
||||
Group.refresh_automatic_group!(:trust_level_3)
|
||||
CustomWizard::Template.save(
|
||||
|
@ -322,6 +330,7 @@ describe CustomWizard::Builder do
|
|||
context "with condition" do
|
||||
before do
|
||||
@template[:steps][0][:fields][0][:condition] = user_condition_json['condition']
|
||||
@template[:steps][2][:fields][5][:condition] = boolean_field_condition_json['condition']
|
||||
CustomWizard::Template.save(@template.as_json)
|
||||
end
|
||||
|
||||
|
@ -334,6 +343,16 @@ describe CustomWizard::Builder do
|
|||
wizard = CustomWizard::Builder.new(@template[:id], user).build
|
||||
expect(wizard.steps.first.fields.first.id).to eq(@template[:steps][0][:fields][1]['id'])
|
||||
end
|
||||
|
||||
it "works if a field condition uses 'is true/false'" do
|
||||
builder = CustomWizard::Builder.new(@template[:id], user)
|
||||
wizard = builder.build
|
||||
wizard.create_updater('step_2', step_2_field_5: 'true').update
|
||||
|
||||
builder = CustomWizard::Builder.new(@template[:id], user)
|
||||
wizard = builder.build
|
||||
expect(wizard.steps.last.fields.last.id).to eq(@template[:steps][2][:fields][5]['id'])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
17
spec/fixtures/condition/boolean_field_condition.json
gevendort
Normale Datei
17
spec/fixtures/condition/boolean_field_condition.json
gevendort
Normale Datei
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"condition": [
|
||||
{
|
||||
"type": "validation",
|
||||
"pairs": [
|
||||
{
|
||||
"index": 0,
|
||||
"key": "step_2_field_5",
|
||||
"key_type": "wizard_field",
|
||||
"value": "true",
|
||||
"value_type": "text",
|
||||
"connector": "is"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
6
spec/fixtures/wizard.json
gevendort
6
spec/fixtures/wizard.json
gevendort
|
@ -157,6 +157,12 @@
|
|||
"label": "User Selector",
|
||||
"description": "",
|
||||
"type": "user_selector"
|
||||
},
|
||||
{
|
||||
"id": "step_3_field_6",
|
||||
"label": "Conditional User Selector",
|
||||
"description": "Shown when checkbox in step_2_field_5 is true",
|
||||
"type": "user_selector"
|
||||
}
|
||||
],
|
||||
"description": "Unfortunately not the edible type :sushi: "
|
||||
|
|
Laden …
In neuem Issue referenzieren