Commit 23cc2681 authored by marcheing's avatar marcheing

Add occupation select helper for profile form

parent a1833680
......@@ -6,4 +6,10 @@ module ProfileHelper
def state_select(states)
options_for_select states.map(&:name)
end
def occupation_select
options_for_select(I18n.t('occupations').map do |key, occupation|
key.zero? ? [occupation, nil] : [occupation, occupation]
end)
end
end
......@@ -192,15 +192,10 @@
<fieldset>
<div class="field-label">
<%= f.label "#{t('occupation')} *", for: 'user-profession' %>
<%= f.label "#{t('occupation')} *", for: 'user-occuation' %>
</div>
<div class="field-item">
<select id="user-profession" name="user-profession" required>
<option value="">Selecione sua profissão</option>
{{#each profissoes}}
<option value="{{ id }}">{{ profissao }}</option>
{{/each}}
</select>
<%= select_tag 'occupation', occupation_select, id: 'user-occupation' %>
<span class="form-error">
Campo obrigatório.
</span>
......
......@@ -22,4 +22,15 @@ describe ProfileHelper, type: :helper do
end
end
end
describe 'occupation_select' do
let!(:occupations) { I18n.t('occupations').values }
let(:result) { helper.occupation_select }
it 'creates options for a select tag with the occupations' do
occupations.each do |occupation|
expect(result).to include CGI.escapeHTML occupation
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