Merge branch 'develop' into staging

This commit is contained in:
Xavier J 2016-12-20 12:28:12 +01:00
commit 1f3d9316ee
7 changed files with 98 additions and 18 deletions

View file

@ -32,7 +32,8 @@ class Users::CarteController < UsersController
end
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'
lat = '46.538192'

View file

@ -21,6 +21,9 @@ class CARTO::SGMAP::API
url,
verify_ssl: verify_ssl_mode,
).post params[:geojson], content_type: 'application/json'
rescue RestClient::InternalServerError
raise RestClient::ResourceNotFound
end
def self.base_url

View file

@ -1,16 +1,16 @@
- unless smart_listing.empty?
%table#dossiers_list.table
%thead
%th.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.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-id.col-md-1.col-lg-1= smart_listing.sortable 'Numéro', 'id'
%th#sort-libelle.col-md-5.col-lg-5= smart_listing.sortable 'Procédure', 'procedure.libelle'
%th#sort-state.col-md-2.col-lg-2= smart_listing.sortable 'État', 'state'
%th#sort-updated.col-md-2.col-lg-2= smart_listing.sortable 'Date de mise à jour', 'updated_at'
- if @liste == "brouillon"
%th.col-md-2.col-lg-2= 'Action'
- @dossiers.each do |dossier|
- if dossier.kind_of? Invite
-invite = dossier
-dossier = invite.dossier.decorate
- invite = dossier
- dossier = invite.dossier.decorate
- else
- dossier = dossier.decorate

View file

@ -179,6 +179,24 @@ shared_examples 'carte_controller_spec' do
end
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
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) }

View file

@ -2,20 +2,20 @@ require 'spec_helper'
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) }
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('etape_suivante').click
page.find_by_id('suivant').click
visit root_path
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('etape_suivante').click
page.find_by_id('suivant').click
visit root_path
end
context 'After sign_in, I can navigate through dossiers indexes and edit a dossier' do

View 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

View file

@ -20,6 +20,16 @@ describe CARTO::SGMAP::API do
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
let(:geojson) { File.read('spec/support/files/geojson/request_qp.json') }
let(:status) { 200 }