Commit c34e6ede authored by Alper Akgun's avatar Alper Akgun

Trial select form to remember posted form fields

Currently trial select form does not remember posted form fields. This
MR adds posted values
parent 6bfe46fe
......@@ -13,7 +13,7 @@ module EE
], selected)
end
def namespace_options_for_select
def namespace_options_for_select(selected = nil)
groups = current_user.manageable_groups.map { |g| [g.name, g.id] }
users = [[current_user.namespace.name, current_user.namespace_id]]
......@@ -23,7 +23,7 @@ module EE
'Users' => users
}
grouped_options_for_select(grouped_options, nil, prompt: _('Please select'))
grouped_options_for_select(grouped_options, selected, prompt: _('Please select'))
end
def show_trial_errors?(namespace, service_result)
......
......@@ -12,7 +12,7 @@
= form_tag apply_trials_path(glm_params), method: :post do
.form-group.gl-select2-html5-required-fix
= label_tag :namespace_id, _('This subscription is for'), for: :namespace_id, class: 'col-form-label'
= select_tag :namespace_id, namespace_options_for_select, class: 'select2', required: true
= select_tag :namespace_id, namespace_options_for_select(params[:namespace_id]), class: 'select2', required: true
#group_name.form-group.hidden
= label_tag :new_group_name, _('New Group Name'), for: :new_group_name, class: 'col-form-label'
= text_field_tag :new_group_name, nil, class: 'form-control'
......@@ -20,10 +20,10 @@
= label_tag :trial_entity, _('Is this GitLab trial for your company?')
.gl-form-checkbox-group
.gl-form-checkbox.form-check.form-check-inline
= radio_button_tag :trial_entity, :company, false, required: true, class: 'form-check-input'
= radio_button_tag :trial_entity, :company, params[:trial_entity]=='company', required: true, class: 'form-check-input'
= label_tag :trial_entity_company, _('Yes'), class: 'form-check-label'
.gl-form-checkbox.form-check.form-check-inline
= radio_button_tag :trial_entity, :individual, false, required: true, class: 'form-check-input'
= radio_button_tag :trial_entity, :individual, params[:trial_entity]=='individual', required: true, class: 'form-check-input'
= label_tag :trial_entity_individual, _('No'), class: 'form-check-label'
= submit_tag _('Start your free trial'), class: 'btn btn-success btn-block'
......
......@@ -136,11 +136,14 @@ describe 'Trial Select Namespace', :js do
expect(find('.flash-text')).to have_text(error_message)
expect(current_path).to eq(apply_trials_path)
expect(find('#namespace_id', visible: false).value).to eq(user.namespace.id.to_s)
# new group name should be functional
select2 '0', from: '#namespace_id'
expect(page).to have_field('New Group Name')
expect(find('#trial_entity_individual').checked?).to be(false)
expect(find('#trial_entity_company').checked?).to be(true)
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