mirror of
https://github.com/discourse/discourse.git
synced 2025-06-06 03:06:53 +08:00
Wizard: Step 1
This commit is contained in:
@ -3,7 +3,6 @@ require 'cache'
|
||||
|
||||
describe Gaps do
|
||||
|
||||
|
||||
it 'returns no gaps for empty data' do
|
||||
expect(Gaps.new(nil, nil)).to be_blank
|
||||
end
|
||||
|
14
spec/components/step_updater_spec.rb
Normal file
14
spec/components/step_updater_spec.rb
Normal file
@ -0,0 +1,14 @@
|
||||
require 'rails_helper'
|
||||
require_dependency 'wizard/step_updater'
|
||||
|
||||
describe Wizard::StepUpdater do
|
||||
let(:user) { Fabricate(:admin) }
|
||||
|
||||
it "can update the forum title" do
|
||||
updater = Wizard::StepUpdater.new(user, 'forum_title')
|
||||
updater.update(title: 'new forum title')
|
||||
|
||||
expect(updater.success?).to eq(true)
|
||||
expect(SiteSetting.title).to eq("new forum title")
|
||||
end
|
||||
end
|
48
spec/components/wizard_spec.rb
Normal file
48
spec/components/wizard_spec.rb
Normal file
@ -0,0 +1,48 @@
|
||||
require 'rails_helper'
|
||||
require 'wizard'
|
||||
|
||||
describe Wizard do
|
||||
|
||||
let(:wizard) { Wizard.new }
|
||||
|
||||
it "has default values" do
|
||||
expect(wizard.start).to be_blank
|
||||
expect(wizard.steps).to be_empty
|
||||
end
|
||||
|
||||
describe "append_step" do
|
||||
|
||||
let(:step1) { wizard.create_step('first-step') }
|
||||
let(:step2) { wizard.create_step('second-step') }
|
||||
|
||||
it "adds the step correctly" do
|
||||
|
||||
expect(step1.index).to be_blank
|
||||
|
||||
wizard.append_step(step1)
|
||||
expect(wizard.steps.size).to eq(1)
|
||||
expect(wizard.start).to eq(step1)
|
||||
expect(step1.next).to be_blank
|
||||
expect(step1.previous).to be_blank
|
||||
expect(step1.index).to eq(0)
|
||||
|
||||
expect(step1.fields).to be_empty
|
||||
field = step1.add_field(id: 'test', type: 'text')
|
||||
expect(step1.fields).to eq([field])
|
||||
end
|
||||
|
||||
it "sequences multiple steps" do
|
||||
wizard.append_step(step1)
|
||||
wizard.append_step(step2)
|
||||
|
||||
expect(wizard.steps.size).to eq(2)
|
||||
expect(wizard.start).to eq(step1)
|
||||
expect(step1.next).to eq(step2)
|
||||
expect(step1.previous).to be_blank
|
||||
expect(step2.previous).to eq(step1)
|
||||
expect(step1.index).to eq(0)
|
||||
expect(step2.index).to eq(1)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
Reference in New Issue
Block a user