Updated test for new user status UI

This commit is contained in:
Xavier J 2016-08-22 16:10:48 +02:00
parent 19ee3af273
commit b661a2eb38
12 changed files with 269 additions and 108 deletions

View file

@ -132,7 +132,7 @@ group :development, :test do
gem "nyan-cat-formatter"
gem 'parallel_tests'
gem 'parallel_tests', '~> 1.9.0'
gem 'brakeman', require: false
# Deploy

View file

@ -115,7 +115,7 @@ GEM
concurrent-ruby (1.0.2)
crack (0.4.2)
safe_yaml (~> 1.0.0)
css_splitter (0.4.4)
css_splitter (0.4.5)
sprockets (>= 2.0.0)
database_cleaner (1.4.1)
debug_inspector (0.0.2)
@ -395,7 +395,7 @@ GEM
openstack (2.0.2)
json
orm_adapter (0.5.0)
parallel (1.6.1)
parallel (1.9.0)
parallel_tests (1.9.0)
parallel
parser (2.2.2.2)
@ -510,13 +510,13 @@ GEM
sexp_processor (~> 4.1)
rubyzip (1.1.7)
safe_yaml (1.0.4)
sass (3.4.16)
sass-rails (5.0.3)
railties (>= 4.0.0, < 5.0)
sass (3.4.22)
sass-rails (5.0.6)
railties (>= 4.0.0, < 6)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (~> 1.1)
tilt (>= 1.1, < 3)
sdoc (0.4.1)
json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0)
@ -569,7 +569,7 @@ GEM
ref
thor (0.19.1)
thread_safe (0.3.5)
tilt (1.4.1)
tilt (2.0.5)
timecop (0.7.3)
trollop (2.1.2)
turbolinks (2.5.3)
@ -662,7 +662,7 @@ DEPENDENCIES
nyan-cat-formatter
openid_connect
openstack
parallel_tests
parallel_tests (~> 1.9.0)
pg
poltergeist
pry-byebug

View file

@ -65,12 +65,12 @@ class DossiersListFacades
end
def a_traiter_total
service.waiting_for_gestionnaire.count if gestionnaire?
return service.waiting_for_gestionnaire.count if gestionnaire?
service.waiting_for_user.count if user?
end
def en_attente_total
service.waiting_for_user.count if gestionnaire?
return service.waiting_for_user.count if gestionnaire?
service.waiting_for_gestionnaire.count if user?
end

View file

@ -41,6 +41,7 @@ class Dossier < ActiveRecord::Base
NOUVEAUX = %w(initiated)
WAITING_FOR_GESTIONNAIRE = %w(updated)
WAITING_FOR_USER = %w(replied validated)
WAITING_FOR_USER_WITHOUT_VALIDATED = %w(replied)
VALIDES = %w(validated)
DEPOSES = %w(submitted)
EN_INSTRUCTION = %w(submitted received)
@ -150,6 +151,10 @@ class Dossier < ActiveRecord::Base
WAITING_FOR_USER.include?(state)
end
def waiting_for_user_without_validated?
WAITING_FOR_USER_WITHOUT_VALIDATED.include?(state)
end
def deposes?
DEPOSES.include?(state)
end
@ -182,6 +187,10 @@ class Dossier < ActiveRecord::Base
where(state: WAITING_FOR_USER, archived: false).order("updated_at #{order}")
end
def self.waiting_for_user_without_validated order = 'ASC'
where(state: WAITING_FOR_USER_WITHOUT_VALIDATED, archived: false).order("updated_at #{order}")
end
def self.valides order = 'ASC'
where(state: VALIDES, archived: false).order("updated_at #{order}")
end

View file

@ -23,7 +23,7 @@ class DossiersListUserService
end
def waiting_for_user
@waiting_for_user ||= @current_devise_profil.dossiers.waiting_for_user
@waiting_for_user ||= @current_devise_profil.dossiers.waiting_for_user_without_validated
end
def invite

View file

@ -6,14 +6,25 @@
.fa.fa-info-circle.text-info{style:'font-size: 2em; margin-top: 20%'}
.col-md-11.col-lg-11
-if dossiers_list_facade.liste == 'nouveaux'
plop
Tous les dossiers présents dans cette liste sont ceux qui
%b
n'ont jamais été ouvert par votre service.
Il attende une première lecture et intervention de votre part.
-elsif dossiers_list_facade.liste == 'a_traiter'
plop
Tous les dossiers présents dans cette liste sont ceux qui
%b
attendent une action de votre part.
Cela peut être par exemple une demande client ou une relecture pour validation de complétude.
-elsif dossiers_list_facade.liste == 'en_attente'
plop
Tous les dossiers présents dans cette liste sont ceux qui requière une action de la part de l'usager. À priori, vous n'avez donc pas d'intervention particulière à réaliser.
-elsif dossiers_list_facade.liste == 'deposes'
plop
Tous les dossiers présents dans cette liste ont été
%b
officiellement déposé par l'usager pour instruction.
Il faut donc que vous confirmiez par "accusé de réception" la bonne réception de toutes les informations et documents demandés avant instruction finale.
-elsif dossiers_list_facade.liste == 'a_instruire'
plop
Tous les dossiers présents dans cette liste sont à instruire. Ceux sont tous les dossiers
%b
qui ont reçu bonne réception.
-elsif dossiers_list_facade.liste == 'termine'
plop
Tous les dossiers présents dans cette liste sont considérés comme cloturé car ils ont tous reçu un verdict final qui peut être "Validé", "Refusé" ou "Sans suite".

View file

@ -6,7 +6,7 @@
%li{ class: @dossiers_list_facade.nouveaux_class }
%a{:href => "#{url_for users_dossiers_path(liste: 'nouveaux')}", 'data-toggle' => :tooltip, title: 'Les nouveaux dossiers qui n\'ont pas encore été vus par votre accompagnateur.'}
%h5.text-info
= "Nouveau"
= "Nouveaux"
.badge.progress-bar-info
= @dossiers_list_facade.nouveaux_total

View file

@ -4,7 +4,21 @@ feature 'on click on tabs button' do
let(:administrateur) { create(:administrateur) }
let(:gestionnaire) { create(:gestionnaire, administrateurs: [administrateur]) }
let(:procedure) { create :procedure, administrateur: administrateur }
before do
create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated')
create(:dossier, :with_entreprise, procedure: procedure, state: 'replied')
create(:dossier, :with_entreprise, procedure: procedure, state: 'updated')
create(:dossier, :with_entreprise, procedure: procedure, state: 'validated')
create(:dossier, :with_entreprise, procedure: procedure, state: 'submitted')
create(:dossier, :with_entreprise, procedure: procedure, state: 'received')
create(:dossier, :with_entreprise, procedure: procedure, state: 'closed')
create(:dossier, :with_entreprise, procedure: procedure, state: 'refused')
create(:dossier, :with_entreprise, procedure: procedure, state: 'without_continuation')
create :assign_to, gestionnaire: gestionnaire, procedure: procedure
login_as gestionnaire, scope: :gestionnaire
end
@ -12,7 +26,7 @@ feature 'on click on tabs button' do
context 'when he click on tabs nouveaux' do
before do
visit backoffice_dossiers_url(liste: :nouveaux)
page.click_on 'Nouveaux 0'
page.click_on 'Nouveaux 1'
end
scenario 'it redirect to backoffice dossier termine' do
@ -23,7 +37,7 @@ feature 'on click on tabs button' do
context 'when he click on tabs a traite' do
before do
visit backoffice_dossiers_url(liste: :a_traiter)
page.click_on 'Action requise 0'
page.click_on 'Action requise 1'
end
scenario 'it redirect to backoffice dossier termine' do
@ -34,7 +48,7 @@ feature 'on click on tabs button' do
context 'when he click on tabs en attente' do
before do
visit backoffice_dossiers_url(liste: :en_attente)
page.click_on 'Attente usager 0'
page.click_on 'Attente usager 2'
end
scenario 'it redirect to backoffice dossier en attente' do
@ -44,8 +58,8 @@ feature 'on click on tabs button' do
context 'when he click on tabs a receptionner' do
before do
visit backoffice_dossiers_url(liste: :nouveaux)
page.click_on 'À réceptionner 0'
visit backoffice_dossiers_url(liste: :deposes)
page.click_on 'À réceptionner 1'
end
scenario 'it redirect to backoffice dossier a_receptionner' do
@ -56,7 +70,7 @@ feature 'on click on tabs button' do
context 'when he click on tabs a instruire' do
before do
visit backoffice_dossiers_url(liste: :a_instruire)
page.click_on 'À instruire 0'
page.click_on 'À instruire 1'
end
scenario 'it redirect to backoffice dossier termine' do
@ -67,7 +81,7 @@ feature 'on click on tabs button' do
context 'when he click on tabs termine' do
before do
visit backoffice_dossiers_url(liste: :termine)
page.click_on 'Terminé 0'
page.click_on 'Terminé 3'
end
scenario 'it redirect to backoffice dossier termine' do

View file

@ -8,7 +8,7 @@ feature 'user access to the list of his dossier' do
let!(:dossier2) { create(:dossier, :with_entreprise) }
before do
dossier1.update_column(:updated_at, "19/07/2016 15:35".to_time)
dossier1.update_column(:updated_at, "19/07/2052 15:35".to_time)
dossier1.entreprise.update_column(:raison_sociale, 'PLOP')
last_updated_dossier.entreprise.update_column(:raison_sociale, 'PLIP')

View file

@ -0,0 +1,102 @@
require 'spec_helper'
feature 'on click on tabs button' do
let(:user) { create :user }
let(:dossier_invite) { create(:dossier, :with_entreprise, user: create(:user), state: 'initiated') }
before do
create(:dossier, :with_entreprise, user: user, state: 'initiated')
create(:dossier, :with_entreprise, user: user, state: 'replied')
create(:dossier, :with_entreprise, user: user, state: 'updated')
create(:dossier, :with_entreprise, user: user, state: 'validated')
create(:dossier, :with_entreprise, user: user, state: 'submitted')
create(:dossier, :with_entreprise, user: user, state: 'received')
create(:dossier, :with_entreprise, user: user, state: 'closed')
create(:dossier, :with_entreprise, user: user, state: 'refused')
create(:dossier, :with_entreprise, user: user, state: 'without_continuation')
create :invite, dossier: dossier_invite, user: user
login_as user, scope: :user
end
context 'when user is logged in' do
context 'when he click on tabs nouveaux' do
before do
visit users_dossiers_url(liste: :nouveaux)
page.click_on 'Nouveaux 1'
end
scenario 'it redirect to users dossier termine' do
expect(page).to have_css('#users_index')
end
end
context 'when he click on tabs a traite' do
before do
visit users_dossiers_url(liste: :a_traiter)
page.click_on 'Action requise 1'
end
scenario 'it redirect to users dossier termine' do
expect(page).to have_css('#users_index')
end
end
context 'when he click on tabs en attente' do
before do
visit users_dossiers_url(liste: :en_attente)
page.click_on 'Etude en cours 1'
end
scenario 'it redirect to users dossier en attente' do
expect(page).to have_css('#users_index')
end
end
context 'when he click on tabs a deposes' do
before do
visit users_dossiers_url(liste: :valides)
page.click_on 'À déposer 1'
end
scenario 'it redirect to users dossier deposes' do
expect(page).to have_css('#users_index')
end
end
context 'when he click on tabs en instruction' do
before do
visit users_dossiers_url(liste: :en_instruction)
page.click_on 'En instruction 2'
end
scenario 'it redirect to users dossier termine' do
expect(page).to have_css('#users_index')
end
end
context 'when he click on tabs termine' do
before do
visit users_dossiers_url(liste: :termine)
page.click_on 'Cloturé 3'
end
scenario 'it redirect to users dossier termine' do
expect(page).to have_css('#users_index')
end
end
context 'when he click on tabs invitation' do
before do
visit users_dossiers_url(liste: :invite)
page.click_on 'Invitation 1'
end
scenario 'it redirect to users dossier invites' do
expect(page).to have_css('#users_index')
end
end
end
end

View file

@ -175,7 +175,7 @@ describe Procedure do
end
it 'is correctly set in ProcedurePath table' do
expect(ProcedurePath.where(path: procedure.path).count.to eq(1)
expect(ProcedurePath.where(path: procedure.path).count).to eq(1)
expect(procedure_path.procedure_id).to eq(procedure.id)
expect(procedure_path.administrateur_id).to eq(procedure.administrateur_id)
end
@ -214,6 +214,5 @@ describe Procedure do
subject { procedure.total_dossier }
it { is_expected.to eq 2 }
end
end

View file

@ -3,118 +3,144 @@ require 'spec_helper'
describe 'users/dossiers/index.html.haml', type: :view do
let(:user) { create(:user) }
let!(:dossier) { create(:dossier, :with_entreprise, user: user, state: 'initiated').decorate }
let!(:dossier_2) { create(:dossier, :with_entreprise, user: user, state: 'replied').decorate }
let!(:dossier_3) { create(:dossier, :with_entreprise, user: user, state: 'replied').decorate }
let!(:dossier_termine) { create(:dossier, :with_entreprise, user: user, state: 'closed').decorate }
let!(:decorate_dossier_initiated) { create(:dossier, :with_entreprise, user: user, state: 'initiated').decorate }
let!(:decorate_dossier_replied) { create(:dossier, :with_entreprise, user: user, state: 'replied').decorate }
let!(:decorate_dossier_updated) { create(:dossier, :with_entreprise, user: user, state: 'updated').decorate }
let!(:decorate_dossier_validated) { create(:dossier, :with_entreprise, user: user, state: 'validated').decorate }
let!(:decorate_dossier_submitted) { create(:dossier, :with_entreprise, user: user, state: 'submitted').decorate }
let!(:decorate_dossier_received) { create(:dossier, :with_entreprise, user: user, state: 'received').decorate }
let!(:decorate_dossier_closed) { create(:dossier, :with_entreprise, user: user, state: 'closed').decorate }
let!(:decorate_dossier_refused) { create(:dossier, :with_entreprise, user: user, state: 'refused').decorate }
let!(:decorate_dossier_without_continuation) { create(:dossier, :with_entreprise, user: user, state: 'without_continuation').decorate }
let!(:decorate_dossier_invite) { create(:dossier, :with_entreprise, user: create(:user), state: 'initiated').decorate }
before do
dossier_2.entreprise.update_column(:raison_sociale, 'plip')
dossier_2.entreprise.update_column(:raison_sociale, 'plop')
dossier_3.entreprise.update_column(:raison_sociale, 'plup')
dossier_termine.entreprise.update_column(:raison_sociale, 'plap')
decorate_dossier_replied.entreprise.update_column(:raison_sociale, 'plap')
decorate_dossier_updated.entreprise.update_column(:raison_sociale, 'plep')
decorate_dossier_validated.entreprise.update_column(:raison_sociale, 'plip')
decorate_dossier_submitted.entreprise.update_column(:raison_sociale, 'plop')
decorate_dossier_received.entreprise.update_column(:raison_sociale, 'plup')
decorate_dossier_closed.entreprise.update_column(:raison_sociale, 'plyp')
decorate_dossier_refused.entreprise.update_column(:raison_sociale, 'plzp')
decorate_dossier_without_continuation.entreprise.update_column(:raison_sociale, 'plnp')
create :invite, dossier: decorate_dossier_invite, user: user
end
describe 'params liste is a_traiter' do
let(:dossiers_list) { user.dossiers.waiting_for_user('DESC') }
shared_examples 'check_tab_content' do
before do
sign_in user
assign :dossiers_list_facade, (DossiersListFacades.new user, liste)
assign(:dossiers, (smart_listing_create :dossiers,
user.dossiers.waiting_for_user('DESC'),
dossiers_to_display,
partial: "users/dossiers/list",
array: true))
assign(:liste, 'a_traiter')
assign(:dossiers_a_traiter_total, '1')
assign(:dossiers_en_attente_total, '2')
assign(:dossiers_termine_total, '1')
render
end
subject { rendered }
it { is_expected.to have_css('#users_index') }
describe 'dossier replied is present' do
it { is_expected.to have_content(dossier_2.procedure.libelle) }
it { is_expected.to have_content(dossier_2.entreprise.raison_sociale) }
it { is_expected.to have_content(dossier_2.display_state) }
it { is_expected.to have_content(dossier_2.last_update) }
describe 'columns' do
it { is_expected.to have_content(decorate_dossier_at_check.procedure.libelle) }
it { is_expected.to have_content(decorate_dossier_at_check.entreprise.raison_sociale) }
it { is_expected.to have_content(decorate_dossier_at_check.display_state) }
it { is_expected.to have_content(decorate_dossier_at_check.last_update) }
end
describe 'dossier initiated and closed are not present' do
it { is_expected.not_to have_content(dossier.entreprise.raison_sociale) }
it { is_expected.not_to have_content(dossier_termine.entreprise.raison_sociale) }
end
it { expect(dossiers_to_display.count).to eq total_dossiers }
describe 'badges on tabs' do
it { is_expected.to have_content('À traiter 1') }
it { is_expected.to have_content('En attente 2') }
it { is_expected.to have_content('Terminé 1') }
describe 'active tab' do
it { is_expected.to have_selector(active_class) }
end
end
describe 'params liste is en_attente' do
let(:dossiers_list) { user.dossiers.waiting_for_gestionnaire('DESC') }
describe 'on tab nouveaux' do
let(:total_dossiers) { 1 }
let(:active_class) { '.active .text-info' }
let(:dossiers_to_display) { user.dossiers.nouveaux }
let(:liste) { 'nouveaux' }
before do
sign_in user
assign(:dossiers, (smart_listing_create :dossiers,
user.dossiers.waiting_for_gestionnaire('DESC'),
partial: "users/dossiers/list",
array: true))
assign(:liste, 'en_attente')
render
end
subject { rendered }
it { is_expected.to have_css('#users_index') }
describe 'dossier initiated is present' do
it { is_expected.to have_content(dossier.procedure.libelle) }
it { is_expected.to have_content(dossier.entreprise.raison_sociale) }
it { is_expected.to have_content(dossier.display_state) }
it { is_expected.to have_content(dossier.last_update) }
end
describe 'dossier replied and closed are not present' do
it { is_expected.not_to have_content(dossier_2.entreprise.raison_sociale) }
it { is_expected.not_to have_content(dossier_termine.entreprise.raison_sociale) }
it_behaves_like 'check_tab_content' do
let(:decorate_dossier_at_check) { decorate_dossier_initiated }
end
end
describe 'params liste is termine' do
let(:dossiers_list) { user.dossiers.termine('DESC') }
describe 'on tab action requise' do
let(:total_dossiers) { 1 }
let(:active_class) { '.active .text-danger' }
let(:dossiers_to_display) { user.dossiers.waiting_for_user_without_validated }
let(:liste) { 'a_traiter' }
before do
sign_in user
assign(:dossiers, (smart_listing_create :dossiers,
user.dossiers.termine('DESC'),
partial: "users/dossiers/list",
array: true))
assign(:liste, 'termine')
render
it_behaves_like 'check_tab_content' do
let(:decorate_dossier_at_check) { decorate_dossier_replied }
end
end
subject { rendered }
describe 'on tab etude en cours' do
let(:total_dossiers) { 1 }
let(:active_class) { '.active .text-default' }
let(:dossiers_to_display) { user.dossiers.waiting_for_gestionnaire }
let(:liste) { 'en_attente' }
it { is_expected.to have_css('#users_index') }
describe 'dossier termine is present' do
it { is_expected.to have_content(dossier_termine.procedure.libelle) }
it { is_expected.to have_content(dossier_termine.entreprise.raison_sociale) }
it { is_expected.to have_content(dossier_termine.display_state) }
it { is_expected.to have_content(dossier_termine.last_update) }
it_behaves_like 'check_tab_content' do
let(:decorate_dossier_at_check) { decorate_dossier_updated }
end
end
describe 'dossier initiated and replied are not present' do
it { is_expected.not_to have_content(dossier.entreprise.raison_sociale) }
it { is_expected.not_to have_content(dossier_2.entreprise.raison_sociale) }
describe 'on tab etude a deposer' do
let(:total_dossiers) { 1 }
let(:active_class) { '.active .text-purple' }
let(:dossiers_to_display) { user.dossiers.valides }
let(:liste) { 'valides' }
it_behaves_like 'check_tab_content' do
let(:decorate_dossier_at_check) { decorate_dossier_validated }
end
end
describe 'on tab etude en instruction' do
let(:total_dossiers) { 2 }
let(:active_class) { '.active .text-default' }
let(:dossiers_to_display) { user.dossiers.en_instruction }
let(:liste) { 'en_instruction' }
it_behaves_like 'check_tab_content' do
let(:decorate_dossier_at_check) { decorate_dossier_submitted }
end
it_behaves_like 'check_tab_content' do
let(:decorate_dossier_at_check) { decorate_dossier_received }
end
end
describe 'on tab etude termine' do
let(:total_dossiers) { 3 }
let(:active_class) { '.active .text-success' }
let(:dossiers_to_display) { user.dossiers.termine }
let(:liste) { 'termine' }
it_behaves_like 'check_tab_content' do
let(:decorate_dossier_at_check) { decorate_dossier_closed }
end
it_behaves_like 'check_tab_content' do
let(:decorate_dossier_at_check) { decorate_dossier_refused }
end
it_behaves_like 'check_tab_content' do
let(:decorate_dossier_at_check) { decorate_dossier_without_continuation }
end
end
describe 'on tab etude invite' do
let(:total_dossiers) { 1 }
let(:active_class) { '.active .text-warning' }
let(:dossiers_to_display) { user.invites }
let(:liste) { 'invite' }
it_behaves_like 'check_tab_content' do
let(:decorate_dossier_at_check) { decorate_dossier_invite }
end
end
end