Fix departements / pays / regions drop down list
This commit is contained in:
parent
ec2a4dd9a4
commit
e4826b468a
8 changed files with 51 additions and 13 deletions
|
@ -1 +1,2 @@
|
|||
= render partial: 'users/description/champs/drop_down_template', locals: {values: Champ.departements, champ: champ}
|
||||
= select_tag("champs['#{champ.id}']",
|
||||
options_for_select(Champ.departements, selected: champ.object.value))
|
||||
|
|
|
@ -1,2 +1,6 @@
|
|||
- unless champ.drop_down_list.nil?
|
||||
= render partial: 'users/description/champs/drop_down_template', locals: { drop_down_list: champ.drop_down_list, champ: champ }
|
||||
- if champ.drop_down_list && champ.drop_down_list.options.any?
|
||||
= select_tag("champs['#{champ.id}']",
|
||||
options_for_select(champ.drop_down_list.options, selected: champ.drop_down_list.selected_options(champ),
|
||||
disabled: champ.drop_down_list.disabled_options),
|
||||
multiple: champ.drop_down_list.multiple,
|
||||
class: champ.drop_down_list.multiple ? 'select2' : nil)
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
- unless drop_down_list.options.blank?
|
||||
= select_tag("champs['#{champ.id}']",
|
||||
options_for_select(drop_down_list.options, selected: drop_down_list.selected_options(champ),
|
||||
disabled: drop_down_list.disabled_options),
|
||||
multiple: drop_down_list.multiple,
|
||||
class: drop_down_list.multiple ? 'select2' : nil)
|
|
@ -1 +1,2 @@
|
|||
= render partial: 'users/description/champs/drop_down_template', locals: {values: Champ.pays, champ: champ}
|
||||
= select_tag("champs['#{champ.id}']",
|
||||
options_for_select(Champ.pays, selected: champ.object.value))
|
||||
|
|
|
@ -1,3 +1,2 @@
|
|||
= render partial: 'users/description/champs/drop_down_template', locals: {values: Champ.regions, champ: champ}
|
||||
|
||||
|
||||
= select_tag("champs['#{champ.id}']",
|
||||
options_for_select(Champ.regions, selected: champ.object.value))
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'users/description/champs/departements.html.haml', vcr: {cassette_name: 'geoapi_departements'}, type: :view do
|
||||
let(:champ) { create(:champ) }
|
||||
|
||||
before do
|
||||
render 'users/description/champs/departements.html.haml', champ: champ.decorate
|
||||
end
|
||||
|
||||
it 'should render departments drop down list' do
|
||||
expect(rendered).to include("Ain")
|
||||
end
|
||||
end
|
13
spec/views/users/description/champs/_pays.html.haml_spec.rb
Normal file
13
spec/views/users/description/champs/_pays.html.haml_spec.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'users/description/champs/pays.html.haml', type: :view do
|
||||
let(:champ) { create(:champ) }
|
||||
|
||||
before do
|
||||
render 'users/description/champs/pays.html.haml', champ: champ.decorate
|
||||
end
|
||||
|
||||
it 'should render pays drop down list' do
|
||||
expect(rendered).to include("FRANCE")
|
||||
end
|
||||
end
|
|
@ -0,0 +1,13 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'users/description/champs/regions.html.haml', vcr: {cassette_name: 'geoapi_regions'}, type: :view do
|
||||
let(:champ) { create(:champ) }
|
||||
|
||||
before do
|
||||
render 'users/description/champs/regions.html.haml', champ: champ.decorate
|
||||
end
|
||||
|
||||
it 'should render regions drop down list' do
|
||||
expect(rendered).to include("Normandie")
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue