Merge branch 'develop' into staging
This commit is contained in:
commit
1f3d9316ee
7 changed files with 98 additions and 18 deletions
|
@ -32,7 +32,8 @@ class Users::CarteController < UsersController
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_position
|
def get_position
|
||||||
point = Carto::Geocodeur.convert_adresse_to_point(current_user_dossier.etablissement.geo_adresse) rescue nil
|
etablissement = current_user_dossier.etablissement
|
||||||
|
point = Carto::Geocodeur.convert_adresse_to_point(etablissement.geo_adresse) unless etablissement.nil?
|
||||||
|
|
||||||
lon = '2.428462'
|
lon = '2.428462'
|
||||||
lat = '46.538192'
|
lat = '46.538192'
|
||||||
|
|
|
@ -21,6 +21,9 @@ class CARTO::SGMAP::API
|
||||||
url,
|
url,
|
||||||
verify_ssl: verify_ssl_mode,
|
verify_ssl: verify_ssl_mode,
|
||||||
).post params[:geojson], content_type: 'application/json'
|
).post params[:geojson], content_type: 'application/json'
|
||||||
|
|
||||||
|
rescue RestClient::InternalServerError
|
||||||
|
raise RestClient::ResourceNotFound
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.base_url
|
def self.base_url
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
- unless smart_listing.empty?
|
- unless smart_listing.empty?
|
||||||
%table#dossiers_list.table
|
%table#dossiers_list.table
|
||||||
%thead
|
%thead
|
||||||
%th.col-md-1.col-lg-1= smart_listing.sortable 'Numéro', 'id'
|
%th#sort-id.col-md-1.col-lg-1= smart_listing.sortable 'Numéro', 'id'
|
||||||
%th.col-md-5.col-lg-5= smart_listing.sortable 'Procédure', 'procedure.libelle'
|
%th#sort-libelle.col-md-5.col-lg-5= smart_listing.sortable 'Procédure', 'procedure.libelle'
|
||||||
%th.col-md-2.col-lg-2= smart_listing.sortable 'État', 'state'
|
%th#sort-state.col-md-2.col-lg-2= smart_listing.sortable 'État', 'state'
|
||||||
%th.col-md-2.col-lg-2= smart_listing.sortable 'Date de mise à jour', 'updated_at'
|
%th#sort-updated.col-md-2.col-lg-2= smart_listing.sortable 'Date de mise à jour', 'updated_at'
|
||||||
- if @liste == "brouillon"
|
- if @liste == "brouillon"
|
||||||
%th.col-md-2.col-lg-2= 'Action'
|
%th.col-md-2.col-lg-2= 'Action'
|
||||||
- @dossiers.each do |dossier|
|
- @dossiers.each do |dossier|
|
||||||
- if dossier.kind_of? Invite
|
- if dossier.kind_of? Invite
|
||||||
-invite = dossier
|
- invite = dossier
|
||||||
-dossier = invite.dossier.decorate
|
- dossier = invite.dossier.decorate
|
||||||
- else
|
- else
|
||||||
- dossier = dossier.decorate
|
- dossier = dossier.decorate
|
||||||
|
|
||||||
|
|
|
@ -179,6 +179,24 @@ shared_examples 'carte_controller_spec' do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#get_position' do
|
describe '#get_position' do
|
||||||
|
|
||||||
|
context 'when etablissement is nil' do
|
||||||
|
before do
|
||||||
|
dossier.update etablissement: nil
|
||||||
|
|
||||||
|
stub_request(:get, /http:\/\/api-adresse[.]data[.]gouv[.]fr\/search[?]limit=1&q=/)
|
||||||
|
.to_return(status: 200, body: '{"query": "babouba", "version": "draft", "licence": "ODbL 1.0", "features": [], "type": "FeatureCollection", "attribution": "BAN"}', headers: {})
|
||||||
|
get :get_position, params: {dossier_id: dossier.id}
|
||||||
|
end
|
||||||
|
|
||||||
|
subject { JSON.parse(response.body) }
|
||||||
|
|
||||||
|
it 'on enregistre des coordonnées lat et lon avec les valeurs par defaut' do
|
||||||
|
expect(subject['lat']).to eq('46.538192')
|
||||||
|
expect(subject['lon']).to eq('2.428462')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'Geocodeur renvoie les positions par defaut' do
|
context 'Geocodeur renvoie les positions par defaut' do
|
||||||
let(:etablissement) { create(:etablissement, adresse: bad_adresse, numero_voie: 'dzj', type_voie: 'fzjfk', nom_voie: 'hdidjkz', complement_adresse: 'fjef', code_postal: 'fjeiefk', localite: 'zjfkfz') }
|
let(:etablissement) { create(:etablissement, adresse: bad_adresse, numero_voie: 'dzj', type_voie: 'fzjfk', nom_voie: 'hdidjkz', complement_adresse: 'fjef', code_postal: 'fjeiefk', localite: 'zjfkfz') }
|
||||||
let(:dossier) { create(:dossier, etablissement: etablissement) }
|
let(:dossier) { create(:dossier, etablissement: etablissement) }
|
||||||
|
|
|
@ -2,20 +2,20 @@ require 'spec_helper'
|
||||||
|
|
||||||
feature 'As a User I want to edit a dossier I own', js: true do
|
feature 'As a User I want to edit a dossier I own', js: true do
|
||||||
|
|
||||||
let(:user) { create(:user) }
|
let(:user) { create(:user) }
|
||||||
let(:procedure_for_individual) { create(:procedure, :published, :for_individual, :with_api_carto, :with_type_de_champ, :with_two_type_de_piece_justificative) }
|
let(:procedure_for_individual) { create(:procedure, :published, :for_individual, :with_api_carto, :with_type_de_champ, :with_two_type_de_piece_justificative) }
|
||||||
|
|
||||||
before "Create dossier" do
|
before "Create dossier" do
|
||||||
login_as user, scope: :user
|
login_as user, scope: :user
|
||||||
visit commencer_path(procedure_path: procedure_for_individual.path)
|
visit commencer_path(procedure_path: procedure_for_individual.path)
|
||||||
fill_in 'dossier_individual_attributes_nom', with: 'Nom'
|
fill_in 'dossier_individual_attributes_nom', with: 'Nom'
|
||||||
fill_in 'dossier_individual_attributes_prenom', with: 'Prenom'
|
fill_in 'dossier_individual_attributes_prenom', with: 'Prenom'
|
||||||
fill_in 'dossier_individual_attributes_birthdate', with: '14/10/1987'
|
fill_in 'dossier_individual_attributes_birthdate', with: '14/10/1987'
|
||||||
find(:css, "#dossier_autorisation_donnees[value='1']").set(true)
|
find(:css, "#dossier_autorisation_donnees[value='1']").set(true)
|
||||||
page.find_by_id('etape_suivante').click
|
page.find_by_id('etape_suivante').click
|
||||||
page.find_by_id('etape_suivante').click
|
page.find_by_id('etape_suivante').click
|
||||||
page.find_by_id('suivant').click
|
page.find_by_id('suivant').click
|
||||||
visit root_path
|
visit root_path
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'After sign_in, I can navigate through dossiers indexes and edit a dossier' do
|
context 'After sign_in, I can navigate through dossiers indexes and edit a dossier' do
|
||||||
|
|
48
spec/features/users/dossier_index_spec.rb
Normal file
48
spec/features/users/dossier_index_spec.rb
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
feature 'As a User I want to sort and paginate dossiers', js: true do
|
||||||
|
|
||||||
|
let(:user) { create(:user) }
|
||||||
|
let(:procedure_for_individual) { create(:procedure, :published, :for_individual) }
|
||||||
|
|
||||||
|
before "Create dossier" do
|
||||||
|
login_as user, scope: :user
|
||||||
|
visit commencer_path(procedure_path: procedure_for_individual.path)
|
||||||
|
fill_in 'dossier_individual_attributes_nom', with: 'Nom'
|
||||||
|
fill_in 'dossier_individual_attributes_prenom', with: 'Prenom'
|
||||||
|
fill_in 'dossier_individual_attributes_birthdate', with: '14/10/1987'
|
||||||
|
find(:css, "#dossier_autorisation_donnees[value='1']").set(true)
|
||||||
|
page.find_by_id('etape_suivante').click
|
||||||
|
page.find_by_id('suivant').click
|
||||||
|
50.times do
|
||||||
|
Dossier.create(procedure_id: 1, user_id: 1, state: "initiated")
|
||||||
|
end
|
||||||
|
visit root_path
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'After sign_in, I can see my 51 dossiers on the index' do
|
||||||
|
|
||||||
|
scenario 'Using sort' do
|
||||||
|
expect(page.all(:css, '#dossiers_list tr')[1].text.split(" ").first).to eq('1')
|
||||||
|
expect(page.all(:css, '#dossiers_list tr')[2].text.split(" ").first).to eq('2')
|
||||||
|
visit "/users/dossiers?dossiers_smart_listing[sort][id]=desc"
|
||||||
|
expect(page.all(:css, '#dossiers_list tr')[1].text.split(" ").first).to eq('51')
|
||||||
|
expect(page.all(:css, '#dossiers_list tr')[2].text.split(" ").first).to eq('50')
|
||||||
|
visit "/users/dossiers?dossiers_smart_listing[sort][id]=asc"
|
||||||
|
expect(page.all(:css, '#dossiers_list tr')[1].text.split(" ").first).to eq('1')
|
||||||
|
expect(page.all(:css, '#dossiers_list tr')[2].text.split(" ").first).to eq('2')
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'Using pagination' do
|
||||||
|
expect(page.all(:css, '#dossiers_list tr')[1].text.split(" ").first).to eq('1')
|
||||||
|
page.find('.next_page a').click
|
||||||
|
wait_for_ajax
|
||||||
|
expect(page.all(:css, '#dossiers_list tr')[1].text.split(" ").first).to eq('8')
|
||||||
|
page.find('.next_page a').click
|
||||||
|
wait_for_ajax
|
||||||
|
expect(page.all(:css, '#dossiers_list tr')[1].text.split(" ").first).to eq('15')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
|
@ -20,6 +20,16 @@ describe CARTO::SGMAP::API do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when request return 500' do
|
||||||
|
let(:geojson) { File.read('spec/support/files/geojson/request_qp.json') }
|
||||||
|
let(:status) { 500 }
|
||||||
|
let(:body) { 'toto' }
|
||||||
|
|
||||||
|
it 'raises RestClient::ResourceNotFound' do
|
||||||
|
expect { subject }.to raise_error(RestClient::ResourceNotFound)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'when geojson exist' do
|
context 'when geojson exist' do
|
||||||
let(:geojson) { File.read('spec/support/files/geojson/request_qp.json') }
|
let(:geojson) { File.read('spec/support/files/geojson/request_qp.json') }
|
||||||
let(:status) { 200 }
|
let(:status) { 200 }
|
||||||
|
|
Loading…
Reference in a new issue