group specs related to skip
functionality in a context
Dieser Commit ist enthalten in:
Ursprung
3c70b712bf
Commit
e260241dea
1 geänderte Dateien mit 41 neuen und 38 gelöschten Zeilen
|
@ -50,52 +50,55 @@ describe CustomWizard::WizardController do
|
||||||
expect(response.parsed_body["error"]).to eq("We couldn't find a wizard at that address.")
|
expect(response.parsed_body["error"]).to eq("We couldn't find a wizard at that address.")
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'skips a wizard if user is allowed to skip' do
|
context 'when user skips the wizard' do
|
||||||
put '/w/super-mega-fun-wizard/skip.json'
|
|
||||||
expect(response.status).to eq(200)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'lets user skip if user cant access wizard' do
|
it 'skips a wizard if user is allowed to skip' do
|
||||||
@template["permitted"] = permitted_json["permitted"]
|
put '/w/super-mega-fun-wizard/skip.json'
|
||||||
CustomWizard::Template.save(@template, skip_jobs: true)
|
expect(response.status).to eq(200)
|
||||||
|
end
|
||||||
|
|
||||||
put '/w/super-mega-fun-wizard/skip.json'
|
it 'lets user skip if user cant access wizard' do
|
||||||
expect(response.status).to eq(200)
|
@template["permitted"] = permitted_json["permitted"]
|
||||||
end
|
CustomWizard::Template.save(@template, skip_jobs: true)
|
||||||
|
|
||||||
it 'returns a no skip message if user is not allowed to skip' do
|
put '/w/super-mega-fun-wizard/skip.json'
|
||||||
@template['required'] = 'true'
|
expect(response.status).to eq(200)
|
||||||
CustomWizard::Template.save(@template)
|
end
|
||||||
put '/w/super-mega-fun-wizard/skip.json'
|
|
||||||
expect(response.parsed_body['error']).to eq("Wizard can't be skipped")
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'skip response contains a redirect_to if in users submissions' do
|
it 'returns a no skip message if user is not allowed to skip' do
|
||||||
@wizard = CustomWizard::Wizard.create(@template["id"], user)
|
@template['required'] = 'true'
|
||||||
CustomWizard::Submission.new(@wizard, redirect_to: "/t/2").save
|
CustomWizard::Template.save(@template)
|
||||||
put '/w/super-mega-fun-wizard/skip.json'
|
put '/w/super-mega-fun-wizard/skip.json'
|
||||||
expect(response.parsed_body['redirect_to']).to eq('/t/2')
|
expect(response.parsed_body['error']).to eq("Wizard can't be skipped")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "deletes the submission if user has filled up some data" do
|
it 'skip response contains a redirect_to if in users submissions' do
|
||||||
@wizard = CustomWizard::Wizard.create(@template["id"], user)
|
@wizard = CustomWizard::Wizard.create(@template["id"], user)
|
||||||
CustomWizard::Submission.new(@wizard, step_1_field_1: "Hello World").save
|
CustomWizard::Submission.new(@wizard, redirect_to: "/t/2").save
|
||||||
current_submission = @wizard.current_submission
|
put '/w/super-mega-fun-wizard/skip.json'
|
||||||
put '/w/super-mega-fun-wizard/skip.json'
|
expect(response.parsed_body['redirect_to']).to eq('/t/2')
|
||||||
list = CustomWizard::Submission.list(@wizard)
|
end
|
||||||
|
|
||||||
expect(list.any? { |submission| submission.id == current_submission.id }).to eq(false)
|
it "deletes the submission if user has filled up some data" do
|
||||||
end
|
@wizard = CustomWizard::Wizard.create(@template["id"], user)
|
||||||
|
CustomWizard::Submission.new(@wizard, step_1_field_1: "Hello World").save
|
||||||
|
current_submission = @wizard.current_submission
|
||||||
|
put '/w/super-mega-fun-wizard/skip.json'
|
||||||
|
list = CustomWizard::Submission.list(@wizard)
|
||||||
|
|
||||||
it "starts from the first step if user visits after skipping the wizard" do
|
expect(list.any? { |submission| submission.id == current_submission.id }).to eq(false)
|
||||||
put '/w/super-mega-fun-wizard/steps/step_1.json', params: {
|
end
|
||||||
fields: {
|
|
||||||
step_1_field_1: "Text input"
|
it "starts from the first step if user visits after skipping the wizard" do
|
||||||
|
put '/w/super-mega-fun-wizard/steps/step_1.json', params: {
|
||||||
|
fields: {
|
||||||
|
step_1_field_1: "Text input"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
put '/w/super-mega-fun-wizard/skip.json'
|
||||||
put '/w/super-mega-fun-wizard/skip.json'
|
get '/w/super-mega-fun-wizard.json'
|
||||||
get '/w/super-mega-fun-wizard.json'
|
|
||||||
|
|
||||||
expect(response.parsed_body["start"]).to eq('step_1')
|
expect(response.parsed_body["start"]).to eq('step_1')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Laden …
In neuem Issue referenzieren