Merge branch 'develop' into staging

This commit is contained in:
Xavier J 2017-01-03 14:09:36 +01:00
commit ace4f12689
22 changed files with 159 additions and 149 deletions

View file

@ -22,4 +22,22 @@ class ApplicationController < ActionController::Base
@left_pannel_url = service.left_panel @left_pannel_url = service.left_panel
@facade_data_view = nil @facade_data_view = nil
end 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 end

View file

@ -122,7 +122,7 @@ class Users::DescriptionController < UsersController
private private
def check_autorisation_donnees 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 redirect_to url_for(users_dossier_path(@dossier.id)) if @dossier.autorisation_donnees.nil? || !@dossier.autorisation_donnees
end end

View file

@ -1,4 +1,4 @@
#form_login #form_login.user_connexion_page
%br %br
= render partial: 'users/sessions/resume_procedure' = render partial: 'users/sessions/resume_procedure'

View file

@ -105,7 +105,7 @@ describe Admin::ProceduresController, type: :controller do
sign_out admin sign_out admin
end end
it { expect(subject).to redirect_to new_administrateur_session_path } it { expect(subject).to redirect_to new_user_session_path }
end end
context 'when user is connected' do context 'when user is connected' do
@ -204,7 +204,7 @@ describe Admin::ProceduresController, type: :controller do
subject { put :update, params: {id: procedure.id} } 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 end
context 'when administrateur is connected' do context 'when administrateur is connected' do

View file

@ -20,7 +20,7 @@ describe Administrateurs::SessionsController, type: :controller do
it { expect(subject.status).to eq 200 } it { expect(subject.status).to eq 200 }
it 'Administrateur demo is initiated' do 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 subject
end end
end end

View file

@ -72,7 +72,7 @@ describe Backoffice::DossiersController, type: :controller do
end end
context 'gestionnaire does not connected but dossier id is correct' do 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
end end

View file

@ -20,7 +20,7 @@ describe Gestionnaires::SessionsController, type: :controller do
it { expect(subject.status).to eq 200 } it { expect(subject.status).to eq 200 }
it 'Gestionnaire demo is initiated' do 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 subject
end end
end end

View file

@ -19,6 +19,13 @@ FactoryGirl.define do
end end
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 trait :with_two_quartier_prioritaires do
after(:build) do |dossier, _evaluator| after(:build) do |dossier, _evaluator|
dossier.quartier_prioritaires << create(:quartier_prioritaire) dossier.quartier_prioritaires << create(:quartier_prioritaire)

View file

@ -0,0 +1,7 @@
FactoryGirl.define do
factory :individual do
nom 'Julien'
prenom 'Xavier'
birthdate '20/01/1991'
end
end

View file

@ -6,13 +6,13 @@ feature 'Administrator connection' do
visit new_administrateur_session_path visit new_administrateur_session_path
end end
scenario 'administrator is on admin loggin page' do 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 end
context "admin fills form and log in" do context "admin fills form and log in" do
before do before do
page.find_by_id('administrateur_email').set admin.email page.find_by_id('user_email').set admin.email
page.find_by_id('administrateur_password').set admin.password page.find_by_id('user_password').set admin.password
page.click_on 'Se connecter' page.click_on 'Se connecter'
end end
scenario 'a menu button is available' do scenario 'a menu button is available' do

View file

@ -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).to have_current_path(admin_procedure_path(Procedure.first.id.to_s))
expect(page.find_by_id('publish-procedure')['disabled']).to eq('disabled') 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)) 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('gestionnaire_email').set 'gestionnaire@apientreprise.fr'
page.find_by_id('add-gestionnaire-email').click page.find_by_id('add-gestionnaire-email').click
page.first('.gestionnaire-affectation').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) expect(page).to have_selector('#publish-procedure', visible: true)
page.find_by_id('publish-procedure').click page.find_by_id('publish-procedure').click

View file

@ -7,16 +7,16 @@ feature 'when gestionnaire come to /backoffice and is not authenticated' do
visit backoffice_path visit backoffice_path
end end
scenario 'he is redirected to /gestionnaires/sign_id' do scenario 'he is redirected to /gestionnaires/sign_id' do
expect(page).to have_css('#gestionnaire_login') expect(page).to have_css('#user_email')
end end
context 'when user enter bad credentials' do context 'when user enter bad credentials' do
before do before do
page.find_by_id(:gestionnaire_email).set 'unknown@plop.com' page.find_by_id(:user_email).set 'unknown@plop.com'
page.find_by_id(:gestionnaire_password).set 'password' page.find_by_id(:user_password).set 'password'
page.click_on 'Se connecter' page.click_on 'Se connecter'
end end
scenario 'he stay on the same page with an error' do 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
end end
context 'when user enter good credentials' do context 'when user enter good credentials' do
@ -25,8 +25,8 @@ feature 'when gestionnaire come to /backoffice and is not authenticated' do
before do before do
create :assign_to, gestionnaire: gestionnaire, procedure: procedure create :assign_to, gestionnaire: gestionnaire, procedure: procedure
page.find_by_id(:gestionnaire_email).set gestionnaire.email page.find_by_id(:user_email).set gestionnaire.email
page.find_by_id(:gestionnaire_password).set gestionnaire.password page.find_by_id(:user_password).set gestionnaire.password
page.click_on 'Se connecter' page.click_on 'Se connecter'
end end
scenario 'he is redirected to /backoffice' do scenario 'he is redirected to /backoffice' do

