Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-14 13:52:54 +01:00
ceef3f4bc9
* Re structure builder logic to allow for step conditionality Concerns - Performance. Look at whether the additional build in the steps controller can be reduced - Does not work if applied to the last step. - Certain conditions will not work with the first step(?) - How should this be scoped to known functionality? * Add indexes and conditions to steps and fields * Complete and add spec * Complete backend * Complete step conditionality and field indexing * Fix failing spec * Update coverage * Apply rubocop * Apply prettier * Apply prettier to wizard js * Fix schema issues created in merge * Remove setting label for force_final * Improve client wizard cache naming * Improve steps controller and spec conditionality * Improve final step attribute naming * Fix failing spec * Linting * Add one more final step test * Linting * Fix eslint issues * Apply prettier * Linting, syntax, merge and copy cleanups * Update wizard-admin.scss * Fix template linting * Rubocop fixes
39 Zeilen
1,2 KiB
Ruby
39 Zeilen
1,2 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require_relative '../../plugin_helper'
|
|
|
|
describe CustomWizard::FieldSerializer do
|
|
fab!(:user) { Fabricate(:user) }
|
|
|
|
before do
|
|
CustomWizard::Template.save(
|
|
JSON.parse(File.open(
|
|
"#{Rails.root}/plugins/discourse-custom-wizard/spec/fixtures/wizard.json"
|
|
).read),
|
|
skip_jobs: true)
|
|
@wizard = CustomWizard::Builder.new("super_mega_fun_wizard", user).build
|
|
end
|
|
|
|
it "should return basic field attributes" do
|
|
json_array = ActiveModel::ArraySerializer.new(
|
|
@wizard.steps.first.fields,
|
|
each_serializer: CustomWizard::FieldSerializer,
|
|
scope: Guardian.new(user)
|
|
).as_json
|
|
|
|
expect(json_array.size).to eq(4)
|
|
expect(json_array[0][:label]).to eq("<p>Text</p>")
|
|
expect(json_array[0][:description]).to eq("Text field description.")
|
|
expect(json_array[3][:index]).to eq(3)
|
|
end
|
|
|
|
it "should return optional field attributes" do
|
|
json_array = ActiveModel::ArraySerializer.new(
|
|
@wizard.steps.second.fields,
|
|
each_serializer: CustomWizard::FieldSerializer,
|
|
scope: Guardian.new(user)
|
|
).as_json
|
|
expect(json_array[0][:format]).to eq("YYYY-MM-DD")
|
|
expect(json_array[6][:file_types]).to eq(".jpg,.jpeg,.png")
|
|
end
|
|
end
|