From 91e937c247d1d861f7938382a08cb9c8a145466c Mon Sep 17 00:00:00 2001 From: Xavier J Date: Mon, 28 Sep 2015 18:55:16 +0200 Subject: [PATCH 1/2] activation page carte for procedure with db attribut use_api_carto is true --- app/assets/javascripts/api_carto/qp.js | 14 +-- app/assets/javascripts/carte.js | 2 +- .../{ => users}/carte_controller.rb | 7 +- app/controllers/users/dossiers_controller.rb | 7 +- .../carte/_carte_sources_CSS.html.haml | 0 .../carte/_carte_sources_JS.html.haml | 0 .../carte/_carte_sources_JS_backend.html.haml | 0 app/views/{ => users}/carte/show.html.haml | 9 +- config/routes.rb | 5 + ...28141512_add_use_api_carto_to_procedure.rb | 5 + db/schema.rb | 7 +- spec/controllers/carte_controller_spec.rb | 108 ------------------ .../users/carte_controller_spec.rb | 106 +++++++++++++++++ .../users/dossiers_controller_spec.rb | 26 ++++- spec/features/carte_page/show_page_spec.rb | 76 ------------ spec/views/users/carte/show.html.haml_spec.rb | 68 +++++++++++ 16 files changed, 232 insertions(+), 208 deletions(-) rename app/controllers/{ => users}/carte_controller.rb (89%) rename app/views/{ => users}/carte/_carte_sources_CSS.html.haml (100%) rename app/views/{ => users}/carte/_carte_sources_JS.html.haml (100%) rename app/views/{ => users}/carte/_carte_sources_JS_backend.html.haml (100%) rename app/views/{ => users}/carte/show.html.haml (68%) create mode 100644 db/migrate/20150928141512_add_use_api_carto_to_procedure.rb delete mode 100644 spec/controllers/carte_controller_spec.rb create mode 100644 spec/controllers/users/carte_controller_spec.rb delete mode 100644 spec/features/carte_page/show_page_spec.rb create mode 100644 spec/views/users/carte/show.html.haml_spec.rb diff --git a/app/assets/javascripts/api_carto/qp.js b/app/assets/javascripts/api_carto/qp.js index 18a953e59..71cdd94ae 100644 --- a/app/assets/javascripts/api_carto/qp.js +++ b/app/assets/javascripts/api_carto/qp.js @@ -155,13 +155,13 @@ function onDocumentReady() { if (typeof L != 'undefined' && typeof L.drawLocal ! } });**/ }); - map.spin(true); - $.ajax({ - url: 'http://apicarto.coremaps.com/zoneville/api/beta/qp/mapservice', - datatype: 'json', - jsonCallback: 'getJson', - success: loadGeoJson - }); + //map.spin(true); + //$.ajax({ + // url: 'http://apicarto.coremaps.com/zoneville/api/beta/qp/mapservice', + // datatype: 'json', + // jsonCallback: 'getJson', + // success: loadGeoJson + //}); window.geom_inter = {index: []}; function style(feature) { diff --git a/app/assets/javascripts/carte.js b/app/assets/javascripts/carte.js index a238bc0d1..0a4c0582c 100644 --- a/app/assets/javascripts/carte.js +++ b/app/assets/javascripts/carte.js @@ -4,7 +4,7 @@ function get_position(){ var position; $.ajax({ - url: '/dossiers/'+dossier_id+'/carte/position', + url: '/users/dossiers/'+dossier_id+'/carte/position', dataType: 'json', async: false }).done(function (data) { diff --git a/app/controllers/carte_controller.rb b/app/controllers/users/carte_controller.rb similarity index 89% rename from app/controllers/carte_controller.rb rename to app/controllers/users/carte_controller.rb index 2e11af799..67cd3498b 100644 --- a/app/controllers/carte_controller.rb +++ b/app/controllers/users/carte_controller.rb @@ -1,15 +1,16 @@ -class CarteController < ApplicationController +class Users::CarteController < ApplicationController include DossierConcern def show @dossier = current_dossier rescue ActiveRecord::RecordNotFound - redirect_to url_for(controller: :siret, action: :error_dossier) + redirect_to url_for(controller: :dossiers, action: :index) end def save_ref_api_carto dossier = current_dossier - if dossier.ref_dossier_carto.blank? + + if dossier.draft? dossier.update_attributes(ref_dossier_carto: params[:ref_dossier]) redirect_to url_for(controller: :description, action: :show, dossier_id: params[:dossier_id]) else diff --git a/app/controllers/users/dossiers_controller.rb b/app/controllers/users/dossiers_controller.rb index e664f5b0b..8d7ee0257 100644 --- a/app/controllers/users/dossiers_controller.rb +++ b/app/controllers/users/dossiers_controller.rb @@ -46,7 +46,12 @@ class Users::DossiersController < UsersController @dossier = Dossier.find(params[:id]) if checked_autorisation_donnees? @dossier.update_attributes(update_params) - redirect_to url_for(controller: :description, action: :show, dossier_id: @dossier.id) + + if @dossier.procedure.use_api_carto + redirect_to url_for(controller: :carte, action: :show, dossier_id: @dossier.id) + else + redirect_to url_for(controller: :description, action: :show, dossier_id: @dossier.id) + end else @etablissement = @dossier.etablissement @entreprise = @dossier.entreprise.decorate diff --git a/app/views/carte/_carte_sources_CSS.html.haml b/app/views/users/carte/_carte_sources_CSS.html.haml similarity index 100% rename from app/views/carte/_carte_sources_CSS.html.haml rename to app/views/users/carte/_carte_sources_CSS.html.haml diff --git a/app/views/carte/_carte_sources_JS.html.haml b/app/views/users/carte/_carte_sources_JS.html.haml similarity index 100% rename from app/views/carte/_carte_sources_JS.html.haml rename to app/views/users/carte/_carte_sources_JS.html.haml diff --git a/app/views/carte/_carte_sources_JS_backend.html.haml b/app/views/users/carte/_carte_sources_JS_backend.html.haml similarity index 100% rename from app/views/carte/_carte_sources_JS_backend.html.haml rename to app/views/users/carte/_carte_sources_JS_backend.html.haml diff --git a/app/views/carte/show.html.haml b/app/views/users/carte/show.html.haml similarity index 68% rename from app/views/carte/show.html.haml rename to app/views/users/carte/show.html.haml index ca0bd655e..d58cb94e5 100644 --- a/app/views/carte/show.html.haml +++ b/app/views/users/carte/show.html.haml @@ -7,14 +7,13 @@ .content #map_qp{style: 'height:600px; width: 100%;'} -= form_tag(url_for({controller: :carte, action: :save_ref_api_carto}), class: 'form-inline', method: 'POST') do += form_tag(url_for({controller: :carte, action: :save_ref_api_carto, dossier_id: @dossier.id}), class: 'form-inline', method: 'POST') do %br %input{type: 'hidden', value: '', name: 'ref_dossier', id: 'ref_dossier'} - %input{type: 'hidden', value: request.parameters[:back_url], name: 'back_url', id: 'back_url'} - -if request.parameters[:back_url] == 'recapitulatif' - =render partial: '/layouts/modifications_terminees' - -else + -if @dossier.draft? =render partial: '/layouts/etape_suivante' + -else + =render partial: '/layouts/modifications_terminees' =render partial: 'carte_sources_JS' \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index bcb55575a..fadcae263 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -24,6 +24,11 @@ Rails.application.routes.draw do get '/demande' => 'demandes#show' post '/demande' => 'demandes#update' post '/commentaire' => 'commentaires#create' + + get '/carte/position' => 'carte#get_position' + get '/carte' => 'carte#show' + post '/carte' => 'carte#save_ref_api_carto' + end resource :dossiers diff --git a/db/migrate/20150928141512_add_use_api_carto_to_procedure.rb b/db/migrate/20150928141512_add_use_api_carto_to_procedure.rb new file mode 100644 index 000000000..620d52ed2 --- /dev/null +++ b/db/migrate/20150928141512_add_use_api_carto_to_procedure.rb @@ -0,0 +1,5 @@ +class AddUseAPICartoToProcedure < ActiveRecord::Migration + def change + add_column :procedures, :use_api_carto, :boolean, :default => false + end +end diff --git a/db/schema.rb b/db/schema.rb index 7930f66c9..06d349ad1 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20150923101000) do +ActiveRecord::Schema.define(version: 20150928141512) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -118,9 +118,10 @@ ActiveRecord::Schema.define(version: 20150923101000) do t.string "organisation" t.string "direction" t.string "lien_demarche" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.boolean "test" + t.boolean "use_api_carto", default: false end create_table "types_de_piece_justificative", force: :cascade do |t| diff --git a/spec/controllers/carte_controller_spec.rb b/spec/controllers/carte_controller_spec.rb deleted file mode 100644 index d6c6c0397..000000000 --- a/spec/controllers/carte_controller_spec.rb +++ /dev/null @@ -1,108 +0,0 @@ -require 'spec_helper' - -RSpec.describe CarteController, type: :controller do - #NOT USED ACTUALY - - # let(:bad_adresse) { 'babouba' } - # - # let(:dossier) { create(:dossier) } - # let!(:entreprise) { create(:entreprise, dossier: dossier) } - # let!(:etablissement) { create(:etablissement, dossier: dossier) } - # let(:dossier_id) { dossier.id } - # let(:bad_dossier_id) { Dossier.count + 10 } - # let(:ref_dossier) { 'IATRQPQY' } - # let(:adresse) { etablissement.adresse } - # - # describe 'GET #show' do - # it 'returns http success' do - # get :show, dossier_id: dossier_id - # expect(response).to have_http_status(:success) - # end - # - # it 'redirection vers start si mauvais dossier ID' do - # get :show, dossier_id: bad_dossier_id - # expect(response).to redirect_to(controller: :start, action: :error_dossier) - # end - # end - # - # describe 'POST #save_ref_api_carto' do - # context 'Aucune localisation n\'a jamais été enregistrée' do - # it do - # post :save_ref_api_carto, dossier_id: dossier_id, ref_dossier: ref_dossier, back_url: '' - # expect(response).to redirect_to("/dossiers/#{dossier_id}/description") - # end - # end - # - # context 'En train de modifier la localisation' do - # let(:dossier) { create(:dossier, ref_dossier: ref_dossier) } - # before do - # post :save_ref_api_carto, dossier_id: dossier_id, ref_dossier: ref_dossier - # end - # - # context 'Enregistrement d\'un commentaire informant la modification' do - # subject { dossier.commentaires.last } - # - # it 'champs email' do - # expect(subject.email).to eq('Modification localisation') - # end - # - # it 'champs body' do - # expect(subject.body).to eq('La localisation de la demande a été modifiée. Merci de le prendre en compte.') - # end - # - # it 'champs dossier' do - # expect(subject.dossier.id).to eq(dossier_id) - # end - # end - # - # it 'Redirection vers la page récapitulatif' do - # expect(response).to redirect_to("/dossiers/#{dossier_id}/recapitulatif") - # end - # end - # end - # - # describe '#get_position' do - # context 'Geocodeur renvoie des positions nil' do - # let(:etablissement) { create(:etablissement, adresse: bad_adresse) } - # let(:dossier) { create(:dossier, etablissement: etablissement) } - # before do - # stub_request(:get, "http://api-adresse.data.gouv.fr/search?limit=1&q=#{bad_adresse}") - # .to_return(status: 200, body: '{"query": "babouba", "version": "draft", "licence": "ODbL 1.0", "features": [], "type": "FeatureCollection", "attribution": "BAN"}', headers: {}) - # get :get_position, dossier_id: dossier.id - # end - # - # subject { dossier.reload } - # - # it 'on enregistre des coordonnées lat et lon à 0' do - # expect(subject.position_lat).to eq('0') - # expect(subject.position_lon).to eq('0') - # end - # end - # - # context 'retour d\'un fichier JSON avec 3 attributs' do - # before do - # stub_request(:get, "http://api-adresse.data.gouv.fr/search?limit=1&q=#{adresse}") - # .to_return(status: 200, body: '{"query": "50 avenue des champs \u00e9lys\u00e9es Paris 75008", "version": "draft", "licence": "ODbL 1.0", "features": [{"geometry": {"coordinates": [2.306888, 48.870374], "type": "Point"}, "type": "Feature", "properties": {"city": "Paris", "label": "50 Avenue des Champs \u00c9lys\u00e9es 75008 Paris", "housenumber": "50", "id": "ADRNIVX_0000000270748251", "postcode": "75008", "name": "50 Avenue des Champs \u00c9lys\u00e9es", "citycode": "75108", "context": "75, \u00cele-de-France", "score": 0.9054545454545454, "type": "housenumber"}}], "type": "FeatureCollection", "attribution": "BAN"}', headers: {}) - # - # get :get_position, dossier_id: dossier_id - # end - # subject { JSON.parse(response.body) } - # - # it 'format JSON valide' do - # expect(response.content_type).to eq('application/json') - # end - # - # it 'latitude' do - # expect(subject['lat']).to eq('48.870374') - # end - # - # it 'longitude' do - # expect(subject['lon']).to eq('2.306888') - # end - # - # it 'dossier_id' do - # expect(subject['dossier_id']).to eq(dossier.id.to_s) - # end - # end - # end -end diff --git a/spec/controllers/users/carte_controller_spec.rb b/spec/controllers/users/carte_controller_spec.rb new file mode 100644 index 000000000..2f33a1666 --- /dev/null +++ b/spec/controllers/users/carte_controller_spec.rb @@ -0,0 +1,106 @@ +require 'spec_helper' + +RSpec.describe Users::CarteController, type: :controller do + let(:bad_adresse) { 'babouba' } + + let(:dossier) { create(:dossier, :with_user, :with_procedure) } + let!(:entreprise) { create(:entreprise, dossier: dossier) } + let!(:etablissement) { create(:etablissement, dossier: dossier) } + let(:dossier_id) { dossier.id } + let(:bad_dossier_id) { Dossier.count + 1000 } + let(:ref_dossier_carto) { 'IATRQPQY' } + let(:adresse) { etablissement.adresse } + + describe 'GET #show' do + it 'returns http success' do + get :show, dossier_id: dossier_id + expect(response).to have_http_status(:success) + end + + it 'redirection vers la liste des dossiers du user si dossier ID n\'existe pas' do + get :show, dossier_id: bad_dossier_id + expect(response).to redirect_to(controller: :dossiers, action: :index) + end + end + + describe 'POST #save_ref_api_carto' do + context 'Aucune localisation n\'a jamais été enregistrée' do + it do + post :save_ref_api_carto, dossier_id: dossier_id, ref_dossier_carto: ref_dossier_carto + expect(response).to redirect_to("/users/dossiers/#{dossier_id}/description") + end + end + + context 'En train de modifier la localisation' do + let(:dossier) { create(:dossier, :with_procedure, :with_user, ref_dossier_carto: ref_dossier_carto) } + before do + post :save_ref_api_carto, dossier_id: dossier_id, ref_dossier_carto: ref_dossier_carto + end + + context 'Enregistrement d\'un commentaire informant la modification' do + subject { dossier.commentaires.last } + + it 'champs email' do + expect(subject.email).to eq('Modification localisation') + end + + it 'champs body' do + expect(subject.body).to eq('La localisation de la demande a été modifiée. Merci de le prendre en compte.') + end + + it 'champs dossier' do + expect(subject.dossier.id).to eq(dossier_id) + end + end + + it 'Redirection vers la page récapitulatif' do + expect(response).to redirect_to("/users/dossiers/#{dossier_id}/recapitulatif") + end + end + end + + describe '#get_position' do + context 'Geocodeur renvoie des positions nil' do + let(:etablissement) { create(:etablissement, adresse: bad_adresse) } + let(:dossier) { create(:dossier, :with_procedure, :with_user, etablissement: etablissement) } + before do + stub_request(:get, "http://api-adresse.data.gouv.fr/search?limit=1&q=#{bad_adresse}") + .to_return(status: 200, body: '{"query": "babouba", "version": "draft", "licence": "ODbL 1.0", "features": [], "type": "FeatureCollection", "attribution": "BAN"}', headers: {}) + get :get_position, dossier_id: dossier.id + end + + subject { dossier.reload } + + it 'on enregistre des coordonnées lat et lon à 0' do + expect(subject.position_lat).to eq('0') + expect(subject.position_lon).to eq('0') + end + end + + context 'retour d\'un fichier JSON avec 3 attributs' do + before do + stub_request(:get, "http://api-adresse.data.gouv.fr/search?limit=1&q=#{adresse}") + .to_return(status: 200, body: '{"query": "50 avenue des champs \u00e9lys\u00e9es Paris 75008", "version": "draft", "licence": "ODbL 1.0", "features": [{"geometry": {"coordinates": [2.306888, 48.870374], "type": "Point"}, "type": "Feature", "properties": {"city": "Paris", "label": "50 Avenue des Champs \u00c9lys\u00e9es 75008 Paris", "housenumber": "50", "id": "ADRNIVX_0000000270748251", "postcode": "75008", "name": "50 Avenue des Champs \u00c9lys\u00e9es", "citycode": "75108", "context": "75, \u00cele-de-France", "score": 0.9054545454545454, "type": "housenumber"}}], "type": "FeatureCollection", "attribution": "BAN"}', headers: {}) + + get :get_position, dossier_id: dossier_id + end + subject { JSON.parse(response.body) } + + it 'format JSON valide' do + expect(response.content_type).to eq('application/json') + end + + it 'latitude' do + expect(subject['lat']).to eq('48.870374') + end + + it 'longitude' do + expect(subject['lon']).to eq('2.306888') + end + + it 'dossier_id' do + expect(subject['dossier_id']).to eq(dossier.id.to_s) + end + end + end +end diff --git a/spec/controllers/users/dossiers_controller_spec.rb b/spec/controllers/users/dossiers_controller_spec.rb index 8e17bfa7a..3a89611d3 100644 --- a/spec/controllers/users/dossiers_controller_spec.rb +++ b/spec/controllers/users/dossiers_controller_spec.rb @@ -16,8 +16,11 @@ describe Users::DossiersController, type: :controller do it { is_expected.to have_http_status(:success) } end end - let(:dossier) { create(:dossier, :with_entreprise, :with_procedure, user: user) } - let(:procedure) { create(:procedure) } + + + let(:use_api_carto) { false } + let(:procedure) { create(:procedure, use_api_carto: use_api_carto) } + let(:dossier) { create(:dossier, :with_entreprise, user: user, procedure: procedure) } let(:dossier_id) { dossier.id } let(:siret_not_found) { 999_999_999_999 } @@ -132,8 +135,23 @@ describe Users::DossiersController, type: :controller do end context 'when Checkbox is checked' do let(:autorisation_donnees) { '1' } - it 'redirects to demande' do - expect(response).to redirect_to(controller: :description, action: :show, dossier_id: dossier.id) + + context 'procedure not use api carto' do + it 'redirects to demande' do + expect(response).to redirect_to(controller: :description, action: :show, dossier_id: dossier.id) + end + end + + context 'procedure use api carto' do + let(:use_api_carto) { true } + + before do + put :update, id: dossier_id, dossier: { autorisation_donnees: autorisation_donnees } + p dossier.procedure.use_api_carto + end + it 'redirects to carte' do + expect(response).to redirect_to(controller: :carte, action: :show, dossier_id: dossier.id) + end end it 'update dossier' do diff --git a/spec/features/carte_page/show_page_spec.rb b/spec/features/carte_page/show_page_spec.rb deleted file mode 100644 index 587a2184b..000000000 --- a/spec/features/carte_page/show_page_spec.rb +++ /dev/null @@ -1,76 +0,0 @@ -require 'spec_helper' - -feature 'Carte#Show Page' do - #NOT USED ACTUALY - - # let(:dossier) { create(:dossier) } - # let(:dossier_id) { dossier.id } - # - # before do - # visit "/dossiers/#{dossier_id}/carte" - # end - # - # context 'sur la page de la carte d\'une demande' do - # scenario 'le formulaire envoie vers /dossiers/:dossier_id/carte en #POST' do - # expect(page).to have_selector("form[action='/dossiers/#{dossier_id}/carte'][method=post]") - # end - # - # scenario 'la page des sources CSS de l\'API carto est chargée' do - # expect(page).to have_selector('#sources_CSS_api_carto') - # end - # - # scenario 'la page des sources JS de l\'API carto est chargée' do - # expect(page).to have_selector('#sources_JS_api_carto') - # end - # - # scenario 'la carte est bien présente' do - # expect(page).to have_selector('#map_qp') - # end - # - # context 'présence des inputs hidden' do - # scenario 'stockage de la référence du dossie de l\'API carto' do - # expect(page).to have_selector('input[type=hidden][id=ref_dossier][name=ref_dossier]') - # end - # - # scenario 'stockage de l\'URL back si elle existe' do - # expect(page).to have_selector('input[type=hidden][id=back_url][name=back_url]') - # end - # end - # - # context 'si la page précédente n\'est pas recapitulatif' do - # scenario 'le bouton "Etape suivante" est présent' do - # expect(page).to have_selector('#etape_suivante') - # end - # - # scenario 'le bouton Etape suivante possède un onclick correct' do - # expect(page).to have_selector('input[type=submit][id=etape_suivante][onclick=\'submit_check_draw(event)\']') - # end - # end - # - # context 'si la page précédente est recapitularif' do - # before do - # visit "/dossiers/#{dossier_id}/carte?back_url=recapitulatif" - # end - # - # scenario 'le bouton "Etape suivante" n\'est pas présent' do - # expect(page).to_not have_selector('#etape_suivante') - # end - # - # scenario 'input hidden back_url a pour valeur le params GET' do - # expect(page).to have_selector('input[type=hidden][id=back_url][value=recapitulatif]') - # end - # - # scenario 'le bouton "Modification terminé" est présent' do - # expect(page).to have_selector('#modification_terminee') - # end - # - # scenario 'le bouton Etape suivante possède un onclick correct' do - # expect(page).to have_selector('input[type=submit][id=modification_terminee][onclick=\'submit_check_draw(event)\']') - # end - # - # scenario 'le lien de retour au récapitulatif est présent' do - # expect(page).to have_selector("a[href='/dossiers/#{dossier_id}/recapitulatif']") - # end - # end - # end -end diff --git a/spec/views/users/carte/show.html.haml_spec.rb b/spec/views/users/carte/show.html.haml_spec.rb new file mode 100644 index 000000000..b1d68bb6d --- /dev/null +++ b/spec/views/users/carte/show.html.haml_spec.rb @@ -0,0 +1,68 @@ +require 'spec_helper' + +describe 'users/carte/show.html.haml', type: :view do + let(:state) { 'draft' } + let(:dossier) { create(:dossier, :with_procedure, :with_user, state: state) } + let(:dossier_id) { dossier.id } + + before do + assign(:dossier, dossier) + end + + context 'sur la page de la carte d\'une demande' do + before do + render + end + it 'le formulaire envoie vers /users/dossiers/:dossier_id/carte en #POST' do + expect(rendered).to have_selector("form[action='/users/dossiers/#{dossier_id}/carte'][method=post]") + end + + it 'la page des sources CSS de l\'API carto est chargée' do + expect(rendered).to have_selector('#sources_CSS_api_carto') + end + + it 'la page des sources JS de l\'API carto est chargée' do + expect(rendered).to have_selector('#sources_JS_api_carto') + end + + it 'la carte est bien présente' do + expect(rendered).to have_selector('#map_qp') + end + + context 'présence des inputs hidden' do + it 'stockage de la référence du dossie de l\'API carto' do + expect(rendered).to have_selector('input[type=hidden][id=ref_dossier][name=ref_dossier]') + end + end + + context 'si la page précédente n\'est pas recapitulatif' do + it 'le bouton "Etape suivante" est présent' do + expect(rendered).to have_selector('#etape_suivante') + end + + it 'le bouton Etape suivante possède un onclick correct' do + expect(rendered).to have_selector('input[type=submit][id=etape_suivante][onclick=\'submit_check_draw(event)\']') + end + end + + context 'si la page précédente est recapitularif' do + let(:state) { 'proposed' } + + it 'le bouton "Etape suivante" n\'est pas présent' do + expect(rendered).to_not have_selector('#etape_suivante') + end + + it 'le bouton "Modification terminé" est présent' do + expect(rendered).to have_selector('#modification_terminee') + end + + it 'le bouton "Modification terminé" possède un onclick correct' do + expect(rendered).to have_selector('input[type=submit][id=modification_terminee][onclick=\'submit_check_draw(event)\']') + end + + it 'le lien de retour au récapitulatif est présent' do + expect(rendered).to have_selector("a[href='/users/dossiers/#{dossier_id}/recapitulatif']") + end + end + end +end From 0c2d1d70ffb25401b635d6d0c8f592566c6ab0a1 Mon Sep 17 00:00:00 2001 From: Xavier J Date: Mon, 28 Sep 2015 18:58:10 +0200 Subject: [PATCH 2/2] fix bug test --- spec/controllers/users/carte_controller_spec.rb | 2 +- spec/controllers/users/dossiers_controller_spec.rb | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/spec/controllers/users/carte_controller_spec.rb b/spec/controllers/users/carte_controller_spec.rb index 2f33a1666..fa1241243 100644 --- a/spec/controllers/users/carte_controller_spec.rb +++ b/spec/controllers/users/carte_controller_spec.rb @@ -32,7 +32,7 @@ RSpec.describe Users::CarteController, type: :controller do end context 'En train de modifier la localisation' do - let(:dossier) { create(:dossier, :with_procedure, :with_user, ref_dossier_carto: ref_dossier_carto) } + let(:dossier) { create(:dossier, :with_procedure, :with_user, ref_dossier_carto: ref_dossier_carto, state: 'proposed') } before do post :save_ref_api_carto, dossier_id: dossier_id, ref_dossier_carto: ref_dossier_carto end diff --git a/spec/controllers/users/dossiers_controller_spec.rb b/spec/controllers/users/dossiers_controller_spec.rb index 3a89611d3..e12cb342a 100644 --- a/spec/controllers/users/dossiers_controller_spec.rb +++ b/spec/controllers/users/dossiers_controller_spec.rb @@ -147,7 +147,6 @@ describe Users::DossiersController, type: :controller do before do put :update, id: dossier_id, dossier: { autorisation_donnees: autorisation_donnees } - p dossier.procedure.use_api_carto end it 'redirects to carte' do expect(response).to redirect_to(controller: :carte, action: :show, dossier_id: dossier.id)