View file

@ -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 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_1
create :assign_to, gestionnaire: gestionnaire, procedure: procedure_2 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') Dossier.create(procedure_id: procedure_1.id.to_s, user: user, state: 'validated')
end end
15.times do 22.times do
Dossier.create(procedure_id: procedure_2.id.to_s, user: user, state: 'validated') Dossier.create(procedure_id: procedure_2.id.to_s, user: user, state: 'validated')
end end
login_as gestionnaire, scope: :gestionnaire 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 scenario 'Switching between procedures' do
page.all('#procedure_list a').first.trigger('click') 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).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') 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).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 end
scenario 'Searching with search bar' do 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') 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" visit "/backoffice/dossiers/procedure/1?all_state_dossiers_smart_listing[sort][id]=desc"
wait_for_ajax 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') page.find('#all_state_dossiers .next_page a').trigger('click')
wait_for_ajax wait_for_ajax
page.find('#all_state_dossiers .next_page a').trigger('click') page.find('#all_state_dossiers .next_page a').trigger('click')
wait_for_ajax 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') page.find('#all_state_dossiers .prev a').trigger('click')
wait_for_ajax 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 end
scenario 'Using filter' do scenario 'Using filter' do

View file

@ -9,20 +9,13 @@ feature 'usage of pref list dossier lateral panel', js: true do
before do before do
create(:dossier, :with_entreprise, procedure: procedure, state: 'updated') create(:dossier, :with_entreprise, procedure: procedure, state: 'updated')
create :assign_to, procedure: procedure, gestionnaire: gestionnaire create :assign_to, procedure: procedure, gestionnaire: gestionnaire
login_as gestionnaire, scope: :gestionnaire
visit backoffice_path visit backoffice_path
end 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 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 scenario 'he is redirected to /backoffice' do
expect(page).to have_css('#backoffice_index') expect(page).to have_css('#backoffice_index')
end end

View file

@ -9,20 +9,13 @@ feature 'usage of pref list dossier lateral panel by procedure', js: true do
before do before do
create(:dossier, :with_entreprise, procedure: procedure, state: 'updated') create(:dossier, :with_entreprise, procedure: procedure, state: 'updated')
create :assign_to, procedure: procedure, gestionnaire: gestionnaire create :assign_to, procedure: procedure, gestionnaire: gestionnaire
login_as gestionnaire, scope: :gestionnaire
visit backoffice_path visit backoffice_path
end 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 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 scenario 'he is redirected to /backoffice/dossiers/' do
expect(page).to have_css('#backoffice_index') expect(page).to have_css('#backoffice_index')
end end

View file

