[#1421] Move regions to RegionChamp
This commit is contained in:
parent
95666238ea
commit
5b59bce0b6
5 changed files with 6 additions and 7 deletions
|
@ -19,10 +19,6 @@ class Champ < ApplicationRecord
|
|||
mandatory? && value.blank?
|
||||
end
|
||||
|
||||
def self.regions
|
||||
JSON.parse(Carto::GeoAPI::Driver.regions).sort_by { |e| e['nom'] }.pluck("nom")
|
||||
end
|
||||
|
||||
def self.departements
|
||||
JSON.parse(Carto::GeoAPI::Driver.departements).map { |liste| "#{liste['code']} - #{liste['nom']}" }.push('99 - Étranger')
|
||||
end
|
||||
|
|
|
@ -1,2 +1,5 @@
|
|||
class Champs::RegionChamp < Champs::TextChamp
|
||||
def self.regions
|
||||
JSON.parse(Carto::GeoAPI::Driver.regions).sort_by { |e| e['nom'] }.pluck("nom")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
= form.select :value,
|
||||
Champ.regions,
|
||||
Champs::RegionChamp.regions,
|
||||
required: champ.mandatory?
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
= select_tag("champs['#{champ.id}']",
|
||||
options_for_select(Champ.regions, selected: champ.object.value))
|
||||
options_for_select(Champs::RegionChamp.regions, selected: champ.object.value))
|
||||
|
|
|
@ -12,7 +12,7 @@ feature 'The user' do
|
|||
# there are no extraneous input
|
||||
# attached file works
|
||||
scenario 'fill a dossier', js: true do
|
||||
allow(Champ).to receive(:regions).and_return(['region1', 'region2']).at_least(:once)
|
||||
allow(Champs::RegionChamp).to receive(:regions).and_return(['region1', 'region2']).at_least(:once)
|
||||
allow(Champ).to receive(:departements).and_return(['dep1', 'dep2']).at_least(:once)
|
||||
|
||||
log_in(user.email, password, procedure)
|
||||
|
|
Loading…
Reference in a new issue