Merge branch 'develop' into staging

This commit is contained in:
Xavier J 2017-02-13 13:52:34 +01:00
commit 138b5ac498
30 changed files with 164 additions and 199 deletions

View file

@ -158,6 +158,15 @@ class Backoffice::DossiersController < Backoffice::DossiersListController
render 'backoffice/dossiers/index', formats: :js render 'backoffice/dossiers/index', formats: :js
end end
def archive
facade = create_dossier_facade params[:dossier_id]
unless facade.dossier.archived
facade.dossier.update(archived: true)
flash.notice = 'Dossier archivé'
end
redirect_to backoffice_dossiers_path
end
private private
def create_dossier_facade dossier_id def create_dossier_facade dossier_id

View file

@ -101,6 +101,7 @@ class Users::SessionsController < Sessions::SessionsController
if resource = klass.find_for_database_authentication(email: params[:user][:email]) if resource = klass.find_for_database_authentication(email: params[:user][:email])
if resource.valid_password?(params[:user][:password]) if resource.valid_password?(params[:user][:password])
sign_in resource sign_in resource
resource.force_sync_credentials
set_flash_message :notice, :signed_in set_flash_message :notice, :signed_in
end end
end end

View file

@ -6,7 +6,8 @@ class Administrateur < ActiveRecord::Base
has_many :procedures has_many :procedures
before_save :ensure_api_token before_save :ensure_api_token
after_update :sync_credentials
include CredentialsSyncableConcern
def ensure_api_token def ensure_api_token
if api_token.nil? if api_token.nil?
@ -27,10 +28,4 @@ class Administrateur < ActiveRecord::Base
end end
end end
def sync_credentials
if email_changed? || encrypted_password_changed?
return SyncCredentialsService.new(Administrateur, email_was, email, encrypted_password).change_credentials!
end
true
end
end end

View file

@ -0,0 +1,19 @@
module CredentialsSyncableConcern
extend ActiveSupport::Concern
included do
after_update :sync_credentials
end
def sync_credentials
if email_changed? || encrypted_password_changed?
return force_sync_credentials
end
true
end
def force_sync_credentials
SyncCredentialsService.new(self.class, email_was, email, encrypted_password).change_credentials!
end
end

View file

@ -14,7 +14,8 @@ class Gestionnaire < ActiveRecord::Base
after_create :build_default_preferences_list_dossier after_create :build_default_preferences_list_dossier
after_create :build_default_preferences_smart_listing_page after_create :build_default_preferences_smart_listing_page
after_update :sync_credentials
include CredentialsSyncableConcern
def dossiers_follow def dossiers_follow
@dossiers_follow ||= dossiers.joins(:follows).where("follows.gestionnaire_id = #{id}") @dossiers_follow ||= dossiers.joins(:follows).where("follows.gestionnaire_id = #{id}")
@ -119,11 +120,4 @@ class Gestionnaire < ActiveRecord::Base
couples.include?({table: table, column: column}) couples.include?({table: table, column: column})
end end
def sync_credentials
if email_changed? || encrypted_password_changed?
return SyncCredentialsService.new(Gestionnaire, email_was, email, encrypted_password).change_credentials!
end
true
end
end end

View file

@ -15,7 +15,8 @@ class User < ActiveRecord::Base
delegate :given_name, :family_name, :email_france_connect, :gender, :birthdate, :birthplace, :france_connect_particulier_id, to: :france_connect_information delegate :given_name, :family_name, :email_france_connect, :gender, :birthdate, :birthplace, :france_connect_particulier_id, to: :france_connect_information
accepts_nested_attributes_for :france_connect_information accepts_nested_attributes_for :france_connect_information
after_update :sync_credentials
include CredentialsSyncableConcern
def self.find_for_france_connect email, siret def self.find_for_france_connect email, siret
user = User.find_by_email(email) user = User.find_by_email(email)
@ -35,12 +36,4 @@ class User < ActiveRecord::Base
invites.pluck(:dossier_id).include?(dossier_id.to_i) invites.pluck(:dossier_id).include?(dossier_id.to_i)
end end
private
def sync_credentials
if email_changed? || encrypted_password_changed?
return SyncCredentialsService.new(User, email_was, email, encrypted_password).change_credentials!
end
true
end
end end

View file

