app: rename new_user
to users
This commit is contained in:
parent
5127481cb1
commit
ded5b70444
53 changed files with 60 additions and 60 deletions
35
spec/views/users/dossiers/brouillon.html.haml_spec.rb
Normal file
35
spec/views/users/dossiers/brouillon.html.haml_spec.rb
Normal file
|
@ -0,0 +1,35 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'users/dossiers/brouillon.html.haml', type: :view do
|
||||
let(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, :with_notice, for_individual: true) }
|
||||
let(:dossier) { create(:dossier, :with_entreprise, :with_service, state: Dossier.states.fetch(:brouillon), procedure: procedure) }
|
||||
let(:footer) { view.content_for(:footer) }
|
||||
|
||||
before do
|
||||
sign_in dossier.user
|
||||
assign(:dossier, dossier)
|
||||
end
|
||||
|
||||
subject! { render }
|
||||
|
||||
it 'affiche le libellé de la démarche' do
|
||||
expect(rendered).to have_text(dossier.procedure.libelle)
|
||||
end
|
||||
|
||||
it 'affiche un lien vers la notice' do
|
||||
expect(rendered).to have_link("Guide de la démarche", href: url_for(procedure.notice))
|
||||
end
|
||||
|
||||
it 'affiche les boutons de validation' do
|
||||
expect(rendered).to have_selector('.send-wrapper')
|
||||
end
|
||||
|
||||
it 'prépare le footer' do
|
||||
expect(footer).to have_selector('footer')
|
||||
end
|
||||
|
||||
context 'quand la démarche ne comporte pas de notice' do
|
||||
let(:procedure) { create(:procedure) }
|
||||
it { is_expected.not_to have_link("Guide de la démarche") }
|
||||
end
|
||||
end
|
39
spec/views/users/dossiers/demande.html.haml_spec.rb
Normal file
39
spec/views/users/dossiers/demande.html.haml_spec.rb
Normal file
|
@ -0,0 +1,39 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'users/dossiers/demande.html.haml', type: :view do
|
||||
let(:procedure) { create(:procedure, :published, :with_two_type_de_piece_justificative, :with_type_de_champ, :with_type_de_champ_private) }
|
||||
let(:dossier) { create(:dossier, :en_construction, :with_entreprise, procedure: procedure) }
|
||||
|
||||
before do
|
||||
sign_in dossier.user
|
||||
assign(:dossier, dossier)
|
||||
end
|
||||
|
||||
subject! { render }
|
||||
|
||||
it 'renders the header' do
|
||||
expect(rendered).to have_text("Dossier nº #{dossier.id}")
|
||||
end
|
||||
|
||||
it 'renders the dossier infos' do
|
||||
expect(rendered).to have_text('Déposé le')
|
||||
expect(rendered).to have_text('Identité')
|
||||
expect(rendered).to have_text('Demande')
|
||||
expect(rendered).to have_text('Pièces jointes')
|
||||
end
|
||||
|
||||
context 'when the dossier is editable' do
|
||||
it { is_expected.to have_link('Modifier le dossier', href: modifier_dossier_path(dossier)) }
|
||||
end
|
||||
|
||||
context 'when the dossier is read-only' do
|
||||
let(:dossier) { create(:dossier, :en_instruction, :with_entreprise, procedure: procedure) }
|
||||
it { is_expected.not_to have_link('Modifier le dossier') }
|
||||
end
|
||||
|
||||
context 'when the dossier has no en_construction_at date' do
|
||||
let(:dossier) { create(:dossier, :with_entreprise, procedure: procedure) }
|
||||
|
||||
it { expect(rendered).not_to have_text('Déposé le') }
|
||||
end
|
||||
end
|
35
spec/views/users/dossiers/etablissement.html.haml_spec.rb
Normal file
35
spec/views/users/dossiers/etablissement.html.haml_spec.rb
Normal file
|
@ -0,0 +1,35 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'users/dossiers/etablissement.html.haml', type: :view do
|
||||
let(:etablissement) { create(:etablissement, :with_exercices) }
|
||||
let(:dossier) { create(:dossier, etablissement: etablissement) }
|
||||
let(:footer) { view.content_for(:footer) }
|
||||
|
||||
before do
|
||||
sign_in dossier.user
|
||||
assign(:dossier, dossier)
|
||||
end
|
||||
|
||||
subject! { render }
|
||||
|
||||
it 'affiche les informations de l’établissement' do
|
||||
expect(rendered).to have_text(etablissement.entreprise_raison_sociale)
|
||||
expect(rendered).to have_text(etablissement.siret)
|
||||
end
|
||||
|
||||
it 'n’affiche pas publiquement les derniers exercices comptables' do
|
||||
expect(rendered).not_to have_text(number_to_currency(etablissement.exercices.first.ca))
|
||||
end
|
||||
|
||||
context 'quand l’établissement est une association' do
|
||||
let(:etablissement) { create(:etablissement, :is_association) }
|
||||
|
||||
it 'affiche les informations de l’association' do
|
||||
expect(rendered).to have_text(etablissement.association_titre)
|
||||
end
|
||||
end
|
||||
|
||||
it 'prépare le footer' do
|
||||
expect(footer).to have_selector('footer')
|
||||
end
|
||||
end
|
26
spec/views/users/dossiers/identite.html.haml_spec.rb
Normal file
26
spec/views/users/dossiers/identite.html.haml_spec.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'users/dossiers/identite.html.haml', type: :view do
|
||||
let(:procedure) { create(:simple_procedure, for_individual: true) }
|
||||
let(:dossier) { create(:dossier, :with_entreprise, :with_service, state: Dossier.states.fetch(:brouillon), procedure: procedure) }
|
||||
|
||||
before do
|
||||
sign_in dossier.user
|
||||
assign(:dossier, dossier)
|
||||
end
|
||||
|
||||
subject! { render }
|
||||
|
||||
it 'has identity fields' do
|
||||
expect(rendered).to have_field('Prénom')
|
||||
expect(rendered).to have_field('Nom')
|
||||
end
|
||||
|
||||
context 'when the demarche asks for the birthdate' do
|
||||
let(:procedure) { create(:simple_procedure, for_individual: true, ask_birthday: true) }
|
||||
|
||||
it 'has a birthday field' do
|
||||
expect(rendered).to have_field('Date de naissance')
|
||||
end
|
||||
end
|
||||
end
|
87
spec/views/users/dossiers/index.html.haml_spec.rb
Normal file
87
spec/views/users/dossiers/index.html.haml_spec.rb
Normal file
|
@ -0,0 +1,87 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'users/dossiers/index.html.haml', type: :view do
|
||||
let(:user) { create(:user) }
|
||||
let(:dossier_brouillon) { create(:dossier, state: Dossier.states.fetch(:brouillon), user: user) }
|
||||
let(:dossier_en_construction) { create(:dossier, state: Dossier.states.fetch(:en_construction), user: user) }
|
||||
let(:user_dossiers) { [dossier_brouillon, dossier_en_construction] }
|
||||
let(:dossiers_invites) { [] }
|
||||
let(:current_tab) { 'mes-dossiers' }
|
||||
|
||||
before do
|
||||
allow(view).to receive(:new_demarche_url).and_return('#')
|
||||
allow(controller).to receive(:current_user) { user }
|
||||
assign(:user_dossiers, Kaminari.paginate_array(user_dossiers).page(1))
|
||||
assign(:dossiers_invites, Kaminari.paginate_array(dossiers_invites).page(1))
|
||||
assign(:dossiers, Kaminari.paginate_array(user_dossiers).page(1))
|
||||
assign(:current_tab, current_tab)
|
||||
render
|
||||
end
|
||||
|
||||
it 'affiche la liste des dossiers' do
|
||||
expect(rendered).to have_selector('.dossiers-table tbody tr', count: 2)
|
||||
end
|
||||
|
||||
it 'affiche les informations des dossiers' do
|
||||
dossier = user_dossiers.first
|
||||
expect(rendered).to have_text(dossier_brouillon.id)
|
||||
expect(rendered).to have_text(dossier_brouillon.procedure.libelle)
|
||||
expect(rendered).to have_link(dossier_brouillon.id, href: brouillon_dossier_path(dossier_brouillon))
|
||||
|
||||
expect(rendered).to have_text(dossier_en_construction.id)
|
||||
expect(rendered).to have_text(dossier_en_construction.procedure.libelle)
|
||||
expect(rendered).to have_link(dossier_en_construction.id, href: dossier_path(dossier_en_construction))
|
||||
end
|
||||
|
||||
context 'quand il n’y a aucun dossier' do
|
||||
let(:user_dossiers) { [] }
|
||||
let(:dossiers_invites) { [] }
|
||||
|
||||
it 'n’affiche pas la table' do
|
||||
expect(rendered).not_to have_selector('.dossiers-table')
|
||||
end
|
||||
|
||||
it 'affiche un message' do
|
||||
expect(rendered).to have_text('Aucun dossier')
|
||||
end
|
||||
end
|
||||
|
||||
context 'quand il n’y a pas de dossiers invités' do
|
||||
let(:dossiers_invites) { [] }
|
||||
|
||||
it 'affiche un titre adapté' do
|
||||
expect(rendered).to have_selector('h1', text: 'Mes dossiers')
|
||||
end
|
||||
|
||||
it 'n’affiche pas la barre d’onglets' do
|
||||
expect(rendered).not_to have_selector('ul.tabs')
|
||||
end
|
||||
end
|
||||
|
||||
context 'quand il y a des dossiers invités' do
|
||||
let(:dossiers_invites) { create_list(:dossier, 1) }
|
||||
|
||||
it 'affiche un titre adapté' do
|
||||
expect(rendered).to have_selector('h1', text: 'Dossiers')
|
||||
end
|
||||
|
||||
it 'affiche la barre d’onglets' do
|
||||
expect(rendered).to have_selector('ul.tabs')
|
||||
expect(rendered).to have_selector('ul.tabs li', count: 2)
|
||||
expect(rendered).to have_selector('ul.tabs li.active', count: 1)
|
||||
end
|
||||
end
|
||||
|
||||
context "quand le user n'a aucun feedback" do
|
||||
it "affiche le formulaire de satisfaction" do
|
||||
expect(rendered).to have_selector('#user-satisfaction', text: 'Que pensez-vous de la facilité d\'utilisation de ce service ?')
|
||||
end
|
||||
end
|
||||
|
||||
context "quand le user a un feedback" do
|
||||
let(:user) { create(:user, feedbacks: [build(:feedback)]) }
|
||||
it "n'affiche pas le formulaire de satisfaction" do
|
||||
expect(rendered).to_not have_selector('#user-satisfaction')
|
||||
end
|
||||
end
|
||||
end
|
28
spec/views/users/dossiers/show.html.haml_spec.rb
Normal file
28
spec/views/users/dossiers/show.html.haml_spec.rb
Normal file
|
@ -0,0 +1,28 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'users/dossiers/show.html.haml', type: :view do
|
||||
let(:dossier) { create(:dossier, :en_construction) }
|
||||
|
||||
before do
|
||||
sign_in dossier.user
|
||||
assign(:dossier, dossier)
|
||||
end
|
||||
|
||||
subject! { render }
|
||||
|
||||
it 'renders a summary of the dossier state' do
|
||||
expect(rendered).to have_text("Dossier nº #{dossier.id}")
|
||||
expect(rendered).to have_selector('.status-overview')
|
||||
end
|
||||
|
||||
context 'with messages' do
|
||||
let(:first_message) { create(:commentaire, body: 'Premier message') }
|
||||
let(:last_message) { create(:commentaire, body: 'Second message') }
|
||||
let(:dossier) { create(:dossier, :en_construction, commentaires: [first_message, last_message]) }
|
||||
|
||||
it 'displays the last message' do
|
||||
expect(rendered).not_to have_text(first_message.body)
|
||||
expect(rendered).to have_text(last_message.body)
|
||||
end
|
||||
end
|
||||
end
|
19
spec/views/users/dossiers/show/_header.html.haml_spec.rb
Normal file
19
spec/views/users/dossiers/show/_header.html.haml_spec.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
describe 'users/dossiers/show/header.html.haml', type: :view do
|
||||
let(:dossier) { create(:dossier, :en_construction, procedure: create(:procedure)) }
|
||||
|
||||
before do
|
||||
sign_in dossier.user
|
||||
end
|
||||
|
||||
subject! { render 'users/dossiers/show/header.html.haml', dossier: dossier }
|
||||
|
||||
it 'affiche les informations du dossier' do
|
||||
expect(rendered).to have_text(dossier.procedure.libelle)
|
||||
expect(rendered).to have_text("Dossier nº #{dossier.id}")
|
||||
expect(rendered).to have_text("en construction")
|
||||
|
||||
expect(rendered).to have_selector("ul.tabs")
|
||||
expect(rendered).to have_link("Résumé", href: dossier_path(dossier))
|
||||
expect(rendered).to have_link("Demande", href: demande_dossier_path(dossier))
|
||||
end
|
||||
end
|
|
@ -0,0 +1,93 @@
|
|||
describe 'users/dossiers/show/_status_overview.html.haml', type: :view do
|
||||
subject! { render 'users/dossiers/show/status_overview.html.haml', dossier: dossier }
|
||||
|
||||
matcher :have_timeline_item do |selector|
|
||||
match do |rendered|
|
||||
expect(rendered).to have_selector(item_selector(selector))
|
||||
end
|
||||
|
||||
chain :active do
|
||||
@active = true
|
||||
end
|
||||
|
||||
chain :inactive do
|
||||
@active = false
|
||||
end
|
||||
|
||||
def item_selector(selector)
|
||||
item_selector = ".status-timeline #{selector}"
|
||||
item_selector += '.active' if @active == true
|
||||
item_selector += ':not(.active)' if @active == false
|
||||
item_selector
|
||||
end
|
||||
end
|
||||
|
||||
context 'when brouillon' do
|
||||
let(:dossier) { create :dossier }
|
||||
|
||||
it 'renders the timeline (without the final states)' do
|
||||
expect(rendered).to have_timeline_item('.brouillon').active
|
||||
expect(rendered).to have_timeline_item('.en-construction').inactive
|
||||
expect(rendered).to have_timeline_item('.en-instruction').inactive
|
||||
expect(rendered).to have_timeline_item('.termine').inactive
|
||||
end
|
||||
|
||||
it { is_expected.to have_selector('.status-explanation .brouillon') }
|
||||
end
|
||||
|
||||
context 'when en construction' do
|
||||
let(:dossier) { create :dossier, :en_construction }
|
||||
|
||||
it 'renders the timeline (without the final states)' do
|
||||
expect(rendered).not_to have_timeline_item('.brouillon')
|
||||
expect(rendered).to have_timeline_item('.en-construction').active
|
||||
expect(rendered).to have_timeline_item('.en-instruction').inactive
|
||||
expect(rendered).to have_timeline_item('.termine').inactive
|
||||
end
|
||||
|
||||
it { is_expected.to have_selector('.status-explanation .en-construction') }
|
||||
end
|
||||
|
||||
context 'when en instruction' do
|
||||
let(:dossier) { create :dossier, :en_instruction }
|
||||
|
||||
it 'renders the timeline (without the final states)' do
|
||||
expect(rendered).not_to have_timeline_item('.brouillon')
|
||||
expect(rendered).to have_timeline_item('.en-construction').inactive
|
||||
expect(rendered).to have_timeline_item('.en-instruction').active
|
||||
expect(rendered).to have_timeline_item('.termine').inactive
|
||||
end
|
||||
|
||||
it { is_expected.to have_selector('.status-explanation .en-instruction') }
|
||||
end
|
||||
|
||||
context 'when accepté' do
|
||||
let(:dossier) { create :dossier, :accepte, :with_motivation }
|
||||
|
||||
it { is_expected.not_to have_selector('.status-timeline') }
|
||||
it { is_expected.to have_selector('.status-explanation .accepte') }
|
||||
it { is_expected.to have_text(dossier.motivation) }
|
||||
|
||||
context 'with attestation' do
|
||||
let(:dossier) { create :dossier, :accepte, :with_attestation }
|
||||
it { is_expected.to have_link(nil, href: attestation_dossier_path(dossier)) }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when refusé' do
|
||||
let(:dossier) { create :dossier, :refuse, :with_motivation }
|
||||
|
||||
it { is_expected.not_to have_selector('.status-timeline') }
|
||||
it { is_expected.to have_selector('.status-explanation .refuse') }
|
||||
it { is_expected.to have_text(dossier.motivation) }
|
||||
it { is_expected.to have_link(nil, href: messagerie_dossier_url(dossier, anchor: 'new_commentaire')) }
|
||||
end
|
||||
|
||||
context 'when classé sans suite' do
|
||||
let(:dossier) { create :dossier, :sans_suite, :with_motivation }
|
||||
|
||||
it { is_expected.not_to have_selector('.status-timeline') }
|
||||
it { is_expected.to have_selector('.status-explanation .sans-suite') }
|
||||
it { is_expected.to have_text(dossier.motivation) }
|
||||
end
|
||||
end
|
16
spec/views/users/dossiers/siret.html.haml_spec.rb
Normal file
16
spec/views/users/dossiers/siret.html.haml_spec.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'users/dossiers/siret.html.haml', type: :view do
|
||||
let(:dossier) { create(:dossier) }
|
||||
|
||||
before do
|
||||
sign_in dossier.user
|
||||
assign(:dossier, dossier)
|
||||
end
|
||||
|
||||
subject! { render }
|
||||
|
||||
it 'affiche le formulaire de SIRET' do
|
||||
expect(rendered).to have_field('Numéro SIRET')
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue