diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 83ab972b9..afcbf7916 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -22,4 +22,22 @@ class ApplicationController < ActionController::Base @left_pannel_url = service.left_panel @facade_data_view = nil end + + protected + + def authenticate_gestionnaire! + if gestionnaire_signed_in? + super + else + redirect_to new_user_session_path + end + end + + def authenticate_administrateur! + if administrateur_signed_in? + super + else + redirect_to new_user_session_path + end + end end diff --git a/app/controllers/users/description_controller.rb b/app/controllers/users/description_controller.rb index 215973c72..4dcd7f287 100644 --- a/app/controllers/users/description_controller.rb +++ b/app/controllers/users/description_controller.rb @@ -122,7 +122,7 @@ class Users::DescriptionController < UsersController private def check_autorisation_donnees - @dossier ||= current_user_dossier + @dossier = current_user_dossier redirect_to url_for(users_dossier_path(@dossier.id)) if @dossier.autorisation_donnees.nil? || !@dossier.autorisation_donnees end diff --git a/app/views/users/sessions/new.html.haml b/app/views/users/sessions/new.html.haml index 7d22b6700..f7ece8315 100644 --- a/app/views/users/sessions/new.html.haml +++ b/app/views/users/sessions/new.html.haml @@ -1,4 +1,4 @@ -#form_login +#form_login.user_connexion_page %br = render partial: 'users/sessions/resume_procedure' diff --git a/spec/controllers/admin/procedures_controller_spec.rb b/spec/controllers/admin/procedures_controller_spec.rb index 0ccbbbdb1..7d3379723 100644 --- a/spec/controllers/admin/procedures_controller_spec.rb +++ b/spec/controllers/admin/procedures_controller_spec.rb @@ -105,7 +105,7 @@ describe Admin::ProceduresController, type: :controller do sign_out admin end - it { expect(subject).to redirect_to new_administrateur_session_path } + it { expect(subject).to redirect_to new_user_session_path } end context 'when user is connected' do @@ -204,7 +204,7 @@ describe Admin::ProceduresController, type: :controller do subject { put :update, params: {id: procedure.id} } - it { expect(subject).to redirect_to new_administrateur_session_path } + it { expect(subject).to redirect_to new_user_session_path } end context 'when administrateur is connected' do diff --git a/spec/controllers/administrateur/sessions_controller_spec.rb b/spec/controllers/administrateur/sessions_controller_spec.rb index a4717fca7..2499e2e0e 100644 --- a/spec/controllers/administrateur/sessions_controller_spec.rb +++ b/spec/controllers/administrateur/sessions_controller_spec.rb @@ -20,7 +20,7 @@ describe Administrateurs::SessionsController, type: :controller do it { expect(subject.status).to eq 200 } it 'Administrateur demo is initiated' do - expect(Administrateur).to receive(:new).with(email: 'admin@tps.fr', password: 'password').and_return(Administrateur) + expect(User).to receive(:new).with(email: 'admin@tps.fr', password: 'password').and_return(Administrateur) subject end end diff --git a/spec/controllers/backoffice/dossiers_controller_spec.rb b/spec/controllers/backoffice/dossiers_controller_spec.rb index 96e838d19..c1529378d 100644 --- a/spec/controllers/backoffice/dossiers_controller_spec.rb +++ b/spec/controllers/backoffice/dossiers_controller_spec.rb @@ -72,7 +72,7 @@ describe Backoffice::DossiersController, type: :controller do end context 'gestionnaire does not connected but dossier id is correct' do - it { is_expected.to redirect_to('/gestionnaires/sign_in') } + it { is_expected.to redirect_to('/users/sign_in') } end end diff --git a/spec/controllers/gestionnaires/sessions_controller_spec.rb b/spec/controllers/gestionnaires/sessions_controller_spec.rb index c01483e41..ff30e6cb7 100644 --- a/spec/controllers/gestionnaires/sessions_controller_spec.rb +++ b/spec/controllers/gestionnaires/sessions_controller_spec.rb @@ -20,7 +20,7 @@ describe Gestionnaires::SessionsController, type: :controller do it { expect(subject.status).to eq 200 } it 'Gestionnaire demo is initiated' do - expect(Gestionnaire).to receive(:new).with(email: 'gestionnaire@apientreprise.fr', password: 'password').and_return(Gestionnaire) + expect(User).to receive(:new).with(email: 'gestionnaire@apientreprise.fr', password: 'password').and_return(Gestionnaire) subject end end diff --git a/spec/factories/dossier.rb b/spec/factories/dossier.rb index 2a98f2a0b..aa619d795 100644 --- a/spec/factories/dossier.rb +++ b/spec/factories/dossier.rb @@ -19,6 +19,13 @@ FactoryGirl.define do end end + trait :for_individual do + after(:build) do |dossier, _evaluator| + dossier.individual = create :individual + dossier.save + end + end + trait :with_two_quartier_prioritaires do after(:build) do |dossier, _evaluator| dossier.quartier_prioritaires << create(:quartier_prioritaire) diff --git a/spec/factories/individual.rb b/spec/factories/individual.rb new file mode 100644 index 000000000..c5924d57c --- /dev/null +++ b/spec/factories/individual.rb @@ -0,0 +1,7 @@ +FactoryGirl.define do + factory :individual do + nom 'Julien' + prenom 'Xavier' + birthdate '20/01/1991' + end +end diff --git a/spec/features/admin/connection_spec.rb b/spec/features/admin/connection_spec.rb index 0511521da..58b256be7 100644 --- a/spec/features/admin/connection_spec.rb +++ b/spec/features/admin/connection_spec.rb @@ -6,13 +6,13 @@ feature 'Administrator connection' do visit new_administrateur_session_path end scenario 'administrator is on admin loggin page' do - expect(page).to have_css('#login_admin') + expect(page).to have_css('#form_login.user_connexion_page') end context "admin fills form and log in" do before do - page.find_by_id('administrateur_email').set admin.email - page.find_by_id('administrateur_password').set admin.password + page.find_by_id('user_email').set admin.email + page.find_by_id('user_password').set admin.password page.click_on 'Se connecter' end scenario 'a menu button is available' do diff --git a/spec/features/admin/procedure_creation_spec.rb b/spec/features/admin/procedure_creation_spec.rb index 61f538018..a8d06e8af 100644 --- a/spec/features/admin/procedure_creation_spec.rb +++ b/spec/features/admin/procedure_creation_spec.rb @@ -83,13 +83,13 @@ feature 'As an administrateur I wanna create a new procedure', js: true do expect(page).to have_current_path(admin_procedure_path(Procedure.first.id.to_s)) expect(page.find_by_id('publish-procedure')['disabled']).to eq('disabled') - page.find_by_id('onglet-accompagnateurs').click + page.find_by_id('onglet-accompagnateurs').trigger('click') expect(page).to have_current_path(admin_procedure_accompagnateurs_path(Procedure.first.id.to_s)) page.find_by_id('gestionnaire_email').set 'gestionnaire@apientreprise.fr' page.find_by_id('add-gestionnaire-email').click page.first('.gestionnaire-affectation').click - page.find_by_id('onglet-infos').click + page.find_by_id('onglet-infos').trigger('click') expect(page).to have_selector('#publish-procedure', visible: true) page.find_by_id('publish-procedure').click diff --git a/spec/features/backoffice/connection_spec.rb b/spec/features/backoffice/connection_spec.rb index c428b965b..419e14853 100644 --- a/spec/features/backoffice/connection_spec.rb +++ b/spec/features/backoffice/connection_spec.rb @@ -7,16 +7,16 @@ feature 'when gestionnaire come to /backoffice and is not authenticated' do visit backoffice_path end scenario 'he is redirected to /gestionnaires/sign_id' do - expect(page).to have_css('#gestionnaire_login') + expect(page).to have_css('#user_email') end context 'when user enter bad credentials' do before do - page.find_by_id(:gestionnaire_email).set 'unknown@plop.com' - page.find_by_id(:gestionnaire_password).set 'password' + page.find_by_id(:user_email).set 'unknown@plop.com' + page.find_by_id(:user_password).set 'password' page.click_on 'Se connecter' end scenario 'he stay on the same page with an error' do - expect(page).to have_content('Email ou mot de passe incorrect.') + expect(page).to have_content('Mauvais couple login / mot de passe') end end context 'when user enter good credentials' do @@ -25,8 +25,8 @@ feature 'when gestionnaire come to /backoffice and is not authenticated' do before do create :assign_to, gestionnaire: gestionnaire, procedure: procedure - page.find_by_id(:gestionnaire_email).set gestionnaire.email - page.find_by_id(:gestionnaire_password).set gestionnaire.password + page.find_by_id(:user_email).set gestionnaire.email + page.find_by_id(:user_password).set gestionnaire.password page.click_on 'Se connecter' end scenario 'he is redirected to /backoffice' do diff --git a/spec/features/backoffice/index_show_procedure_spec.rb b/spec/features/backoffice/index_show_procedure_spec.rb index 1e8a0ec14..b59fdbe46 100644 --- a/spec/features/backoffice/index_show_procedure_spec.rb +++ b/spec/features/backoffice/index_show_procedure_spec.rb @@ -10,10 +10,10 @@ feature 'As an Accompagnateur I can navigate and use each functionnality around before 'Assign procedures to Accompagnateur and generating dossiers for each' do create :assign_to, gestionnaire: gestionnaire, procedure: procedure_1 create :assign_to, gestionnaire: gestionnaire, procedure: procedure_2 - 20.times do + 30.times do Dossier.create(procedure_id: procedure_1.id.to_s, user: user, state: 'validated') end - 15.times do + 22.times do Dossier.create(procedure_id: procedure_2.id.to_s, user: user, state: 'validated') end login_as gestionnaire, scope: :gestionnaire @@ -25,10 +25,10 @@ feature 'As an Accompagnateur I can navigate and use each functionnality around scenario 'Switching between procedures' do page.all('#procedure_list a').first.trigger('click') expect(page).to have_current_path(backoffice_dossiers_procedure_path(id: procedure_1.id.to_s), only_path: true) - expect(page.find('#all_dossiers .count').text).to eq('20 dossiers') + expect(page.find('#all_dossiers .count').text).to eq('30 dossiers') page.all('#procedure_list a').last.trigger('click') expect(page).to have_current_path(backoffice_dossiers_procedure_path(id: procedure_2.id.to_s), only_path: true) - expect(page.find('#all_dossiers .count').text).to eq('15 dossiers') + expect(page.find('#all_dossiers .count').text).to eq('22 dossiers') end scenario 'Searching with search bar' do @@ -54,15 +54,15 @@ feature 'As an Accompagnateur I can navigate and use each functionnality around expect(page.all("#all_state_dossiers .dossier-row")[0]['id']).to eq('tr_dossier_1') visit "/backoffice/dossiers/procedure/1?all_state_dossiers_smart_listing[sort][id]=desc" wait_for_ajax - expect(page.all(".dossier-row")[0]['id']).to eq('tr_dossier_20') + expect(page.all(".dossier-row")[0]['id']).to eq('tr_dossier_30') page.find('#all_state_dossiers .next_page a').trigger('click') wait_for_ajax page.find('#all_state_dossiers .next_page a').trigger('click') wait_for_ajax - expect(page.all(".dossier-row")[0]['id']).to eq('tr_dossier_6') + expect(page.all(".dossier-row")[0]['id']).to eq('tr_dossier_10') page.find('#all_state_dossiers .prev a').trigger('click') wait_for_ajax - expect(page.all(".dossier-row")[0]['id']).to eq('tr_dossier_13') + expect(page.all(".dossier-row")[0]['id']).to eq('tr_dossier_20') end scenario 'Using filter' do diff --git a/spec/features/backoffice/lateral_page_pref_list_dossier_backoffice_spec.rb b/spec/features/backoffice/lateral_page_pref_list_dossier_backoffice_spec.rb index 8b75df35e..fe4ce332d 100644 --- a/spec/features/backoffice/lateral_page_pref_list_dossier_backoffice_spec.rb +++ b/spec/features/backoffice/lateral_page_pref_list_dossier_backoffice_spec.rb @@ -9,20 +9,13 @@ feature 'usage of pref list dossier lateral panel', js: true do before do create(:dossier, :with_entreprise, procedure: procedure, state: 'updated') create :assign_to, procedure: procedure, gestionnaire: gestionnaire + + login_as gestionnaire, scope: :gestionnaire + visit backoffice_path end - scenario 'he is redirected to /gestionnaires/sign_id' do - expect(page).to have_css('#gestionnaire_login') - end - context 'when user enter good credentials' do - before do - page.find_by_id(:gestionnaire_email).set gestionnaire.email - page.find_by_id(:gestionnaire_password).set gestionnaire.password - page.click_on 'Se connecter' - end - scenario 'he is redirected to /backoffice' do expect(page).to have_css('#backoffice_index') end diff --git a/spec/features/backoffice/lateral_page_pref_list_dossier_by_procedure_backoffice_spec.rb b/spec/features/backoffice/lateral_page_pref_list_dossier_by_procedure_backoffice_spec.rb index a86eb9612..404c20ea2 100644 --- a/spec/features/backoffice/lateral_page_pref_list_dossier_by_procedure_backoffice_spec.rb +++ b/spec/features/backoffice/lateral_page_pref_list_dossier_by_procedure_backoffice_spec.rb @@ -9,20 +9,13 @@ feature 'usage of pref list dossier lateral panel by procedure', js: true do before do create(:dossier, :with_entreprise, procedure: procedure, state: 'updated') create :assign_to, procedure: procedure, gestionnaire: gestionnaire + + login_as gestionnaire, scope: :gestionnaire + visit backoffice_path end - scenario 'he is redirected to /gestionnaires/sign_id' do - expect(page).to have_css('#gestionnaire_login') - end - context 'when user enter good credentials' do - before do - page.find_by_id(:gestionnaire_email).set gestionnaire.email - page.find_by_id(:gestionnaire_password).set gestionnaire.password - page.click_on 'Se connecter' - end - scenario 'he is redirected to /backoffice/dossiers/' do expect(page).to have_css('#backoffice_index') end diff --git a/spec/features/backoffice/navigate_to_dossier_spec.rb b/spec/features/backoffice/navigate_to_dossier_spec.rb index 3cb14cbf6..b73a1217d 100644 --- a/spec/features/backoffice/navigate_to_dossier_spec.rb +++ b/spec/features/backoffice/navigate_to_dossier_spec.rb @@ -1,27 +1,29 @@ require 'spec_helper' -feature 'on backoffice page' do +feature 'on backoffice page', js: true do let(:administrateur) { create(:administrateur) } let(:gestionnaire) { create(:gestionnaire, administrateurs: [administrateur]) } let(:procedure) { create(:procedure, administrateur: administrateur) } + let(:procedure_individual) { create :procedure, libelle: 'procedure individual', administrateur: administrateur, for_individual: true } let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'updated') } + let!(:dossier_individual) { create :dossier, procedure: procedure_individual, state: 'updated' } before do create :assign_to, gestionnaire: gestionnaire, procedure: procedure create :follow, gestionnaire: gestionnaire, dossier: dossier - + create :assign_to, gestionnaire: gestionnaire, procedure: procedure_individual + create :follow, gestionnaire: gestionnaire, dossier: dossier_individual visit backoffice_path end context 'when gestionnaire is logged in' do before do - page.find_by_id(:gestionnaire_email).set gestionnaire.email - page.find_by_id(:gestionnaire_password).set gestionnaire.password - + page.find_by_id(:user_email).set gestionnaire.email + page.find_by_id(:user_password).set gestionnaire.password page.click_on 'Se connecter' end - context 'when he click on first dossier', js: true do + context 'when he click on first dossier' do before do page.find("#tr_dossier_#{dossier.id}", visible: true).click end @@ -30,22 +32,20 @@ feature 'on backoffice page' do expect(page).to have_css('#backoffice_dossier_show') end end + end - context 'when gestionnaire have enterprise and individual dossier in his inbox', js: true do - let!(:procedure_individual) { create :procedure, libelle: 'procedure individual', administrateur: administrateur, for_individual: true } - let!(:dossier_individual) { create :dossier, procedure: procedure_individual, state: 'updated' } + context 'when gestionnaire have enterprise and individual dossier in his inbox', js: true do + before do + page.find_by_id(:user_email).set gestionnaire.email + page.find_by_id(:user_password).set gestionnaire.password + page.click_on 'Se connecter' - before do - create :assign_to, gestionnaire: gestionnaire, procedure: procedure_individual - create :follow, gestionnaire: gestionnaire, dossier: dossier_individual + visit backoffice_dossiers_procedure_path(id: procedure_individual.id) + page.find("#tr_dossier_#{dossier_individual.id}", visible: true).click + end - visit backoffice_dossiers_procedure_path(id: procedure_individual.id) - page.find("#tr_dossier_#{dossier_individual.id}", visible: true).click - end - - scenario 'it redirect to dossier page' do - expect(page).to have_css('#backoffice_dossier_show') - end + scenario 'it redirect to dossier page' do + expect(page).to have_css('#backoffice_dossier_show') end end end diff --git a/spec/features/users/dossier_edition_spec.rb b/spec/features/users/dossier_edition_spec.rb index 27ee4c077..85cbc97b6 100644 --- a/spec/features/users/dossier_edition_spec.rb +++ b/spec/features/users/dossier_edition_spec.rb @@ -1,20 +1,13 @@ 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' do 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_type_de_champ, :with_two_type_de_piece_justificative) } + let!(:dossier) { create(:dossier, :with_entreprise, :for_individual, procedure: procedure_for_individual, user: user, autorisation_donnees: true, state: 'initiated') } - before "Create dossier" do + before "Create dossier and visit root path" 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').trigger('click') - page.find_by_id('etape_suivante').trigger('click') - page.find_by_id('suivant').trigger('click') visit root_path end @@ -22,30 +15,31 @@ feature 'As a User I want to edit a dossier I own', js: true do scenario 'After sign_in, I can see dossiers "à traiter" (default), and other indexes' do expect(page.find('#a_traiter')['class'] ).to eq('active procedure_list_element') - page.find_by_id('brouillon').trigger('click') - page.find_by_id('a_traiter').trigger('click') - page.find_by_id('valides').trigger('click') - page.find_by_id('en_instruction').trigger('click') - page.find_by_id('termine').trigger('click') - page.find_by_id('invite').trigger('click') + page.find_by_id('brouillon').click + page.find_by_id('a_traiter').click + page.find_by_id('valides').click + page.find_by_id('en_instruction').click + page.find_by_id('termine').click + page.find_by_id('invite').click end - scenario 'Getting a dossier, I want to create a new message on' do - page.find_by_id('tr_dossier_' + Dossier.last.id.to_s).trigger('click') + scenario 'Getting a dossier, I want to create a new message on', js: true do + page.find_by_id('tr_dossier_' + Dossier.last.id.to_s).click expect(page).to have_current_path(users_dossier_recapitulatif_path(Dossier.first.id.to_s), only_path: true) - page.find_by_id('open-message').trigger('click') + page.find_by_id('open-message').click page.execute_script("$('#texte_commentaire').data('wysihtml5').editor.setValue('Contenu du nouveau message')") - page.find_by_id('save-message').trigger('click') + page.find_by_id('save-message').click expect(page.find('.last-commentaire .content').text).to eq('Contenu du nouveau message') end - scenario 'On the same dossier, I want to edit informations' do - page.find_by_id('tr_dossier_' + Dossier.last.id.to_s).trigger('click') - page.find_by_id('edit-dossier').trigger('click') - expect(page).to have_current_path(users_dossier_description_path(Dossier.first.id.to_s), only_path: true) - fill_in 'champs_1', with: 'Contenu du champ 1' - page.find_by_id('modification_terminee').trigger('click') - expect(page).to have_current_path(users_dossier_recapitulatif_path(Dossier.first.id.to_s), only_path: true) + scenario 'On the same dossier, I want to edit informations', js: true do + page.find_by_id('tr_dossier_' + dossier.id.to_s).click + expect(page).to have_current_path(users_dossier_recapitulatif_path(dossier.id.to_s), only_path: true) + page.find_by_id('maj_infos').trigger('click') + expect(page).to have_current_path(users_dossier_description_path(dossier.id.to_s), only_path: true) + fill_in "champs_#{dossier.champs.first.id.to_s}", with: 'Contenu du champ 1' + page.find_by_id('modification_terminee').click + expect(page).to have_current_path(users_dossier_recapitulatif_path(dossier.id.to_s), only_path: true) expect(page.find('#champ-1-value').text).to eq('Contenu du champ 1') end end diff --git a/spec/features/users/dossier_index_spec.rb b/spec/features/users/dossier_index_spec.rb index 98dba283e..a2b649693 100644 --- a/spec/features/users/dossier_index_spec.rb +++ b/spec/features/users/dossier_index_spec.rb @@ -23,7 +23,8 @@ feature 'As a User I want to sort and paginate dossiers', js: true do 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')[0].text.split(" ").first).to eq('1') + 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') visit "/users/dossiers?dossiers_smart_listing[sort][id]=desc" expect(page.all(:css, '#dossiers_list tr')[1].text.split(" ").first).to eq('51') @@ -34,13 +35,14 @@ feature 'As a User I want to sort and paginate dossiers', js: true do end scenario 'Using pagination' do - expect(page.all(:css, '#dossiers_list tr')[0].text.split(" ").first).to eq('1') + visit "/users/dossiers?dossiers_smart_listing[sort][id]=asc" + expect(page.all(:css, '#dossiers_list tr')[1].text.split(" ").first).to eq('1') page.find('.next_page a').trigger('click') wait_for_ajax - expect(page.all(:css, '#dossiers_list tr')[1].text.split(" ").first).to eq('8') + expect(page.all(:css, '#dossiers_list tr')[1].text.split(" ").first).to eq('11') page.find('.next_page a').trigger('click') wait_for_ajax - expect(page.all(:css, '#dossiers_list tr')[1].text.split(" ").first).to eq('15') + expect(page.all(:css, '#dossiers_list tr')[1].text.split(" ").first).to eq('21') page.find('.prev a').trigger('click') wait_for_ajax page.find('.prev a').trigger('click') diff --git a/spec/fixtures/cassettes/search_ban_paris.yml b/spec/fixtures/cassettes/search_ban_paris.yml index e0f65331e..b13b545b5 100644 --- a/spec/fixtures/cassettes/search_ban_paris.yml +++ b/spec/fixtures/cassettes/search_ban_paris.yml @@ -21,7 +21,7 @@ http_interactions: Server: - nginx/1.11.3 Date: - - Tue, 20 Dec 2016 11:36:58 GMT + - Tue, 03 Jan 2017 13:00:54 GMT Content-Type: - application/json; charset=utf-8 Content-Length: @@ -44,5 +44,50 @@ http_interactions: "housenumber": "50", "street": "Avenue des Champs \u00c9lys\u00e9es"}, "type": "Feature"}]}' http_version: - recorded_at: Tue, 20 Dec 2016 11:36:58 GMT + recorded_at: Tue, 03 Jan 2017 13:00:54 GMT +- request: + method: get + uri: http://api-adresse.data.gouv.fr/search?limit=1&q=50%20AV%20DES%20CHAMPS%20ELYSEES%20complement_adresse%2075008%20PARIS%208 + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - "*/*" + Accept-Encoding: + - gzip, deflate + User-Agent: + - rest-client/2.0.0 (darwin15.6.0 x86_64) ruby/2.3.1p112 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/1.11.3 + Date: + - Tue, 03 Jan 2017 13:00:55 GMT + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '660' + Connection: + - keep-alive + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Headers: + - X-Requested-With + body: + encoding: UTF-8 + string: '{"limit": 1, "attribution": "BAN", "version": "draft", "licence": "ODbL + 1.0", "query": "50 AV DES CHAMPS ELYSEES complement_adresse 75008 PARIS 8", + "type": "FeatureCollection", "features": [{"geometry": {"type": "Point", "coordinates": + [2.306888, 48.870374]}, "properties": {"citycode": "75108", "postcode": "75008", + "name": "50 Avenue des Champs \u00c9lys\u00e9es", "id": "ADRNIVX_0000000270748251", + "type": "housenumber", "context": "75, \u00cele-de-France", "score": 0.596517719568567, + "label": "50 Avenue des Champs \u00c9lys\u00e9es 75008 Paris", "city": "Paris", + "housenumber": "50", "street": "Avenue des Champs \u00c9lys\u00e9es"}, "type": + "Feature"}]}' + http_version: + recorded_at: Tue, 03 Jan 2017 13:00:55 GMT recorded_with: VCR 3.0.3 diff --git a/spec/lib/github/api_spec.rb b/spec/lib/github/api_spec.rb deleted file mode 100644 index f605391cc..000000000 --- a/spec/lib/github/api_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -require 'spec_helper' - -describe Github::API do - - describe '.base_uri' do - it { expect(described_class.base_uri).to eq 'https://api.github.com' } - end - - describe '.latest_release' do - subject { described_class.latest_release } - - context 'when github is up', vcr: {cassette_name: 'github_lastrelease'} do - it { expect(subject).to be_a RestClient::Response } - it { expect(subject.code).to eq 200 } - end - - context 'when github is down' do - - before do - allow_any_instance_of(RestClient::Resource).to receive(:get).and_raise(RestClient::Forbidden) - end - - it { is_expected.to be_nil } - end - end -end \ No newline at end of file diff --git a/spec/lib/github/releases_spec.rb b/spec/lib/github/releases_spec.rb deleted file mode 100644 index 41bcfc049..000000000 --- a/spec/lib/github/releases_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'spec_helper' - -describe Github::Releases do - - describe '.latest' do - - subject { described_class.latest } - - context 'when github is up', vcr: {cassette_name: 'github_lastrelease'} do - it { expect(subject.url).to eq 'https://api.github.com/repos/sgmap/tps/releases/4685573' } - it { expect(subject.body).to match /.*[Nouveautés].*/ } - it { expect(subject.published_at).to match /[0-9][0-9][\/][0-9][0-9][\/][0-9][0-9][0-9][0-9]/ } - end - - context 'when github is down' do - before do - allow_any_instance_of(RestClient::Resource).to receive(:get).and_raise(RestClient::Forbidden) - end - - it { is_expected.to be_nil } - end - end -end \ No newline at end of file diff --git a/spec/mailers/notification_mailer_spec.rb b/spec/mailers/notification_mailer_spec.rb index 1b54455c4..730ce70de 100644 --- a/spec/mailers/notification_mailer_spec.rb +++ b/spec/mailers/notification_mailer_spec.rb @@ -7,9 +7,9 @@ RSpec.describe NotificationMailer, type: :mailer do subject(:subject) { described_class.new_answer(dossier) } - it { expect(subject.body).to match('Un nouveau commentaire est disponible dans votre espace TPS.') } + it { expect(subject.body).to match('Un nouveau message est disponible dans votre espace TPS.') } it { expect(subject.body).to include("Pour le consulter, merci de vous rendre sur #{users_dossier_recapitulatif_url(dossier_id: dossier.id)}") } - it { expect(subject.subject).to eq("Nouveau commentaire pour votre dossier TPS N°#{dossier.id}") } + it { expect(subject.subject).to eq("Nouveau message pour votre dossier TPS N°#{dossier.id}") } end describe ".dossier_validated" do