@ -11,7 +11,7 @@ class SyncCredentialsService
unless @klass == User unless @klass == User
user = User.find_by(email: @email_was) user = User.find_by(email: @email_was)
if user if user
return user.update_columns( return false unless user.update_columns(
email: @email, email: @email,
encrypted_password: @encrypted_password) encrypted_password: @encrypted_password)
end end
@ -20,7 +20,7 @@ class SyncCredentialsService
unless @klass == Gestionnaire unless @klass == Gestionnaire
gestionnaire = Gestionnaire.find_by(email: @email_was) gestionnaire = Gestionnaire.find_by(email: @email_was)
if gestionnaire if gestionnaire
return gestionnaire.update_columns( return false unless gestionnaire.update_columns(
email: @email, email: @email,
encrypted_password: @encrypted_password) encrypted_password: @encrypted_password)
end end
@ -29,10 +29,12 @@ class SyncCredentialsService
unless @klass == Administrateur unless @klass == Administrateur
administrateur = Administrateur.find_by(email: @email_was) administrateur = Administrateur.find_by(email: @email_was)
if administrateur if administrateur
return administrateur.update_columns( return false unless administrateur.update_columns(
email: @email, email: @email,
encrypted_password: @encrypted_password) encrypted_password: @encrypted_password)
end end
end end
true
end end
end end

View file

@ -24,6 +24,11 @@
%button.action.refuse-dossier %button.action.refuse-dossier
%i.fa.fa-times %i.fa.fa-times
- unless @facade.dossier.archived?
= link_to 'Archiver', backoffice_dossier_archive_path(@facade.dossier), method: :post, class: 'btn btn-default btn-block'
%div#menu-block %div#menu-block
%div#infos-block %div#infos-block
@ -33,7 +38,7 @@
%div.split-hr-left %div.split-hr-left
%div.notifications %div.notifications
- if @facade.dossier.notifications.empty? - if @facade.dossier.notifications.empty?
= "Aucune notification pour le moment." Aucune notification pour le moment.
- else - else
%i.fa.fa-bell-o %i.fa.fa-bell-o
- @facade.last_notifications.each do |notification| - @facade.last_notifications.each do |notification|

View file

@ -1,3 +0,0 @@
#!/usr/bin/env ruby
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
load Gem.bin_path('bundler', 'bundle')

View file

@ -1,29 +0,0 @@
#!/usr/bin/env ruby
require 'pathname'
# path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
Dir.chdir APP_ROOT do
# This script is a starting point to setup your application.
# Add necessary setup steps to this file:
puts "== Installing dependencies =="
system "gem install bundler --conservative"
system "bundle check || bundle install"
# puts "\n== Copying sample files =="
# unless File.exist?("config/database.yml")
# system "cp config/database.yml.sample config/database.yml"
# end
puts "\n== Preparing database =="
system "bin/rake db:setup"
puts "\n== Removing old logs and tempfiles =="
system "rm -f log/*"
system "rm -rf tmp/cache"
puts "\n== Restarting application server =="
system "touch tmp/restart.txt"
end

View file

@ -172,6 +172,7 @@ Rails.application.routes.draw do
post 'refuse' => 'dossiers#refuse' post 'refuse' => 'dossiers#refuse'
post 'without_continuation' => 'dossiers#without_continuation' post 'without_continuation' => 'dossiers#without_continuation'
post 'close' => 'dossiers#close' post 'close' => 'dossiers#close'
post 'archive' => 'dossiers#archive'
put 'follow' => 'dossiers#follow' put 'follow' => 'dossiers#follow'
resources :commentaires, only: [:index] resources :commentaires, only: [:index]

View file

@ -345,4 +345,23 @@ describe Backoffice::DossiersController, type: :controller do
end end
end end
end end
describe 'POST #archive' do
before do
dossier.update(archived: false)
sign_in gestionnaire
end
subject { post :archive, params: {dossier_id: dossier_id} }
it 'change state to archived' do
subject
dossier.reload
expect(dossier.archived).to eq(true)
end
it { is_expected.to redirect_to backoffice_dossiers_path }
end
end end

View file

