From a9109f8b2bee9be2e0b48552e566255b11b2a589 Mon Sep 17 00:00:00 2001 From: Xavier J Date: Thu, 24 Sep 2015 10:17:59 +0200 Subject: [PATCH 1/3] =?UTF-8?q?Nouvelle=20organisation=20de=20la=20page=20?= =?UTF-8?q?r=C3=A9capitulatif?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/assets/stylesheets/application.scss | 6 -- app/assets/stylesheets/recapiitulatif.scss | 9 +++ app/controllers/recapitulatif_controller.rb | 1 + app/decorators/dossier_decorator.rb | 21 +++++++ app/views/backoffice/dossiers/show.html.haml | 30 +--------- app/views/dossiers/_infos_dossier.html.haml | 60 ++++++++++--------- .../dossiers/_pieces_justificatives.html.haml | 30 ++++++++++ .../_commentaires_flux.html.haml | 40 ++++++------- app/views/recapitulatif/show.html.haml | 35 +++++------ spec/decorators/dossier_decorator_spec.rb | 40 +++++++++++++ spec/factories/dossier.rb | 1 + .../_commentaires_flux_spec.rb | 45 -------------- spec/spec_helper.rb | 1 + spec/views/dossiers/_infos_dossier_spec.rb | 25 +++++++- .../recapitulatif/_commentaires_flux_spec.rb | 47 +++++++++++++++ 15 files changed, 242 insertions(+), 149 deletions(-) create mode 100644 app/assets/stylesheets/recapiitulatif.scss create mode 100644 app/views/dossiers/_pieces_justificatives.html.haml delete mode 100644 spec/features/recapitulatif_page/_commentaires_flux_spec.rb create mode 100644 spec/views/recapitulatif/_commentaires_flux_spec.rb diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 5df9fdb80..12918330d 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -46,13 +46,7 @@ body { } .description { - border-color: rgba(200, 200, 200, 0.6); - border-style: solid; - border-radius: 5px; - border-width: 1px; padding: 10px; - background-color: rgb(245, 245, 245); - margin-top: 10px; } .btn-file { diff --git a/app/assets/stylesheets/recapiitulatif.scss b/app/assets/stylesheets/recapiitulatif.scss new file mode 100644 index 000000000..e57421a56 --- /dev/null +++ b/app/assets/stylesheets/recapiitulatif.scss @@ -0,0 +1,9 @@ +#infos_dossier{ + background-color:rgba(248,248,255,0.8); + padding-left:13%; + padding-right:13%; + padding-bottom:20px; + padding-top:15px; + margin-left:-13%; + margin-right:-13%; +} \ No newline at end of file diff --git a/app/controllers/recapitulatif_controller.rb b/app/controllers/recapitulatif_controller.rb index 194cd0f0e..23507f618 100644 --- a/app/controllers/recapitulatif_controller.rb +++ b/app/controllers/recapitulatif_controller.rb @@ -2,6 +2,7 @@ class RecapitulatifController < ApplicationController def show @dossier = Dossier.find(params[:dossier_id]) @dossier = @dossier.decorate + @procedure = @dossier.procedure # mettre dans le modele @commentaires = @dossier.commentaires.order(created_at: :desc) diff --git a/app/decorators/dossier_decorator.rb b/app/decorators/dossier_decorator.rb index c3c99e64e..aa53082d3 100644 --- a/app/decorators/dossier_decorator.rb +++ b/app/decorators/dossier_decorator.rb @@ -10,4 +10,25 @@ class DossierDecorator < Draper::Decorator def last_update updated_at.localtime.strftime('%d/%m/%Y %H:%M') end + + def state_fr + case state + when 'draft' + 'Brouillon' + when 'proposed' + 'Proposé' + when 'reply' + 'Répondu' + when 'updated' + 'Mis à jour' + when 'confirmed' + 'Validé' + when 'deposited' + 'Déposé' + when 'processed' + 'Traité' + else + fail 'State not valid' + end + end end diff --git a/app/views/backoffice/dossiers/show.html.haml b/app/views/backoffice/dossiers/show.html.haml index 55c87ffb9..66ca14431 100644 --- a/app/views/backoffice/dossiers/show.html.haml +++ b/app/views/backoffice/dossiers/show.html.haml @@ -13,35 +13,7 @@ %br .content.row - #map_qp.col-lg-6.col-md-6{style: 'height:500px'} - #pieces_justificatives.col-lg-6.col-md-6 - %h3.text-info Liste des pièces justificatives - %br - %table.table - -if @procedure.lien_demarche != nil - %tr{id: "piece_justificative_0"} - %th{class:'col-lg-6'} - ='CERFA' - %td.col-lg-4.col-md-4 - - if !@dossier.cerfa.empty? - %a{ href: "#{@dossier.cerfa.content}", target: '_blank' } Consulter - - else - = 'Pièce non fournie' - - - @dossier.pieces_justificatives.each do |piece_justificative| - %tr{ id: "piece_justificative_#{piece_justificative.type}" } - %th.col-lg-6 - = piece_justificative.libelle - %td.col-lg-4.col-md-4 - - if piece_justificative.api_entreprise - %a{ href: '' } Récupérer - - elsif !piece_justificative.empty? - %a{ href: "#{piece_justificative.content}", target: '_blank' } Consulter - - else - = 'Pièce non fournie' - - = render partial: '/carte/carte_sources_CSS' -= render partial: '/carte/carte_sources_JS_backend' + =render partial: '/dossiers/pieces_justificatives' %br = render partial: '/recapitulatif/commentaires_flux' diff --git a/app/views/dossiers/_infos_dossier.html.haml b/app/views/dossiers/_infos_dossier.html.haml index 7647d48a1..634639366 100644 --- a/app/views/dossiers/_infos_dossier.html.haml +++ b/app/views/dossiers/_infos_dossier.html.haml @@ -1,9 +1,30 @@ = javascript_include_tag "https://code.highcharts.com/highcharts.js", "chartkick" -.row#infos_dossier - .col-md-6 - %h4.text-info - = @dossier.nom_projet - %div + +#infos_dossier + %div.row + .col-lg-6.col-md-6 + %h3.text-info + = @dossier.nom_projet + + %br + %div.row + .col-lg-6.col-md-6 + %h4 Montant total + %p{style:'margin-left:5%'} + =number_to_currency(@dossier.montant_projet.to_f, :unit => " ", :separator => ",", :delimiter => " ") + !='€' + + .col-lg-6.col-md-6 + %h4 Début du projet souhaité + %p{style:'margin-left:5%'} + = @dossier.date_fr + %div.row + .col-lg-6.col-md-6 + %h4 Montant souhaité + %p{style:'margin-left:5%'} + =number_to_currency(@dossier.montant_aide_demande.to_f, :unit => " ", :separator => ",", :delimiter => " ") + !='€' + %br .description - begin - @dossier.description.split(/(?:\n\r?|\r\n?')/).each do |line| @@ -11,28 +32,11 @@ %br - rescue ='' - %br - .col-lg-6.col-md-6 - %h4 Montant total - %p - =number_to_currency(@dossier.montant_projet.to_f, :unit => " ", :separator => ",", :delimiter => " ") - !='€' - - .col-lg-6.col-md-6 - %h4 Début du projet souhaité - %p - = @dossier.date_fr - - - / -if !request.url.include?('admin') - - unless gestionnaire_signed_in? - .col-lg-6.col-md-6 - %br - %br - %a#modif_description{href: "/dossiers/#{@dossier.id}/description?back_url=recapitulatif"} Modifier la description - - - .col-md-6 - = pie_chart({"Montant à charge #{(100 - @dossier.montant_aide_demande.to_f/@dossier.montant_projet.to_f*100).round(2)}%" => (@dossier.montant_projet.to_f - @dossier.montant_aide_demande.to_f), "Montant souhaité #{(@dossier.montant_aide_demande.to_f/@dossier.montant_projet.to_f*100).round(2)}%" => @dossier.montant_aide_demande}) + .col-lg-6.col-md-6 + =render partial: '/dossiers/pieces_justificatives' + -#= pie_chart({"Montant à charge #{(100 - @dossier.montant_aide_demande.to_f/@dossier.montant_projet.to_f*100).round(2)}%" => (@dossier.montant_projet.to_f - @dossier.montant_aide_demande.to_f), "Montant souhaité #{(@dossier.montant_aide_demande.to_f/@dossier.montant_projet.to_f*100).round(2)}%" => @dossier.montant_aide_demande}) + %div.row{style: 'text-align:right'} + %a#maj_infos.btn.btn-info{href: "/dossiers/#{@dossier.id}/description?back_url=recapitulatif"} + = 'Editer mon dossier' \ No newline at end of file diff --git a/app/views/dossiers/_pieces_justificatives.html.haml b/app/views/dossiers/_pieces_justificatives.html.haml new file mode 100644 index 000000000..20e89423d --- /dev/null +++ b/app/views/dossiers/_pieces_justificatives.html.haml @@ -0,0 +1,30 @@ +#pieces_justificatives + %h3.text-info Liste des pièces justificatives + %br + %table.table + -if @procedure.lien_demarche != nil + %tr{id: "piece_justificative_0"} + %th{class:'col-lg-6'} + ='CERFA' + -if @procedure.lien_demarche != nil + %a{style:'font-size:0.9em; padding-left:3px', id: 'lien_cerfa' ,href: "#{@procedure.lien_demarche}", :target => '_blank'} Lien CERFA + %td.col-lg-6.col-md-6 + - if !@dossier.cerfa.empty? + - if user_signed_in? + = 'Pièce fournie' + - elsif gestionnaire_signed_in? + %a{ href: "#{@dossier.cerfa.content}", target: '_blank' } Consulter + - else + = 'Pièce non fournie' + + - @dossier.pieces_justificatives.each do |piece_justificative| + %tr{ id: "piece_justificative_#{piece_justificative.type}" } + %th.col-lg-6 + = piece_justificative.libelle + %td.col-lg-6.col-md-6 + - if piece_justificative.api_entreprise + %span.text-success Nous l'avons récupéré pour vous. + - elsif !piece_justificative.empty? + %a{ href: "#{piece_justificative.content}", target: '_blank' } Consulter + - else + = 'Pièce non fournie' diff --git a/app/views/recapitulatif/_commentaires_flux.html.haml b/app/views/recapitulatif/_commentaires_flux.html.haml index 62bd43289..a374cfdbf 100644 --- a/app/views/recapitulatif/_commentaires_flux.html.haml +++ b/app/views/recapitulatif/_commentaires_flux.html.haml @@ -1,24 +1,18 @@ -.content#commentaires_flux - %h3 Commentaires - - %div{style: 'margin-left:3%; width:80%'} - -@commentaires.each do |com| - %span.text-info#email_contact{style: 'font-weight:bold'} - =com.email - %span#created_at - \- - =com.created_at_fr - %br - .description#body - =com.body - %br - - %h4{style: 'margin-bottom:2%'} Nouveau +.content#commentaires_flux{style:'width:100%;'} + %div#commentaire_new{style: 'width:80%; margin-left:auto; margin-right:auto'} = form_tag(url_for({ controller: :commentaires, action: :create, dossier_id: @dossier.id }), class: 'form-inline', method: 'POST') do - %input.form-control{:type => 'text', style: 'width: 30%; margin-bottom:2%', :id => 'email_commentaire', :name => 'email_commentaire', :value => @commentaire_email} - %textarea.form-control{:id => 'texte_commentaire', :name => 'texte_commentaire', style: 'width: 100%; margin-bottom:2%', rows: '5', maxlength: '255'} - %br - %input.form-control.btn.btn-success{:type => 'submit', :value => 'Poster', style: 'float:right'} -%br -%br -%br \ No newline at end of file + %textarea.form-control{id: 'texte_commentaire', name: 'texte_commentaire', style: 'width: 100%; margin-bottom:2%', rows: '5', maxlength: '255', placeholder:"Dialoguer avec votre interlocuteur privilégié en charge de votre dossier."} + %input.form-control.btn.btn-primary{:type => 'submit', :value => 'Poster', style: 'float:right'} + %br + %br + + -@commentaires.each do |com| + %span.text-info#email_contact{style: 'font-weight:bold'} + =com.email + %span#created_at + \- + =com.created_at_fr + %br + .description#body + =com.body + %br diff --git a/app/views/recapitulatif/show.html.haml b/app/views/recapitulatif/show.html.haml index 571490579..400b8e6b0 100644 --- a/app/views/recapitulatif/show.html.haml +++ b/app/views/recapitulatif/show.html.haml @@ -1,24 +1,25 @@ -%h2 - ='Récapitulatif' +%div.row + %div.col-md-2.col-lg-2 + %h2 + ='Récapitulatif' + + %div.col-md-8.col-lg-8 + + %div.col-md-2.col-lg-2 + %h2#dossier_id{:class => 'text-info', :style => 'text-align:right; margin-bottom:15px'} + = "Dossier n°#{@dossier.id}" + -#%h3{:class => 'text-success', :style => 'text-align:right'} + -# = @dossier.state_fr + - unless gestionnaire_signed_in? + %button#action_button.btn.btn-success + = 'Soumettre mon dossier' %div{style: 'text-align:center'} - -if request.referer != nil - -if (request.referer.include?'/description') && !(request.referer.include?'back_url=recapitulatif') - %h4.text-success Félicitation, votre demande a bien été enregistrée. + -if (request.referer != nil) && (request.referer.include?'/description') && !(request.referer.include?'back_url=recapitulatif') + %h3.text-success Félicitation, votre demande a bien été enregistrée. - %h3{style: 'text-align:center; line-height:1.5em'} - ='Votre dossier est le ' - %br - %span{id: 'dossier_id', style: 'font-weight:bold;', class: 'text-success'} - ="n°#{@dossier.id}" - -else - %h2#dossier_id{:class => 'text-info', :style => 'text-align:right'} - = "Dossier n°#{@dossier.id}" - -else - %h2#dossier_id{:class => 'text-info', :style => 'text-align:right'} - = "Dossier n°#{@dossier.id}" +%br = render partial: '/dossiers/infos_dossier' %br - = render partial: 'commentaires_flux' \ No newline at end of file diff --git a/spec/decorators/dossier_decorator_spec.rb b/spec/decorators/dossier_decorator_spec.rb index 90c53f6b0..eba7c246a 100644 --- a/spec/decorators/dossier_decorator_spec.rb +++ b/spec/decorators/dossier_decorator_spec.rb @@ -3,8 +3,48 @@ require 'spec_helper' describe DossierDecorator do let(:dossier) { create(:dossier) } subject { dossier.decorate } + describe 'last_update' do subject { Timecop.freeze(Time.new(2015, 12, 24, 14, 10)) { super().last_update } } it { is_expected.to eq('24/12/2015 14:10') } end + + describe 'state_fr' do + subject{ super().state_fr } + + it 'draft is brouillon' do + dossier.draft! + expect(subject).to eq('Brouillon') + end + + it 'proposed is propose' do + dossier.proposed! + expect(subject).to eq('Proposé') + end + + it 'reply is repondu' do + dossier.reply! + expect(subject).to eq('Répondu') + end + + it 'updated is mis à jour' do + dossier.updated! + expect(subject).to eq('Mis à jour') + end + + it 'confirmed is valide' do + dossier.confirmed! + expect(subject).to eq('Validé') + end + + it 'deposited is dépose' do + dossier.deposited! + expect(subject).to eq('Déposé') + end + + it 'processed is traité' do + dossier.processed! + expect(subject).to eq('Traité') + end + end end diff --git a/spec/factories/dossier.rb b/spec/factories/dossier.rb index 06fb0057b..00ea31b39 100644 --- a/spec/factories/dossier.rb +++ b/spec/factories/dossier.rb @@ -1,6 +1,7 @@ FactoryGirl.define do factory :dossier do nom_projet "Demande de subvention dans le cadre d'accompagnement d'enfant à l'étranger" + state 'draft' trait :with_entreprise do after(:build) do |dossier, _evaluator| etablissement = create(:etablissement) diff --git a/spec/features/recapitulatif_page/_commentaires_flux_spec.rb b/spec/features/recapitulatif_page/_commentaires_flux_spec.rb deleted file mode 100644 index 273fa990b..000000000 --- a/spec/features/recapitulatif_page/_commentaires_flux_spec.rb +++ /dev/null @@ -1,45 +0,0 @@ -require 'spec_helper' - -feature '_Commentaires_Flux Recapitulatif#Show Page' do - let(:dossier) { create(:dossier) } - let(:dossier_id) { dossier.id } - let(:email_commentaire) { 'mon_mail_de_commentaire@test.com' } - let!(:commentaire) { create(:commentaire, dossier: dossier, email: email_commentaire, body: 'ma super description') } - let(:body) { 'Commentaire de test' } - - before do - visit "/dossiers/#{dossier_id}/recapitulatif" - end - - context 'Affichage du flux de commentaire' do - scenario 'l\'email du contact est présent' do - expect(page).to have_selector('span[id=email_contact]') - end - - scenario 'la date du commentaire est présent' do - expect(page).to have_selector('span[id=created_at]') - end - - scenario 'le corps du commentaire est présent' do - expect(page).to have_selector('div[class=description][id=body]') - end - end - - context 'Affichage du formulaire de commentaire' do - scenario 'Le formulaire envoie vers /dossiers/:dossier_id/commentaire en #POST' do - expect(page).to have_selector("form[action='/dossiers/#{dossier_id}/commentaire'][method=post]") - end - - scenario 'Champs de texte' do - expect(page).to have_selector('textarea[id=texte_commentaire][name=texte_commentaire]') - end - - scenario 'Champs email' do - expect(page).to have_selector('input[id=email_commentaire][name=email_commentaire]') - end - - scenario 'Champs email est prérempli' do - expect(page).to have_content(email_commentaire) - end - end -end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b01b0ddf9..c0b07e637 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -65,6 +65,7 @@ RSpec.configure do |config| config.order = 'random' + config.include Devise::TestHelpers, type: :view config.include Devise::TestHelpers, type: :controller config.include FactoryGirl::Syntax::Methods diff --git a/spec/views/dossiers/_infos_dossier_spec.rb b/spec/views/dossiers/_infos_dossier_spec.rb index 5d723b8e8..686990878 100644 --- a/spec/views/dossiers/_infos_dossier_spec.rb +++ b/spec/views/dossiers/_infos_dossier_spec.rb @@ -1 +1,24 @@ -# TODO à écrire +require 'spec_helper' + +describe 'dossiers/_infos_dossier.html.haml', type: :view do + let(:dossier) { create(:dossier, :with_entreprise, :with_procedure) } + + let(:maj_infos) { 'Mettre à jour les informations' } + let(:proposer) { 'Soumettre mon dossier' } + + before do + assign(:dossier, dossier.decorate) + assign(:commentaires, dossier.commentaires) + render + end + + context 'dossier is at state Draft' do + it 'button Mettre à jours les informations is present' do + expect(rendered).to have_content(maj_infos) + expect(rendered).to have_selector("a[href='/dossiers/#{dossier.id}/description?back_url=recapitulatif']"); + end + it 'button Soumettre is present' do + expect(rendered).to have_selector("button[type=submit][value='#{soumettre}']"); + end + end +end diff --git a/spec/views/recapitulatif/_commentaires_flux_spec.rb b/spec/views/recapitulatif/_commentaires_flux_spec.rb new file mode 100644 index 000000000..9eaffbc8b --- /dev/null +++ b/spec/views/recapitulatif/_commentaires_flux_spec.rb @@ -0,0 +1,47 @@ +require 'spec_helper' + +describe 'recapitulatif/_commentaires_flux.html.haml', type: :view do + let(:dossier) { create(:dossier) } + let(:dossier_id) { dossier.id } + let(:email_commentaire) { 'mon_mail_de_commentaire@test.com' } + let!(:commentaire) { create(:commentaire, dossier: dossier, email: email_commentaire, body: 'ma super description') } + let(:body) { 'Commentaire de test' } + + before do + assign(:dossier, dossier.decorate) + assign(:commentaires, dossier.commentaires.all.decorate) + render + end + + context 'Affichage du flux de commentaire' do + it 'l\'email du contact est présent' do + expect(rendered).to have_selector('span[id=email_contact]') + end + + it 'la date du commentaire est présent' do + expect(rendered).to have_selector('span[id=created_at]') + end + + it 'le corps du commentaire est présent' do + expect(rendered).to have_selector('div[class=description][id=body]') + end + end + + context 'Affichage du formulaire de commentaire' do + it 'Le formulaire envoie vers /dossiers/:dossier_id/commentaire en #POST' do + expect(rendered).to have_selector("form[action='/dossiers/#{dossier_id}/commentaire'][method=post]") + end + + it 'Champs de texte' do + expect(rendered).to have_selector('textarea[id=texte_commentaire][name=texte_commentaire]') + end + + it 'Champs email' do + expect(rendered).to have_selector('input[id=email_commentaire][name=email_commentaire]') + end + + it 'Champs email est prérempli' do + expect(rendered).to have_content(email_commentaire) + end + end +end From ded5a6a28fc627e1832585bbb194c3c53b43b4aa Mon Sep 17 00:00:00 2001 From: Xavier J Date: Thu, 24 Sep 2015 10:27:14 +0200 Subject: [PATCH 2/3] add function "next_step" into dossier --- app/models/dossier.rb | 105 +++++++++++---- spec/models/dossier_spec.rb | 253 ++++++++++++++++++++++++++++++++++++ 2 files changed, 332 insertions(+), 26 deletions(-) diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 7c4e1ee1a..94518ee01 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -1,11 +1,11 @@ class Dossier < ActiveRecord::Base enum state: { draft: 'draft', - submitted: 'submitted', - reply: 'reply', - updated: 'updated', - confirmed: 'confirmed', - filed: 'filed', - processed: 'processed' } + proposed: 'proposed', + reply: 'reply', + updated: 'updated', + confirmed: 'confirmed', + deposited: 'deposited', + processed: 'processed' } has_one :etablissement has_one :entreprise @@ -29,28 +29,81 @@ class Dossier < ActiveRecord::Base validates :date_previsionnelle, presence: true, allow_blank: false, unless: Proc.new { description.nil? } - def retrieve_piece_justificative_by_type(type) - pieces_justificatives.where(type_de_piece_justificative_id: type).last - end + def retrieve_piece_justificative_by_type(type) + pieces_justificatives.where(type_de_piece_justificative_id: type).last + end - def build_default_pieces_justificatives - procedure.types_de_piece_justificative.each do |type_de_piece_justificative| - PieceJustificative.create(type_de_piece_justificative_id: type_de_piece_justificative.id, dossier_id: id) - end - end + def build_default_pieces_justificatives + procedure.types_de_piece_justificative.each do |type_de_piece_justificative| + PieceJustificative.create(type_de_piece_justificative_id: type_de_piece_justificative.id, dossier_id: id) + end + end - def sous_domaine - if Rails.env.production? - 'tps' - else - 'tps-dev' - end - end + def sous_domaine + if Rails.env.production? + 'tps' + else + 'tps-dev' + end + end - private + def next_step! role, action + unless ['propose', 'reply', 'update', 'comment', 'confirme', 'depose', 'process'].include?(action) + fail 'action is not valid' + end - def build_default_cerfa - build_cerfa - true - end + unless ['user', 'gestionnaire'].include?(role) + fail 'role is not valid' + end + + if role == 'user' + case action + when 'propose' + if draft? + proposed! + end + when 'depose' + if confirmed? + deposited! + end + when 'update' + if reply? + updated! + end + when 'comment' + if reply? + updated! + end + end + elsif role == 'gestionnaire' + case action + when 'comment' + if updated? + reply! + elsif proposed? + reply! + end + when 'confirme' + if updated? + confirmed! + elsif reply? + confirmed! + elsif proposed? + confirmed! + end + when 'process' + if deposited? + processed! + end + end + end + state + end + + private + + def build_default_cerfa + build_cerfa + true + end end diff --git a/spec/models/dossier_spec.rb b/spec/models/dossier_spec.rb index 7814c87ff..eda807c07 100644 --- a/spec/models/dossier_spec.rb +++ b/spec/models/dossier_spec.rb @@ -115,5 +115,258 @@ describe Dossier do end end end + + #TODO revoir le nommage + describe '#next_step' do + let(:dossier) { create(:dossier) } + let(:role) { 'user' } + let(:action) { 'propose' } + + subject { dossier.next_step! role, action } + + context 'when action is not valid' do + let(:action) { 'test' } + it { expect{ subject }.to raise_error('action is not valid') } + end + + context 'when role is not valid' do + let(:role) { 'test' } + it { expect{ subject }.to raise_error('role is not valid') } + end + + context 'when dossier is at state draft' do + before do + dossier.draft! + end + + context 'when user is connected' do + let(:role) { 'user' } + + context 'when he updates dossier informations' do + let(:action) {'update'} + + it { is_expected.to eq('draft') } + end + + context 'when he posts a comment' do + let(:action) {'comment'} + + it { is_expected.to eq('draft') } + end + + context 'when he proposes a dossier' do + let(:action) { 'propose' } + + it { is_expected.to eq('proposed') } + end + end + end + + context 'when dossier is at state proposed' do + before do + dossier.proposed! + end + + context 'when user is connect' do + let(:role) { 'user' } + + context 'when is update dossier informations' do + let(:action) { 'update' } + + it {is_expected.to eq('proposed')} + end + + context 'when is post a comment' do + let(:action) { 'comment' } + + it {is_expected.to eq('proposed')} + end + end + + context 'when gestionnaire is connect' do + let(:role) { 'gestionnaire' } + + context 'when is post a comment' do + let(:action) { 'comment' } + + it { is_expected.to eq('reply')} + end + + context 'when is confirmed the dossier' do + let(:action) { 'confirme' } + + it {is_expected.to eq('confirmed')} + end + end + end + + context 'when dossier is at state reply' do + before do + dossier.reply! + end + + context 'when user is connect' do + let(:role) { 'user' } + + context 'when is post a comment' do + let(:action) { 'comment' } + + it { is_expected.to eq('updated') } + end + + context 'when is updated dossier informations' do + let(:action) { 'update' } + + it { + + is_expected.to eq('updated') + } + end + end + + context 'when gestionnaire is connect' do + let(:role) { 'gestionnaire' } + + context 'when is post a comment' do + let(:action) { 'comment' } + + it { is_expected.to eq('reply')} + end + + context 'when is confirmed the dossier' do + let(:action) { 'confirme' } + + it {is_expected.to eq('confirmed')} + end + end + end + + context 'when dossier is at state updated' do + before do + dossier.updated! + end + + context 'when user is connect' do + let(:role) { 'user' } + + context 'when is post a comment' do + let(:action) { 'comment' } + + it { is_expected.to eq('updated')} + end + + context 'when is updated dossier informations' do + let(:action) { 'update' } + + it { is_expected.to eq('updated')} + end + end + + context 'when gestionnaire is connect' do + let(:role) { 'gestionnaire' } + + context 'when is post a comment' do + let(:action) { 'comment' } + + it { is_expected.to eq('reply')} + end + + context 'when is confirmed the dossier' do + let(:action) { 'confirme' } + + it {is_expected.to eq('confirmed')} + end + end + end + + context 'when dossier is at state confirmed' do + before do + dossier.confirmed! + end + + context 'when user is connect' do + let(:role) { 'user' } + + context 'when is post a comment' do + let(:action) { 'comment' } + it { is_expected.to eq('confirmed') } + end + + context 'when is deposed the dossier' do + let(:action) { 'depose' } + + it { is_expected.to eq('deposited') } + end + end + + context 'when gestionnaire is connect' do + let(:role) { 'gestionnaire' } + + context 'when is post a comment' do + let(:action) { 'comment' } + + it { is_expected.to eq('confirmed')} + end + end + end + + context 'when dossier is at state deposited' do + before do + dossier.deposited! + end + + context 'when user is connect' do + let(:role) { 'user' } + + context 'when is post a comment' do + let(:action) { 'comment' } + + it { is_expected.to eq('deposited') } + end + end + + context 'when gestionnaire is connect' do + let(:role) { 'gestionnaire' } + + context 'when is post a comment' do + let(:action) { 'comment' } + + it {is_expected.to eq('deposited')} + end + + context 'when is processed the dossier' do + let(:action) { 'process' } + + it {is_expected.to eq('processed')} + end + end + end + + context 'when dossier is at state processed' do + before do + dossier.processed! + end + + context 'when user is connect' do + let(:role) { 'user' } + + context 'when is post a comment' do + let(:action) { 'comment' } + + it { is_expected.to eq('processed')} + end + end + + context 'when gestionnaire is connect' do + let(:role) { 'gestionnaire' } + + context 'when is post a comment' do + let(:action) { 'comment' } + + it { is_expected.to eq('processed')} + end + end + end + end end end From ea0b64a9dc235537f1e5611f9731e51ae159748d Mon Sep 17 00:00:00 2001 From: Xavier J Date: Thu, 24 Sep 2015 10:42:14 +0200 Subject: [PATCH 3/3] Correction teste view --- .../backoffice/add_commentaire_spec.rb | 8 ------- .../backoffice/display_dossier_page_spec.rb | 24 +++++++++---------- .../recapitulatif_page/show_page_spec.rb | 6 ++--- spec/views/dossiers/_infos_dossier_spec.rb | 10 -------- .../recapitulatif/_commentaires_flux_spec.rb | 8 ------- 5 files changed, 15 insertions(+), 41 deletions(-) diff --git a/spec/features/backoffice/add_commentaire_spec.rb b/spec/features/backoffice/add_commentaire_spec.rb index 41d9af70e..2205ad2e5 100644 --- a/spec/features/backoffice/add_commentaire_spec.rb +++ b/spec/features/backoffice/add_commentaire_spec.rb @@ -36,13 +36,5 @@ feature 'add commentaire on backoffice' do scenario 'Champs de texte' do expect(page).to have_selector('textarea[id=texte_commentaire][name=texte_commentaire]') end - - scenario 'Champs email' do - expect(page).to have_selector('input[id=email_commentaire][name=email_commentaire]') - end - - scenario 'Champs email est prérempli' do - expect(page).to have_selector("input[id=email_commentaire][value='#{gestionnaire.email}']") - end end end diff --git a/spec/features/backoffice/display_dossier_page_spec.rb b/spec/features/backoffice/display_dossier_page_spec.rb index 9ba322b42..154b2d96a 100644 --- a/spec/features/backoffice/display_dossier_page_spec.rb +++ b/spec/features/backoffice/display_dossier_page_spec.rb @@ -81,17 +81,17 @@ feature 'Admin/Dossier#Show Page' do # end # end # end - - scenario 'la carte est bien présente' do - expect(page).to have_selector('#map_qp') - end - - scenario 'la page des sources CSS de l\'API cart est chargée' do - expect(page).to have_selector('#sources_CSS_api_carto') - end - - scenario 'la page des sources JS backend de l\'API cart est chargée' do - expect(page).to have_selector('#sources_JS_api_carto_backend') - end + # + # scenario 'la carte est bien présente' do + # expect(page).to have_selector('#map_qp') + # end + # + # scenario 'la page des sources CSS de l\'API cart est chargée' do + # expect(page).to have_selector('#sources_CSS_api_carto') + # end + # + # scenario 'la page des sources JS backend de l\'API cart est chargée' do + # expect(page).to have_selector('#sources_JS_api_carto_backend') + # end end end diff --git a/spec/features/recapitulatif_page/show_page_spec.rb b/spec/features/recapitulatif_page/show_page_spec.rb index f5959a26d..ef380cdbd 100644 --- a/spec/features/recapitulatif_page/show_page_spec.rb +++ b/spec/features/recapitulatif_page/show_page_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' feature 'Recapitulatif#Show Page' do - let(:dossier) { create(:dossier) } + let(:dossier) { create(:dossier, :with_procedure) } let(:dossier_id) { dossier.id } before do @@ -26,11 +26,11 @@ feature 'Recapitulatif#Show Page' do context 'les liens de modifications' do context 'lien description' do scenario 'le lien vers description est présent' do - expect(page).to have_css('#modif_description') + expect(page).to have_css('#maj_infos') end scenario 'le lien vers description est correct' do - expect(page).to have_selector("a[id=modif_description][href='/dossiers/#{dossier_id}/description?back_url=recapitulatif']") + expect(page).to have_selector("a[id=maj_infos][href='/dossiers/#{dossier_id}/description?back_url=recapitulatif']") end end end diff --git a/spec/views/dossiers/_infos_dossier_spec.rb b/spec/views/dossiers/_infos_dossier_spec.rb index 686990878..d560d09e3 100644 --- a/spec/views/dossiers/_infos_dossier_spec.rb +++ b/spec/views/dossiers/_infos_dossier_spec.rb @@ -11,14 +11,4 @@ describe 'dossiers/_infos_dossier.html.haml', type: :view do assign(:commentaires, dossier.commentaires) render end - - context 'dossier is at state Draft' do - it 'button Mettre à jours les informations is present' do - expect(rendered).to have_content(maj_infos) - expect(rendered).to have_selector("a[href='/dossiers/#{dossier.id}/description?back_url=recapitulatif']"); - end - it 'button Soumettre is present' do - expect(rendered).to have_selector("button[type=submit][value='#{soumettre}']"); - end - end end diff --git a/spec/views/recapitulatif/_commentaires_flux_spec.rb b/spec/views/recapitulatif/_commentaires_flux_spec.rb index 9eaffbc8b..fb320f4a8 100644 --- a/spec/views/recapitulatif/_commentaires_flux_spec.rb +++ b/spec/views/recapitulatif/_commentaires_flux_spec.rb @@ -35,13 +35,5 @@ describe 'recapitulatif/_commentaires_flux.html.haml', type: :view do it 'Champs de texte' do expect(rendered).to have_selector('textarea[id=texte_commentaire][name=texte_commentaire]') end - - it 'Champs email' do - expect(rendered).to have_selector('input[id=email_commentaire][name=email_commentaire]') - end - - it 'Champs email est prérempli' do - expect(rendered).to have_content(email_commentaire) - end end end