2020-11-03 01:24:20 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
describe CustomWizard::WizardSerializer do
|
2024-10-16 13:52:03 +02:00
|
|
|
fab!(:user)
|
|
|
|
fab!(:category)
|
2021-09-07 14:06:13 +02:00
|
|
|
let(:template) { get_wizard_fixture("wizard") }
|
|
|
|
let(:similar_topics_validation) { get_wizard_fixture("field/validation/similar_topics") }
|
2022-03-25 17:08:24 +01:00
|
|
|
let(:advanced_fields) { get_wizard_fixture("field/advanced_types") }
|
2020-11-03 01:24:20 +01:00
|
|
|
|
|
|
|
before do
|
2021-09-07 14:06:13 +02:00
|
|
|
CustomWizard::Template.save(template, skip_jobs: true)
|
2024-10-16 13:52:03 +02:00
|
|
|
@template = CustomWizard::Template.find("super_mega_fun_wizard")
|
2020-11-03 01:24:20 +01:00
|
|
|
end
|
2021-03-11 07:30:15 +01:00
|
|
|
|
2024-10-16 13:52:03 +02:00
|
|
|
it "should return the wizard attributes" do
|
|
|
|
json =
|
|
|
|
CustomWizard::WizardSerializer.new(
|
|
|
|
CustomWizard::Builder.new(@template[:id], user).build,
|
|
|
|
scope: Guardian.new(user),
|
|
|
|
).as_json
|
2020-11-03 01:24:20 +01:00
|
|
|
expect(json[:wizard][:id]).to eq("super_mega_fun_wizard")
|
|
|
|
expect(json[:wizard][:name]).to eq("Super Mega Fun Wizard")
|
|
|
|
expect(json[:wizard][:background]).to eq("#333333")
|
|
|
|
expect(json[:wizard][:required]).to eq(false)
|
|
|
|
end
|
2021-03-11 07:30:15 +01:00
|
|
|
|
2024-10-16 13:52:03 +02:00
|
|
|
it "should return the wizard steps" do
|
|
|
|
json =
|
|
|
|
CustomWizard::WizardSerializer.new(
|
|
|
|
CustomWizard::Builder.new(@template[:id], user).build,
|
|
|
|
scope: Guardian.new(user),
|
|
|
|
).as_json
|
2020-11-03 01:24:20 +01:00
|
|
|
expect(json[:wizard][:steps].length).to eq(3)
|
|
|
|
end
|
2021-03-11 07:30:15 +01:00
|
|
|
|
2020-11-03 01:24:20 +01:00
|
|
|
it "should return the wizard user attributes" do
|
2024-10-16 13:52:03 +02:00
|
|
|
json =
|
|
|
|
CustomWizard::WizardSerializer.new(
|
|
|
|
CustomWizard::Builder.new(@template[:id], user).build,
|
|
|
|
scope: Guardian.new(user),
|
|
|
|
).as_json
|
|
|
|
expect(json[:wizard][:user]).to eq(BasicUserSerializer.new(user, root: false).as_json)
|
2020-11-03 01:24:20 +01:00
|
|
|
end
|
2021-03-11 07:30:15 +01:00
|
|
|
end
|