@ -84,15 +84,16 @@ describe RootController, type: :controller do
end end
context 'when opensimplif features is true' do context 'when opensimplif features is true' do
let(:gestionnaire) { create(:gestionnaire) } pending
# let(:gestionnaire) { create(:gestionnaire) }
before do #
sign_in gestionnaire # before do
# sign_in gestionnaire
allow_any_instance_of(Features).to receive(:opensimplif).and_return(true) #
end # allow_any_instance_of(Features).to receive(:opensimplif).and_return(true)
# end
it { expect(subject).to redirect_to(simplifications_path) } #
# it { expect(subject).to redirect_to(simplifications_path) }
end end
context "unified login" do context "unified login" do

View file

@ -100,6 +100,24 @@ describe Users::SessionsController, type: :controller do
expect(subject.current_gestionnaire).to be(nil) expect(subject.current_gestionnaire).to be(nil)
expect(subject.current_administrateur).to be(nil) expect(subject.current_administrateur).to be(nil)
end end
context 'with different passwords' do
let!(:gestionnaire) { create(:gestionnaire, email: email, password: 'another_password') }
let!(:administrateur) { create(:administrateur, email: email, password: 'another_password') }
before do
user
end
it 'should sync passwords on login' do
post :create, params: { user: { email: email, password: password } }
gestionnaire.reload
administrateur.reload
expect(user.valid_password?(password)).to be(true)
expect(gestionnaire.valid_password?(password)).to be(true)
expect(administrateur.valid_password?(password)).to be(true)
end
end
end end
end end

View file

@ -1,15 +0,0 @@
require 'spec_helper'
describe InviteDossierFacades do
let(:dossier) { create :dossier }
let(:email) { 'email@octo.com' }
subject { described_class.new dossier.id, email }
before do
create :invite, email: email, dossier: dossier
end
it { expect(subject.dossier).to eq dossier }
end

View file

@ -46,7 +46,6 @@ feature 'As an administrateur I wanna create a new procedure', js: true do
end end
context 'Editing a new procedure' do context 'Editing a new procedure' do
before 'Create procedure' do before 'Create procedure' do
page.find_by_id('new-procedure').click page.find_by_id('new-procedure').click
fill_in 'procedure_libelle', with: 'libelle de la procedure' fill_in 'procedure_libelle', with: 'libelle de la procedure'

View file

