Commit 22c497f3 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'vslobodin/restrict-number-of-users-field-for-trials' into 'master'

Restrict number of users input to positive numbers

See merge request gitlab-org/gitlab!18381
parents e5752f0b 53d57f31
......@@ -20,7 +20,7 @@
= text_field_tag :phone_number, params[:phone_number], class: 'form-control', required: true
.form-group
= label_tag :number_of_users, _('How many users will be evaluating the trial?'), for: :number_of_users, class: 'col-form-label'
= number_field_tag :number_of_users, nil, class: 'form-control', required: true
= number_field_tag :number_of_users, nil, class: 'form-control', required: true, min: 1
.form-group
= label_tag :country, _('Country'), class: 'col-form-label'
= select_tag :country, options_for_select([[_('Please select a country'), '']]), class: 'select2', required: true, id: 'country_select', data: { countries_end_point: countries_path }
......
---
title: Restrict number of users input to positive numbers
merge_request: 18381
author:
type: fixed
......@@ -41,28 +41,39 @@ describe 'Trial Capture Lead', :js do
end
end
context 'enters invalid company information' do
context 'enters company information' do
before do
fill_in 'company_name', with: 'GitLab'
select2 '1-99', from: '#company_size'
# to trigger validation error
# skip filling phone number
# fill_in 'phone_number', with: '+1234567890'
fill_in 'number_of_users', with: '1'
select2 'US', from: '#country_select'
click_button 'Continue'
end
context 'without phone number' do
it 'shows validation error' do
fill_in 'number_of_users', with: '1'
click_button 'Continue'
message = page.find('#phone_number').native.attribute('validationMessage')
expect(message).to eq('Please fill out this field.')
expect(current_path).to eq(new_trial_path)
end
end
context 'and enters negative number to the number of users field' do
it 'shows validation error' do
fill_in 'number_of_users', with: '-1'
it 'does not proceeds to the next step' do
click_button 'Continue'
message = page.find('#number_of_users').native.attribute('validationMessage')
expect(message).to eq('Value must be greater than or equal to 1.')
expect(current_path).to eq(new_trial_path)
end
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment