0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-29 20:20:29 +01:00
discourse-custom-wizard/spec/requests/custom_wizard/steps_controller_spec.rb

44 Zeilen
1,1 KiB
Ruby

2021-03-11 07:30:15 +01:00
# frozen_string_literal: true
require_relative '../../plugin_helper'
2020-11-03 01:24:20 +01:00
describe CustomWizard::StepsController do
fab!(:user) {
Fabricate(
:user,
username: 'angus',
email: "angus@email.com",
trust_level: TrustLevel[3]
2021-03-11 07:30:15 +01:00
)
2020-11-03 01:24:20 +01:00
}
before do
CustomWizard::Template.save(
JSON.parse(File.open(
"#{Rails.root}/plugins/discourse-custom-wizard/spec/fixtures/wizard.json"
).read),
skip_jobs: true)
sign_in(user)
end
2021-03-11 07:30:15 +01:00
2020-11-03 01:24:20 +01:00
it 'performs a step update' do
put '/w/super-mega-fun-wizard/steps/step_1.json', params: {
fields: {
step_1_field_1: "Text input"
}
}
expect(response.status).to eq(200)
2021-03-11 07:30:15 +01:00
2020-11-03 01:24:20 +01:00
wizard = CustomWizard::Builder.new("super_mega_fun_wizard", user).build
expect(wizard.current_submission['step_1_field_1']).to eq("Text input")
expect(wizard.start.id).to eq("step_2")
end
2021-03-11 07:30:15 +01:00
2020-11-06 06:39:26 +01:00
it "works if the step has no fields" do
put '/w/super-mega-fun-wizard/steps/step_1.json'
expect(response.status).to eq(200)
2021-03-11 07:30:15 +01:00
2020-11-06 06:39:26 +01:00
wizard = CustomWizard::Builder.new("super_mega_fun_wizard", user).build
expect(wizard.start.id).to eq("step_2")
end
2021-03-11 07:30:15 +01:00
end