@ -1,7 +1,6 @@
require 'spec_helper' require 'spec_helper'
feature 'As an Accompagnateur I can navigate and use each functionnality around procedures and their dossiers', js: true do feature 'As an Accompagnateur I can navigate and use each functionnality around procedures and their dossiers' do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:gestionnaire) { create(:gestionnaire) } let(:gestionnaire) { create(:gestionnaire) }
let(:procedure_1) { create(:procedure, :with_type_de_champ, libelle: 'procedure 1') } let(:procedure_1) { create(:procedure, :with_type_de_champ, libelle: 'procedure 1') }
@ -23,46 +22,46 @@ feature 'As an Accompagnateur I can navigate and use each functionnality around
context 'On index' do context 'On index' do
scenario 'Switching between procedures' do scenario 'Switching between procedures' do
page.all('#procedure_list a').first.trigger('click') page.all('#procedure_list a').first.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('30 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.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('22 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', js: true do
page.find_by_id('search_area').trigger('click') page.find_by_id('search_area').trigger('click')
fill_in 'q', with: '15' fill_in 'q', with: (procedure_1.dossiers.first.id + 14)
page.find_by_id('search_button').trigger('click') page.find_by_id('search_button').click
page.find_by_id('tr_dossier_15').trigger('click') page.find_by_id("tr_dossier_#{(procedure_1.dossiers.first.id + 14)}").click
expect(page).to have_current_path("/backoffice/dossiers/15") expect(page).to have_current_path("/backoffice/dossiers/#{(procedure_1.dossiers.first.id + 14)}")
end end
scenario 'Following dossier' do scenario 'Following dossier' do
page.all('#procedure_list a').first.trigger('click') page.all('#procedure_list a').first.click
expect(page.all('#follow_dossiers .smart-listing')[0]['data-item-count']).to eq ("0") expect(page.all('#follow_dossiers .smart-listing')[0]['data-item-count']).to eq ("0")
page.find_by_id('all_dossiers').trigger('click') page.find_by_id('all_dossiers').click
expect(page.all('#dossiers_list a').first.text).to eq('Suivre') expect(page.all('#dossiers_list a').first.text).to eq('Suivre')
page.all('#dossiers_list a').first.trigger('click') page.all('#dossiers_list a').first.click
expect(page.all('#follow_dossiers .smart-listing')[0]['data-item-count']).to eq ("1") expect(page.all('#follow_dossiers .smart-listing')[0]['data-item-count']).to eq ("1")
end end
scenario 'Using sort and pagination' do scenario 'Using sort and pagination', js: true do
visit "/backoffice/dossiers/procedure/1?all_state_dossiers_smart_listing[sort][id]=asc" visit "/backoffice/dossiers/procedure/#{procedure_1.id}?all_state_dossiers_smart_listing[sort][id]=asc"
wait_for_ajax wait_for_ajax
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_#{procedure_1.dossiers.first.id}")
visit "/backoffice/dossiers/procedure/1?all_state_dossiers_smart_listing[sort][id]=desc" visit "/backoffice/dossiers/procedure/#{procedure_1.id}?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_30') expect(page.all(".dossier-row")[0]['id']).to eq("tr_dossier_#{procedure_1.dossiers.last.id}")
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_10') expect(page.all(".dossier-row")[0]['id']).to eq("tr_dossier_#{procedure_1.dossiers.first.id + 9}")
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_20') expect(page.all(".dossier-row")[0]['id']).to eq("tr_dossier_#{procedure_1.dossiers.first.id + 19}")
end end
scenario 'Using filter' do scenario 'Using filter' do
@ -76,23 +75,25 @@ feature 'As an Accompagnateur I can navigate and use each functionnality around
end end
context 'On show' do context 'On show' do
scenario 'Following dossier' do scenario 'Following dossier' do
expect(page.all('#follow_dossiers .count').first.text).to eq('0 dossiers') expect(page.all('#follow_dossiers .count').first.text).to eq('0 dossiers')
visit "/backoffice/dossiers/procedure/1?all_state_dossiers_smart_listing[sort][id]=asc"
page.find_by_id("suivre_dossier_1").trigger('click') visit "/backoffice/dossiers/procedure/#{procedure_1.id}?all_state_dossiers_smart_listing[sort][id]=asc"
visit "backoffice/dossiers/4" page.find_by_id("suivre_dossier_#{procedure_1.dossiers.first.id}").click
page.find_by_id("suivre_dossier_4").trigger('click')
visit "/backoffice/dossiers/procedure/1" visit "/backoffice/dossiers/#{procedure_1.dossiers.second.id}"
page.find_by_id("suivre_dossier_#{procedure_1.dossiers.second.id}").click
visit "/backoffice/dossiers/procedure/#{procedure_1.id}"
expect(page.all('#follow_dossiers .count').first.text).to eq('2 dossiers') expect(page.all('#follow_dossiers .count').first.text).to eq('2 dossiers')
end end
scenario 'Adding message' do scenario 'Adding message', js: true do
page.find_by_id('tr_dossier_4').trigger('click') page.find_by_id("tr_dossier_#{procedure_1.dossiers.first.id}").trigger('click')
expect(page).to have_current_path(backoffice_dossier_path(4), only_path: true) expect(page).to have_current_path(backoffice_dossier_path(procedure_1.dossiers.first.id), 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
end end

View file

@ -1,25 +0,0 @@
require 'spec_helper'
feature 'As an Accompagnateur I can send invitations from dossiers', js: true do
let(:user) { create(:user) }
let(:gestionnaire) { create(:gestionnaire) }
let(:procedure_1) { create(:procedure, :with_type_de_champ, libelle: 'procedure 1') }
before 'Assign procedures to Accompagnateur and generating dossiers for each' do
create :assign_to, gestionnaire: gestionnaire, procedure: procedure_1
Dossier.create(procedure_id: procedure_1.id.to_s, user: user, state: 'initiated')
login_as gestionnaire, scope: :gestionnaire
visit backoffice_dossier_path(1)
end
context 'On dossier show' do
scenario 'Sending invitation' do
page.find('#invitations').click
page.find('#invitation-email').set('toto@email.com')
page.find('#send-invitation .btn-success').trigger('click')
end
end
end

View file

@ -69,6 +69,7 @@ feature 'usage of pref list dossier lateral panel', js: true do
end end
scenario 'lateral panel is masked' do scenario 'lateral panel is masked' do
wait_for_ajax
expect(page).to have_css('#pref_list_menu', visible: false) expect(page).to have_css('#pref_list_menu', visible: false)
end end
end end

View file

@ -35,6 +35,7 @@ feature 'usage of pref list dossier lateral panel by procedure', js: true do
end end
scenario 'lateral panel is appeared' do scenario 'lateral panel is appeared' do
wait_for_ajax
expect(page).to have_css('#pref_list_menu') expect(page).to have_css('#pref_list_menu')
end end
@ -69,6 +70,7 @@ feature 'usage of pref list dossier lateral panel by procedure', js: true do
end end
scenario 'lateral panel is masked' do scenario 'lateral panel is masked' do
wait_for_ajax
expect(page).to have_css('#pref_list_menu', visible: false) expect(page).to have_css('#pref_list_menu', visible: false)
end end
end end

View file

@ -14,7 +14,7 @@ feature 'on backoffice page', js: true do
create :follow, gestionnaire: gestionnaire, dossier: dossier create :follow, gestionnaire: gestionnaire, dossier: dossier
create :assign_to, gestionnaire: gestionnaire, procedure: procedure_individual create :assign_to, gestionnaire: gestionnaire, procedure: procedure_individual
create :follow, gestionnaire: gestionnaire, dossier: dossier_individual create :follow, gestionnaire: gestionnaire, dossier: dossier_individual
visit backoffice_path visit users_path
end end
context 'when gestionnaire is logged in' do context 'when gestionnaire is logged in' do

View file

@ -14,7 +14,6 @@ feature 'user is on description page' do
page.find_by_id('user_password').set dossier.user.password page.find_by_id('user_password').set dossier.user.password
page.click_on 'Se connecter' page.click_on 'Se connecter'
end end
end end
it { expect(page).to have_css('#description_page') } it { expect(page).to have_css('#description_page') }

View file

@ -61,7 +61,7 @@ feature 'user path for dossier creation' do
context 'when validating info entreprise recap page' do context 'when validating info entreprise recap page' do
before do before do
page.check('dossier_autorisation_donnees') page.check('dossier_autorisation_donnees')
page.click_on 'Etape suivante' page.find_by_id('etape_suivante').trigger('click')
end end
scenario 'user is on description page' do scenario 'user is on description page' do
expect(page).to have_css('#description_page') expect(page).to have_css('#description_page')
@ -69,7 +69,7 @@ feature 'user path for dossier creation' do
context 'user fill and validate description page' do context 'user fill and validate description page' do
before do before do
page.find_by_id("champs_#{Dossier.last.champs.first.id}").set 'Mon super projet' page.find_by_id("champs_#{Dossier.last.champs.first.id}").set 'Mon super projet'
page.click_on 'Soumettre mon dossier' page.find_by_id('suivant').trigger('click')
end end
scenario 'user is on recap page' do scenario 'user is on recap page' do
expect(page).to have_css('#users_recapitulatif_dossier_show') expect(page).to have_css('#users_recapitulatif_dossier_show')

View file

@ -1,7 +1,6 @@
require 'spec_helper' require 'spec_helper'
feature 'As a User I wanna create a dossier', js: true do feature 'As a User I wanna create a dossier' do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:siret) { '40307130100044' } let(:siret) { '40307130100044' }
let(:siren) { siret[0...9] } let(:siren) { siret[0...9] }
@ -17,18 +16,18 @@ feature 'As a User I wanna create a dossier', js: true do
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').trigger('click') page.find_by_id('etape_suivante').click
expect(page).to have_current_path(users_dossier_carte_path(Dossier.first.id.to_s), only_path: true) expect(page).to have_current_path(users_dossier_carte_path(procedure_for_individual.dossiers.last.id.to_s), only_path: true)
page.find_by_id('etape_suivante').trigger('click') page.find_by_id('etape_suivante').click
fill_in 'champs_1', with: 'contenu du champ 1' fill_in "champs_#{procedure_for_individual.dossiers.last.champs.first.id}", with: 'contenu du champ 1'
page.find_by_id('suivant').trigger('click') page.find_by_id('suivant').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(procedure_for_individual.dossiers.last.id.to_s), only_path: true)
end end
scenario 'Identification through siret', vcr: {cassette_name: 'search_ban_paris'} do scenario 'Identification through siret', vcr: {cassette_name: 'search_ban_paris'}, js: true do
login_as user, scope: :user login_as user, scope: :user
visit commencer_path(procedure_path: procedure_with_siret.path) visit commencer_path(procedure_path: procedure_with_siret.path)
expect(page).to have_current_path(users_dossier_path(Dossier.first.id.to_s), only_path: true) expect(page).to have_current_path(users_dossier_path(procedure_with_siret.dossiers.last.id.to_s), only_path: true)
fill_in 'dossier_siret', with: siret fill_in 'dossier_siret', with: siret
stub_request(:get, "https://api-dev.apientreprise.fr/v2/etablissements/#{siret}?token=#{SIADETOKEN}") stub_request(:get, "https://api-dev.apientreprise.fr/v2/etablissements/#{siret}?token=#{SIADETOKEN}")
.to_return(status: 200, body: File.read('spec/support/files/etablissement.json')) .to_return(status: 200, body: File.read('spec/support/files/etablissement.json'))
@ -43,11 +42,11 @@ feature 'As a User I wanna create a dossier', js: true do
expect(page).to have_css('#recap_info_entreprise') expect(page).to have_css('#recap_info_entreprise')
find(:css, "#dossier_autorisation_donnees[value='1']").set(true) 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')
expect(page).to have_current_path(users_dossier_carte_path(Dossier.first.id.to_s), only_path: true) expect(page).to have_current_path(users_dossier_carte_path(procedure_with_siret.dossiers.last.id.to_s), only_path: true)
page.find_by_id('etape_suivante').trigger('click') page.find_by_id('etape_suivante').trigger('click')
fill_in 'champs_1', with: 'contenu du champ 1' fill_in "champs_#{procedure_with_siret.dossiers.last.champs.first.id}", with: 'contenu du champ 1'
page.find_by_id('suivant').trigger('click') page.find_by_id('suivant').trigger('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(procedure_with_siret.dossiers.last.id.to_s), only_path: true)
end end
end end
end end

View file

@ -40,7 +40,7 @@ feature 'As a User I want to edit a dossier I own' do
fill_in "champs_#{dossier.champs.first.id.to_s}", with: 'Contenu du champ 1' fill_in "champs_#{dossier.champs.first.id.to_s}", with: 'Contenu du champ 1'
page.find_by_id('modification_terminee').click 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).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-#{dossier.champs.first.id}-value").text).to eq('Contenu du champ 1')
end end
end end
end end

View file

@ -15,7 +15,7 @@ feature 'As a User I want to sort and paginate dossiers', js: true do
page.find_by_id('etape_suivante').trigger('click') page.find_by_id('etape_suivante').trigger('click')
page.find_by_id('suivant').trigger('click') page.find_by_id('suivant').trigger('click')
50.times do 50.times do
Dossier.create(procedure_id: 1, user_id: 1, state: "initiated") Dossier.create(procedure_id: procedure_for_individual.id, user_id: user.id, state: "initiated")
end end
visit root_path visit root_path
end end
@ -24,30 +24,30 @@ feature 'As a User I want to sort and paginate dossiers', js: true do
scenario 'Using sort' do scenario 'Using sort' do
visit "/users/dossiers?dossiers_smart_listing[sort][id]=asc" 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')[1].text.split(" ").first).to eq(user.dossiers.first.id.to_s)
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(user.dossiers.second.id.to_s)
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((user.dossiers.first.id + 50).to_s)
expect(page.all(:css, '#dossiers_list tr')[2].text.split(" ").first).to eq('50') expect(page.all(:css, '#dossiers_list tr')[2].text.split(" ").first).to eq((user.dossiers.first.id + 49).to_s)
visit "/users/dossiers?dossiers_smart_listing[sort][id]=asc" 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')[1].text.split(" ").first).to eq(user.dossiers.first.id.to_s)
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(user.dossiers.second.id.to_s)
end end
scenario 'Using pagination' do scenario 'Using pagination' do
visit "/users/dossiers?dossiers_smart_listing[sort][id]=asc" 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')[1].text.split(" ").first).to eq(user.dossiers.first.id.to_s)
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('11') expect(page.all(:css, '#dossiers_list tr')[1].text.split(" ").first).to eq((user.dossiers.first.id + 10).to_s)
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('21') expect(page.all(:css, '#dossiers_list tr')[1].text.split(" ").first).to eq((user.dossiers.first.id + 20).to_s)
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')
wait_for_ajax wait_for_ajax
expect(page.all(:css, '#dossiers_list tr')[1].text.split(" ").first).to eq('1') expect(page.all(:css, '#dossiers_list tr')[1].text.split(" ").first).to eq((user.dossiers.first.id).to_s)
end end
end end