@ -1,27 +1,29 @@
require 'spec_helper' require 'spec_helper'
feature 'on backoffice page' do feature 'on backoffice page', js: true do
let(:administrateur) { create(:administrateur) } let(:administrateur) { create(:administrateur) }
let(:gestionnaire) { create(:gestionnaire, administrateurs: [administrateur]) } let(:gestionnaire) { create(:gestionnaire, administrateurs: [administrateur]) }
let(:procedure) { create(:procedure, administrateur: 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) { create(:dossier, :with_entreprise, procedure: procedure, state: 'updated') }
let!(:dossier_individual) { create :dossier, procedure: procedure_individual, state: 'updated' }
before do before do
create :assign_to, gestionnaire: gestionnaire, procedure: procedure create :assign_to, gestionnaire: gestionnaire, procedure: procedure
create :follow, gestionnaire: gestionnaire, dossier: dossier create :follow, gestionnaire: gestionnaire, dossier: dossier
create :assign_to, gestionnaire: gestionnaire, procedure: procedure_individual
create :follow, gestionnaire: gestionnaire, dossier: dossier_individual
visit backoffice_path visit backoffice_path
end end
context 'when gestionnaire is logged in' do context 'when gestionnaire is logged in' do
before do before do
page.find_by_id(:gestionnaire_email).set gestionnaire.email page.find_by_id(:user_email).set gestionnaire.email
page.find_by_id(:gestionnaire_password).set gestionnaire.password page.find_by_id(:user_password).set gestionnaire.password
page.click_on 'Se connecter' page.click_on 'Se connecter'
end end
context 'when he click on first dossier', js: true do context 'when he click on first dossier' do
before do before do
page.find("#tr_dossier_#{dossier.id}", visible: true).click page.find("#tr_dossier_#{dossier.id}", visible: true).click
end end
@ -30,14 +32,13 @@ feature 'on backoffice page' do
expect(page).to have_css('#backoffice_dossier_show') expect(page).to have_css('#backoffice_dossier_show')
end end
end end
end
context 'when gestionnaire have enterprise and individual dossier in his inbox', js: true do 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' }
before do before do
create :assign_to, gestionnaire: gestionnaire, procedure: procedure_individual page.find_by_id(:user_email).set gestionnaire.email
create :follow, gestionnaire: gestionnaire, dossier: dossier_individual page.find_by_id(:user_password).set gestionnaire.password
page.click_on 'Se connecter'
visit backoffice_dossiers_procedure_path(id: procedure_individual.id) visit backoffice_dossiers_procedure_path(id: procedure_individual.id)
page.find("#tr_dossier_#{dossier_individual.id}", visible: true).click page.find("#tr_dossier_#{dossier_individual.id}", visible: true).click
@ -47,5 +48,4 @@ feature 'on backoffice page' do
expect(page).to have_css('#backoffice_dossier_show') expect(page).to have_css('#backoffice_dossier_show')
end end
end end
end
end end

View file

@ -1,20 +1,13 @@
require 'spec_helper' 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(: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 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 visit root_path
end 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 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') expect(page.find('#a_traiter')['class'] ).to eq('active procedure_list_element')
page.find_by_id('brouillon').trigger('click') page.find_by_id('brouillon').click
page.find_by_id('a_traiter').trigger('click') page.find_by_id('a_traiter').click
page.find_by_id('valides').trigger('click') page.find_by_id('valides').click
page.find_by_id('en_instruction').trigger('click') page.find_by_id('en_instruction').click
page.find_by_id('termine').trigger('click') page.find_by_id('termine').click
page.find_by_id('invite').trigger('click') page.find_by_id('invite').click
end end
scenario 'Getting a dossier, I want to create a new message on' do 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).trigger('click') 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) 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.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') expect(page.find('.last-commentaire .content').text).to eq('Contenu du nouveau message')
end end
scenario 'On the same dossier, I want to edit informations' do scenario 'On the same dossier, I want to edit informations', js: true do
page.find_by_id('tr_dossier_' + Dossier.last.id.to_s).trigger('click') page.find_by_id('tr_dossier_' + dossier.id.to_s).click
page.find_by_id('edit-dossier').trigger('click') expect(page).to have_current_path(users_dossier_recapitulatif_path(dossier.id.to_s), only_path: true)
expect(page).to have_current_path(users_dossier_description_path(Dossier.first.id.to_s), only_path: true) page.find_by_id('maj_infos').trigger('click')
fill_in 'champs_1', with: 'Contenu du champ 1' expect(page).to have_current_path(users_dossier_description_path(dossier.id.to_s), only_path: true)
page.find_by_id('modification_terminee').trigger('click') fill_in "champs_#{dossier.champs.first.id.to_s}", with: 'Contenu du champ 1'
expect(page).to have_current_path(users_dossier_recapitulatif_path(Dossier.first.id.to_s), only_path: true) 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') expect(page.find('#champ-1-value').text).to eq('Contenu du champ 1')
end end
end end

View file

@ -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 context 'After sign_in, I can see my 51 dossiers on the index' do
scenario 'Using sort' 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') expect(page.all(:css, '#dossiers_list tr')[2].text.split(" ").first).to eq('2')
visit "/users/dossiers?dossiers_smart_listing[sort][id]=desc" 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')[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 end
scenario 'Using pagination' do 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') page.find('.next_page a').trigger('click')
wait_for_ajax 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') page.find('.next_page a').trigger('click')
wait_for_ajax 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') page.find('.prev a').trigger('click')
wait_for_ajax wait_for_ajax
page.find('.prev a').trigger('click') page.find('.prev a').trigger('click')

View file

@ -21,7 +21,7 @@ http_interactions:
Server: Server:
- nginx/1.11.3 - nginx/1.11.3
Date: Date:
- Tue, 20 Dec 2016 11:36:58 GMT - Tue, 03 Jan 2017 13:00:54 GMT
Content-Type: Content-Type:
- application/json; charset=utf-8 - application/json; charset=utf-8
Content-Length: Content-Length:
@ -44,5 +44,50 @@ http_interactions:
"housenumber": "50", "street": "Avenue des Champs \u00c9lys\u00e9es"}, "type": "housenumber": "50", "street": "Avenue des Champs \u00c9lys\u00e9es"}, "type":
"Feature"}]}' "Feature"}]}'
http_version: 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 recorded_with: VCR 3.0.3

View file

@ -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

View file

@ -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

View file

@ -7,9 +7,9 @@ RSpec.describe NotificationMailer, type: :mailer do
subject(:subject) { described_class.new_answer(dossier) } 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.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 end
describe ".dossier_validated" do describe ".dossier_validated" do