View file

@ -1,23 +0,0 @@
require 'spec_helper'
feature 'As a User I can send invitations from dossiers', js: true do
let(:user) { create(:user) }
let(:procedure_1) { create(:procedure, :with_type_de_champ, libelle: 'procedure 1') }
before 'Assign procedures to Accompagnateur and generating dossiers for each' do
Dossier.create(procedure_id: procedure_1.id.to_s, user: user, state: 'initiated')
login_as user, scope: :user
visit users_dossier_recapitulatif_path(1)
end
context 'On dossier show' do
scenario 'Sending invitation' do
page.find('#invitations').click
fill_in 'invitation-email', with: 'toto@email.com'
page.find('#send-invitation .btn-success').trigger('click')
end
end
end

View file

@ -32,8 +32,8 @@ describe TypeDePieceJustificative do
end end
context 'lien_demarche' do context 'lien_demarche' do
it { is_expected.not_to allow_value(nil).for(:lien_demarche) } it { is_expected.to allow_value(nil).for(:lien_demarche) }
it { is_expected.not_to allow_value('').for(:lien_demarche) } it { is_expected.to allow_value('').for(:lien_demarche) }
it { is_expected.not_to allow_value('not-a-link').for(:lien_demarche) } it { is_expected.not_to allow_value('not-a-link').for(:lien_demarche) }
it { is_expected.to allow_value('http://link').for(:lien_demarche) } it { is_expected.to allow_value('http://link').for(:lien_demarche) }
end end

View file

@ -269,13 +269,13 @@ describe DossiersListGestionnaireService do
describe '#change_page!' do describe '#change_page!' do
let(:procedure) { nil } let(:procedure) { nil }
let(:liste) { 'a_traiter' } let(:liste) { 'all_state' }
let(:page) { 2 } let(:page) { 2 }
let(:new_page) { 1 } let(:new_page) { 1 }
before do before do
preference_smart_listing_page.update page: page, liste: 'a_traiter', procedure: nil preference_smart_listing_page.update page: page, liste: liste, procedure: nil
subject subject
preference_smart_listing_page.reload preference_smart_listing_page.reload
end end
@ -297,7 +297,7 @@ describe DossiersListGestionnaireService do
end end
context 'when liste change' do context 'when liste change' do
let(:liste) { 'en_attente' } let(:liste) { 'all_state' }
it { expect(preference_smart_listing_page.liste).to eq liste } it { expect(preference_smart_listing_page.liste).to eq liste }
it { expect(preference_smart_listing_page.procedure).to eq procedure } it { expect(preference_smart_listing_page.procedure).to eq procedure }
@ -308,7 +308,7 @@ describe DossiersListGestionnaireService do
it { expect(preference_smart_listing_page.liste).to eq liste } it { expect(preference_smart_listing_page.liste).to eq liste }
it { expect(preference_smart_listing_page.procedure).to eq procedure } it { expect(preference_smart_listing_page.procedure).to eq procedure }
it { expect(preference_smart_listing_page.page).to eq 1 } it { expect(preference_smart_listing_page.page).to eq page }
end end
end end
@ -329,7 +329,7 @@ describe DossiersListGestionnaireService do
end end
context 'when procedure and liste change' do context 'when procedure and liste change' do
let(:liste) { 'en_attente' } let(:liste) { 'all_state' }
let(:procedure) { dossier.procedure } let(:procedure) { dossier.procedure }
it { expect(preference_smart_listing_page.liste).to eq liste } it { expect(preference_smart_listing_page.liste).to eq liste }

View file

@ -8,6 +8,8 @@ describe 'layouts/left_panels/_left_panel_users_dossierscontroller_index.html.ha
before do before do
sign_in user sign_in user
create :dossier, user: user
assign :dossiers_list_facade, (DossiersListFacades.new user, param_list) assign :dossiers_list_facade, (DossiersListFacades.new user, param_list)
render render