From 7d0bcfc35f62682674b8cb83a378d7dfb1454138 Mon Sep 17 00:00:00 2001 From: Xavier J Date: Tue, 19 Jul 2016 16:10:50 +0200 Subject: [PATCH] Delete utilisation of "nom_projet" attribut (no delete in database) --- app/assets/stylesheets/application.scss | 4 --- .../users/description_controller.rb | 2 +- app/models/dossier.rb | 2 -- app/serializers/dossier_serializer.rb | 1 - app/serializers/dossiers_serializer.rb | 1 - app/views/backoffice/dossiers/_list.html.haml | 4 +-- .../backoffice/dossiers/search.html.haml | 29 +++++++-------- app/views/dossiers/_infos_dossier.html.haml | 4 +-- app/views/invite_mailer/invite_user.text.erb | 1 - app/views/users/description/_show.html.haml | 7 ---- app/views/users/dossiers/_list.html.haml | 6 ++-- config/environments/development.rb | 2 +- config/locales/models/dossier/fr.yml | 2 -- .../api/v1/dossiers_controller_spec.rb | 8 ++--- .../commentaires_controller_spec.rb | 2 +- .../backoffice/dossiers_controller_spec.rb | 18 +++------- .../users/description_controller_spec.rb | 35 ++----------------- spec/factories/dossier.rb | 1 - spec/factories/type_de_champ.rb | 2 +- .../backoffice/navigate_to_dossier_spec.rb | 4 +-- spec/features/backoffice/search_file_spec.rb | 8 ++--- .../upload_piece_justificative_spec.rb | 4 +-- spec/features/users/complete_demande_spec.rb | 4 +-- spec/features/users/list_dossiers_spec.rb | 19 +++++----- spec/models/dossier_spec.rb | 27 ++++---------- .../previsualisations/show.html.haml_spec.rb | 9 ----- .../dossiers/index_html.haml_spec.rb | 29 ++++++++------- .../users/description/show.html.haml_spec.rb | 20 ----------- .../users/dossiers/index_html.haml_spec.rb | 33 ++++++++++------- 29 files changed, 95 insertions(+), 193 deletions(-) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 92fa141f8..dedae8dcd 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -164,10 +164,6 @@ textarea#description { width: 100%; } -input#nom_projet { - width: 100%; -} - .logo_fc_small { max-width: 27px; } diff --git a/app/controllers/users/description_controller.rb b/app/controllers/users/description_controller.rb index dfe9672d3..b3956eaa6 100644 --- a/app/controllers/users/description_controller.rb +++ b/app/controllers/users/description_controller.rb @@ -102,6 +102,6 @@ class Users::DescriptionController < UsersController private def create_params - params.permit(:nom_projet) + params.permit() end end diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 28a0c5074..ad44e2437 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -30,7 +30,6 @@ class Dossier < ActiveRecord::Base after_save :build_default_champs, if: Proc.new { procedure_id_changed? } - validates :nom_projet, presence: true, allow_blank: false, allow_nil: true validates :user, presence: true WAITING_FOR_GESTIONNAIRE = %w(initiated updated submitted) @@ -161,7 +160,6 @@ class Dossier < ActiveRecord::Base query_string_start_with = "#{word}%" composed_scope = composed_scope.where( - dossiers[:nom_projet].matches(query_string).or\ users[:email].matches(query_string).or\ etablissements[:siret].matches(query_string_start_with).or\ entreprises[:raison_sociale].matches(query_string)) diff --git a/app/serializers/dossier_serializer.rb b/app/serializers/dossier_serializer.rb index 0a79f1242..71aad46d8 100644 --- a/app/serializers/dossier_serializer.rb +++ b/app/serializers/dossier_serializer.rb @@ -1,6 +1,5 @@ class DossierSerializer < ActiveModel::Serializer attributes :id, - :nom_projet, :created_at, :updated_at, :archived, diff --git a/app/serializers/dossiers_serializer.rb b/app/serializers/dossiers_serializer.rb index 2a4f084a1..0179a0667 100644 --- a/app/serializers/dossiers_serializer.rb +++ b/app/serializers/dossiers_serializer.rb @@ -1,5 +1,4 @@ class DossiersSerializer < ActiveModel::Serializer attributes :id, - :nom_projet, :updated_at end \ No newline at end of file diff --git a/app/views/backoffice/dossiers/_list.html.haml b/app/views/backoffice/dossiers/_list.html.haml index 116d10802..3ee51e447 100644 --- a/app/views/backoffice/dossiers/_list.html.haml +++ b/app/views/backoffice/dossiers/_list.html.haml @@ -2,7 +2,7 @@ %table.table %thead %th= smart_listing.sortable 'Procédure', 'procedure.libelle' - %th= smart_listing.sortable 'Dossier', 'nom_projet' + %th= smart_listing.sortable 'Raison sociale', 'entreprise.raison_sociale' %th= smart_listing.sortable 'État', 'state' %th= smart_listing.sortable 'Date de mise à jour', 'updated_at' - unless @liste == 'termine' @@ -13,7 +13,7 @@ %tr %td.col-md-4.col-lg-4= dossier.procedure.libelle %td.col-md-4.col-lg-4 - = link_to(dossier.nom_projet, "/backoffice/dossiers/#{dossier.id}") + = link_to(dossier.entreprise.raison_sociale, "/backoffice/dossiers/#{dossier.id}") %td= dossier.display_state %td= dossier.last_update - unless @liste == 'termine' diff --git a/app/views/backoffice/dossiers/search.html.haml b/app/views/backoffice/dossiers/search.html.haml index d55850ae2..9d01e31b5 100644 --- a/app/views/backoffice/dossiers/search.html.haml +++ b/app/views/backoffice/dossiers/search.html.haml @@ -8,16 +8,14 @@ %h4 = "Dossier N°#{@dossier.id}" %tr - %td.col-md-2.col-lg-1 + %td.col-md-1.col-lg-1 = @dossier.id - %td.col-md-4.col-lg-3 - = link_to(@dossier.nom_projet, "/backoffice/dossiers/#{@dossier.id}") - %td.col-md-2.col-lg-3 - = @dossier.entreprise.raison_sociale - %td.col-md-4.col-lg-2 - = @dossier.user.email + %td.col-md-4.col-lg-4 + = @dossier.procedure.libelle + %td.col-md-4.col-lg-4 + = link_to(@dossier.entreprise.raison_sociale, "/backoffice/dossiers/#{@dossier.id}") %td.col-md-2.col-lg-2 - = @dossier.etablissement.siret + = @dossier.user.email %td.col-md-1.col-lg-1{class: @dossier.state_color_class} = @dossier.display_state %br @@ -29,21 +27,18 @@ - elsif !@dossiers_search.empty? %table.table %tr - %th.col-md-2.col-lg-1 ID dossier - %th.col-md-4.col-lg-3 Dossier - %th.col-md-2.col-lg-3 Raison Sociale - %th.col-md-4.col-lg-2 Email contact - %th.col-md-2.col-lg-2 SIRET + %th.col-md-1.col-lg-1 ID dossier + %th.col-md-4.col-lg-4 Procédure + %th.col-md-4.col-lg-4 Raison Sociale + %th.col-md-2.col-lg-2 Email contact %th.col-md-1.col-lg-1 État - @dossiers_search.each do |dossier| %tr %td= dossier.id - %td - = link_to(dossier.nom_projet, "/backoffice/dossiers/#{dossier.id}") - %td= dossier.entreprise.raison_sociale + %td= dossier.procedure.libelle + %td= link_to(dossier.entreprise.raison_sociale, "/backoffice/dossiers/#{dossier.id}") %td= dossier.user.email - %td= dossier.etablissement.siret %td{class: dossier.state_color_class}= dossier.display_state .pagination diff --git a/app/views/dossiers/_infos_dossier.html.haml b/app/views/dossiers/_infos_dossier.html.haml index f916f5dcb..6e814043f 100644 --- a/app/views/dossiers/_infos_dossier.html.haml +++ b/app/views/dossiers/_infos_dossier.html.haml @@ -1,9 +1,7 @@ #infos_dossier %div.row .col-lg-6.col-md-6 - %h3.text-info - = @facade.dossier.nom_projet - %h4 + %h3 = @facade.dossier.procedure.libelle - if @facade.dossier.mandataire_social && gestionnaire_signed_in? diff --git a/app/views/invite_mailer/invite_user.text.erb b/app/views/invite_mailer/invite_user.text.erb index 12d8125c9..57827303c 100644 --- a/app/views/invite_mailer/invite_user.text.erb +++ b/app/views/invite_mailer/invite_user.text.erb @@ -1,7 +1,6 @@ Bonjour <%= @invite.email %> L'utilisateur <%= @invite.email_sender %> souhaite que vous participiez à l'élaboration d'un dossier sur la plateforme TPS. -Ce dossier se nomme : <%= @invite.dossier.nom_projet %> Pour le consulter, merci de suivre ce lien : <%= users_dossiers_invite_url(@invite.id) %> diff --git a/app/views/users/description/_show.html.haml b/app/views/users/description/_show.html.haml index c0db91dc6..463ac15e8 100644 --- a/app/views/users/description/_show.html.haml +++ b/app/views/users/description/_show.html.haml @@ -3,15 +3,8 @@ = @dossier.procedure.libelle %h3 Votre dossier - %br - -#TODO use form_for = form_tag(url_for({controller: 'users/description', action: :create, dossier_id: @dossier.id}), class: 'form-inline', method: 'POST', multipart: true) do - %div - .row - .col-md-12 - %h4 Libellé pour votre dossier * - = text_field_tag :nom_projet, @dossier.nom_projet, placeholder: 'Nom du projet', class: 'form-control' #liste_champs -unless @champs.nil? diff --git a/app/views/users/dossiers/_list.html.haml b/app/views/users/dossiers/_list.html.haml index eee042954..3f788cee0 100644 --- a/app/views/users/dossiers/_list.html.haml +++ b/app/views/users/dossiers/_list.html.haml @@ -2,7 +2,7 @@ %table.table %thead %th.col-md-4.col-lg-4= smart_listing.sortable 'Procédure', 'procedure.libelle' - %th.col-md-4.col-lg-4= smart_listing.sortable 'Nom du Projet', 'nom_projet' + %th.col-md-4.col-lg-4= smart_listing.sortable 'Raison sociale', 'entreprise.raison_sociale' %th.col-md-2.col-lg-2= smart_listing.sortable 'État', 'state' %th.col-md-2.col-lg-2= smart_listing.sortable 'Date de mise à jour', 'updated_at' - @dossiers.each do |dossier| @@ -15,8 +15,8 @@ %td = dossier.procedure.libelle %td - = link_to(dossier.nom_projet, users_dossiers_invite_path(id: invite.id)) unless invite.nil? - = link_to(dossier.nom_projet, users_dossier_recapitulatif_path(dossier)) if invite.nil? + = link_to(dossier.entreprise.raison_sociale, users_dossiers_invite_path(id: invite.id)) unless invite.nil? + = link_to(dossier.entreprise.raison_sociale, users_dossier_recapitulatif_path(dossier)) if invite.nil? %td{id: "dossier_#{dossier.id}_state"}= dossier.display_state %td= dossier.last_update diff --git a/config/environments/development.rb b/config/environments/development.rb index 0d42d3db7..66984e511 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -36,7 +36,7 @@ Rails.application.configure do # Raises helpful error messages. config.assets.raise_runtime_errors = true - config.action_mailer.delivery_method = :mailjet + config.action_mailer.delivery_method = :test config.action_mailer.default_url_options = { :host => 'localhost:3000' } # Raises error for missing translations diff --git a/config/locales/models/dossier/fr.yml b/config/locales/models/dossier/fr.yml index 37b811618..6c7eaab74 100644 --- a/config/locales/models/dossier/fr.yml +++ b/config/locales/models/dossier/fr.yml @@ -4,8 +4,6 @@ fr: dossier: 'Dossier' attributes: dossier: - nom_projet: 'Le nom du projet' - description: 'La description' montant_projet: 'Le montant du projet' montant_aide_demande: "Le montant d'aide demandée" date_previsionnelle: "La date de début prévisionnelle" diff --git a/spec/controllers/api/v1/dossiers_controller_spec.rb b/spec/controllers/api/v1/dossiers_controller_spec.rb index 3e0554444..74cac6446 100644 --- a/spec/controllers/api/v1/dossiers_controller_spec.rb +++ b/spec/controllers/api/v1/dossiers_controller_spec.rb @@ -52,9 +52,8 @@ describe API::V1::DossiersController do describe 'dossier' do subject { super().first } it { expect(subject[:id]).to eq(dossier.id) } - it { expect(subject[:nom_projet]).to eq(dossier.nom_projet) } it { expect(subject[:updated_at]).to eq("2008-09-01T08:05:00.000Z") } - it { expect(subject.keys.size).to eq(3) } + it { expect(subject.keys.size).to eq(2) } end end @@ -116,14 +115,13 @@ describe API::V1::DossiersController do let!(:dossier) { Timecop.freeze(date_creation) { create(:dossier, :with_entreprise, procedure: procedure) } } let(:dossier_id) { dossier.id } let(:body) { JSON.parse(retour.body, symbolize_names: true) } - let(:field_list) { [:id, :nom_projet, :created_at, :updated_at, :archived, :mandataire_social, :entreprise, :etablissement, :cerfa, :types_de_piece_justificative, :pieces_justificatives, :champs, :commentaires, :state] } + let(:field_list) { [:id, :created_at, :updated_at, :archived, :mandataire_social, :entreprise, :etablissement, :cerfa, :types_de_piece_justificative, :pieces_justificatives, :champs, :commentaires, :state] } subject { body[:dossier] } it 'return REST code 200', :show_in_doc do expect(retour.code).to eq('200') end it { expect(subject[:id]).to eq(dossier.id) } - it { expect(subject[:nom_projet]).to eq(dossier.nom_projet) } it { expect(subject[:state]).to eq(dossier.state) } it { expect(subject[:created_at]).to eq('2008-09-01T08:05:00.000Z') } it { expect(subject[:updated_at]).to eq('2008-09-01T08:05:00.000Z') } @@ -231,7 +229,7 @@ describe API::V1::DossiersController do it { expect(subject[:libelle]).to eq('Description') } it { expect(subject[:description]).to eq('description de votre projet') } it { expect(subject.keys.include?(:order_place)).to be_truthy } - it { expect(subject[:type]).to eq('textarea') } + it { expect(subject[:type]).to eq('text') } end end end diff --git a/spec/controllers/backoffice/commentaires_controller_spec.rb b/spec/controllers/backoffice/commentaires_controller_spec.rb index 18e51695d..231f12c69 100644 --- a/spec/controllers/backoffice/commentaires_controller_spec.rb +++ b/spec/controllers/backoffice/commentaires_controller_spec.rb @@ -20,7 +20,7 @@ describe Backoffice::CommentairesController, type: :controller do subject { post :create, dossier_id: dossier_id, email_commentaire: email_commentaire, texte_commentaire: texte_commentaire } it 'depuis la page admin' do - expect(response).to redirect_to("/backoffice/dossiers/#{dossier_id}") + expect(subject).to redirect_to("/backoffice/dossiers/#{dossier_id}") end it 'gestionnaire is automatically affect to follow the dossier' do diff --git a/spec/controllers/backoffice/dossiers_controller_spec.rb b/spec/controllers/backoffice/dossiers_controller_spec.rb index 8b23017b3..19d5c280b 100644 --- a/spec/controllers/backoffice/dossiers_controller_spec.rb +++ b/spec/controllers/backoffice/dossiers_controller_spec.rb @@ -1,6 +1,10 @@ require 'rails_helper' describe Backoffice::DossiersController, type: :controller do + before do + @request.env['HTTP_REFERER'] = TPS::Application::URL + end + let(:dossier) { create(:dossier, :with_entreprise) } let(:dossier_archived) { create(:dossier, :with_entreprise, archived: true) } @@ -67,19 +71,6 @@ describe Backoffice::DossiersController, type: :controller do end end - describe 'GET #suivi' do - context 'when gestionnaire is connected' do - before do - sign_in gestionnaire - end - - it 'returns http success' do - get :index, liste: :suivi - expect(response).to have_http_status(200) - end - end - end - describe 'GET #termine' do context 'when gestionnaire is connected' do before do @@ -150,7 +141,6 @@ describe Backoffice::DossiersController, type: :controller do subject { put :follow, dossier_id: dossier_id } it { expect(subject.status).to eq 302 } - it { is_expected.to redirect_to backoffice_dossiers_path } describe 'flash alert' do context 'when dossier is not follow by gestionnaire' do diff --git a/spec/controllers/users/description_controller_spec.rb b/spec/controllers/users/description_controller_spec.rb index bcf08bcbb..58d0f9f2a 100644 --- a/spec/controllers/users/description_controller_spec.rb +++ b/spec/controllers/users/description_controller_spec.rb @@ -63,14 +63,13 @@ describe Users::DescriptionController, type: :controller, vcr: {cassette_name: ' describe 'POST #create' do let(:timestamp) { Time.now } - let(:nom_projet) { 'Projet de test' } let(:description) { 'Description de test Coucou, je suis un saut à la ligne Je suis un double saut la ligne.' } context 'Tous les attributs sont bons' do describe 'Premier enregistrement des données' do before do dossier.draft! - post :create, dossier_id: dossier_id, nom_projet: nom_projet + post :create, dossier_id: dossier_id dossier.reload end @@ -78,8 +77,6 @@ describe Users::DescriptionController, type: :controller, vcr: {cassette_name: ' expect(response).to redirect_to("/users/dossiers/#{dossier_id}/recapitulatif") end - it { expect(dossier.nom_projet).to eq nom_projet } - it 'etat du dossier est soumis' do expect(dossier.state).to eq('initiated') end @@ -88,7 +85,7 @@ describe Users::DescriptionController, type: :controller, vcr: {cassette_name: ' context 'En train de manipuler un dossier non brouillon' do before do dossier.initiated! - post :create, dossier_id: dossier_id, nom_projet: nom_projet, description: description + post :create, dossier_id: dossier_id dossier.reload end @@ -102,28 +99,10 @@ describe Users::DescriptionController, type: :controller, vcr: {cassette_name: ' end end - context 'Attribut(s) manquant(s)' do - subject { - post :create, - dossier_id: dossier_id, - nom_projet: nom_projet, - description: description - } - before { subject } - - context 'nom_projet empty' do - let(:nom_projet) { '' } - it { is_expected.to render_template(:show) } - it { expect(flash[:alert]).to be_present } - end - end - context 'Quand la procédure accepte les CERFA' do context 'Sauvegarde du CERFA PDF', vcr: {cassette_name: 'controllers_users_description_controller_save_cerfa'} do before do post :create, dossier_id: dossier_id, - nom_projet: nom_projet, - description: description, cerfa_pdf: cerfa_pdf dossier.reload end @@ -150,7 +129,7 @@ describe Users::DescriptionController, type: :controller, vcr: {cassette_name: ' let(:cerfas) { Cerfa.where(dossier_id: dossier_id) } before do - post :create, dossier_id: dossier_id, nom_projet: nom_projet, description: description, cerfa_pdf: cerfa_pdf + post :create, dossier_id: dossier_id, cerfa_pdf: cerfa_pdf end it "il y a deux CERFA PDF pour ce dossier" do @@ -165,8 +144,6 @@ describe Users::DescriptionController, type: :controller, vcr: {cassette_name: ' let!(:procedure) { create(:procedure) } before do post :create, dossier_id: dossier_id, - nom_projet: nom_projet, - description: description, cerfa_pdf: cerfa_pdf dossier.reload end @@ -186,8 +163,6 @@ describe Users::DescriptionController, type: :controller, vcr: {cassette_name: ' before do post :create, {dossier_id: dossier_id, - nom_projet: nom_projet, - description: description, champs: { "'#{dossier.champs.first.id}'" => dossier_champs_first, "'#{dossier.champs.second.id}'" => dossier_date_value @@ -228,8 +203,6 @@ describe Users::DescriptionController, type: :controller, vcr: {cassette_name: ' let(:all_pj_type) { dossier.procedure.type_de_piece_justificative_ids } before do post :create, {dossier_id: dossier_id, - nom_projet: nom_projet, - description: description, 'piece_justificative_'+all_pj_type[0].to_s => piece_justificative_0, 'piece_justificative_'+all_pj_type[1].to_s => piece_justificative_1} dossier.reload @@ -240,8 +213,6 @@ describe Users::DescriptionController, type: :controller, vcr: {cassette_name: ' expect(ClamavService).to receive(:safe_file?).twice post :create, {dossier_id: dossier_id, - nom_projet: nom_projet, - description: description, 'piece_justificative_'+all_pj_type[0].to_s => piece_justificative_0, 'piece_justificative_'+all_pj_type[1].to_s => piece_justificative_1} end diff --git a/spec/factories/dossier.rb b/spec/factories/dossier.rb index 3919ecccd..e3f1e3490 100644 --- a/spec/factories/dossier.rb +++ b/spec/factories/dossier.rb @@ -1,6 +1,5 @@ FactoryGirl.define do factory :dossier do - nom_projet "Demande de subvention dans le cadre d'accompagnement d'enfant à l'étranger" state 'draft' association :user, factory: [:user] diff --git a/spec/factories/type_de_champ.rb b/spec/factories/type_de_champ.rb index 2b26e9ca0..8e348a254 100644 --- a/spec/factories/type_de_champ.rb +++ b/spec/factories/type_de_champ.rb @@ -2,7 +2,7 @@ FactoryGirl.define do factory :type_de_champ do libelle 'Description' description 'description de votre projet' - type_champ 'textarea' + type_champ 'text' order_place 1 mandatory false end diff --git a/spec/features/backoffice/navigate_to_dossier_spec.rb b/spec/features/backoffice/navigate_to_dossier_spec.rb index 41d0944f6..4a3664a99 100644 --- a/spec/features/backoffice/navigate_to_dossier_spec.rb +++ b/spec/features/backoffice/navigate_to_dossier_spec.rb @@ -5,7 +5,7 @@ feature 'on backoffice page' do let(:gestionnaire) { create(:gestionnaire, administrateurs: [administrateur]) } let(:procedure) { create(:procedure, administrateur: administrateur) } - let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated') } + let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated') } before do create :assign_to, gestionnaire: gestionnaire, procedure: procedure @@ -20,7 +20,7 @@ feature 'on backoffice page' do end context 'when he click on first dossier' do before do - page.click_on dossier.nom_projet + page.click_on dossier.entreprise.raison_sociale end scenario 'it redirect to dossier page' do expect(page).to have_css('#backoffice_dossier_show') diff --git a/spec/features/backoffice/search_file_spec.rb b/spec/features/backoffice/search_file_spec.rb index 8d0bb38df..d0db942d7 100644 --- a/spec/features/backoffice/search_file_spec.rb +++ b/spec/features/backoffice/search_file_spec.rb @@ -40,13 +40,11 @@ feature 'search file on gestionnaire backoffice' do context 'when terms input does return result' do let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated') } - let!(:dossier_2) { create(:dossier, procedure: procedure, state: 'initiated', nom_projet: 'Projet de test') } + let!(:dossier_2) { create(:dossier, procedure: procedure, state: 'initiated') } - let(:terms) { dossier.nom_projet } + let(:terms) { dossier.entreprise.raison_sociale } - it { expect(page).not_to have_content('Projet de test') } - - it { expect(page).to have_content(dossier.nom_projet) } + it { expect(page).to have_content(dossier.entreprise.raison_sociale) } context "when terms is a file's id" do let(:terms) { dossier.id } diff --git a/spec/features/description_page/upload_piece_justificative_spec.rb b/spec/features/description_page/upload_piece_justificative_spec.rb index 89b14e15a..09f97734d 100644 --- a/spec/features/description_page/upload_piece_justificative_spec.rb +++ b/spec/features/description_page/upload_piece_justificative_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' feature 'user is on description page' do - let!(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, cerfa_flag: true) } + let!(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ, cerfa_flag: true) } let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure) } before do @@ -21,7 +21,7 @@ feature 'user is on description page' do context 'he fill description fields' do before do - find_by_id('nom_projet').set 'mon nom' + find_by_id("champs_#{dossier.champs.first.id}").set 'mon nom' end context 'before submit' do it 'dossier cerfa is empty' do diff --git a/spec/features/users/complete_demande_spec.rb b/spec/features/users/complete_demande_spec.rb index 70e73deb7..61f071c0c 100644 --- a/spec/features/users/complete_demande_spec.rb +++ b/spec/features/users/complete_demande_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' feature 'user path for dossier creation' do let(:user) { create(:user) } - let(:procedure) { create(:procedure, :published) } + let(:procedure) { create(:procedure, :published, :with_type_de_champ) } let(:siret) { '53272417600013' } let(:siren) { siret[0...9] } @@ -68,7 +68,7 @@ feature 'user path for dossier creation' do end context 'user fill and validate description page' do before do - page.find_by_id('nom_projet').set 'Mon super projet' + page.find_by_id("champs_#{Dossier.last.champs.first.id}").set 'Mon super projet' page.click_on 'Soumettre mon dossier' end scenario 'user is on recap page' do diff --git a/spec/features/users/list_dossiers_spec.rb b/spec/features/users/list_dossiers_spec.rb index e9867fe61..22d0c1060 100644 --- a/spec/features/users/list_dossiers_spec.rb +++ b/spec/features/users/list_dossiers_spec.rb @@ -3,12 +3,15 @@ require 'spec_helper' feature 'user access to the list of his dossier' do let(:user) { create(:user) } - let!(:last_updated_dossier) { create(:dossier, user: user, state: 'replied')} - let!(:dossier1) { create(:dossier, user: user, nom_projet: 'mon permier dossier', state: 'replied') } - let!(:dossier2) { create(:dossier, nom_projet: 'mon deuxième dossier') } + let!(:last_updated_dossier) { create(:dossier, :with_entreprise, user: user, state: 'replied')} + let!(:dossier1) { create(:dossier, :with_entreprise, user: user, state: 'replied') } + let!(:dossier2) { create(:dossier, :with_entreprise) } before do - last_updated_dossier.update_attributes(nom_projet: 'salut la compagnie') + dossier1.update_column(:updated_at, "19/07/2016 15:35".to_time) + dossier1.entreprise.update_column(:raison_sociale, 'PLOP') + last_updated_dossier.entreprise.update_column(:raison_sociale, 'PLIP') + visit new_user_session_path within('#new_user') do page.find_by_id('user_email').set user.email @@ -17,12 +20,12 @@ feature 'user access to the list of his dossier' do end end scenario 'the list of dossier is displayed' do - expect(page).to have_content(dossier1.nom_projet) - expect(page).not_to have_content(dossier2.nom_projet) + expect(page).to have_content(dossier1.entreprise.raison_sociale) + expect(page).not_to have_content(dossier2.entreprise.raison_sociale) end scenario 'the list must be order by last updated' do - expect(page.body).to match(/#{last_updated_dossier.nom_projet}.*#{dossier1.nom_projet}/m) + expect(page.body).to match(/#{last_updated_dossier.entreprise.raison_sociale}.*#{dossier1.entreprise.raison_sociale}/m) end scenario 'the state of dossier is displayed' do @@ -31,7 +34,7 @@ feature 'user access to the list of his dossier' do context 'when user clicks on a projet in list' do before do - page.click_on dossier1.nom_projet + page.click_on dossier1.entreprise.raison_sociale end scenario 'user is redirected to dossier page' do expect(page).to have_css('#recap_dossier') diff --git a/spec/models/dossier_spec.rb b/spec/models/dossier_spec.rb index 3f20d3fb4..99c77a2ab 100644 --- a/spec/models/dossier_spec.rb +++ b/spec/models/dossier_spec.rb @@ -34,14 +34,6 @@ describe Dossier do it { is_expected.to delegate_method(:types_de_champ).to(:procedure) } end - describe 'validation' do - context 'nom_projet' do - it { is_expected.to allow_value(nil).for(:nom_projet) } - it { is_expected.not_to allow_value('').for(:nom_projet) } - it { is_expected.to allow_value('mon super projet').for(:nom_projet) } - end - end - describe 'methods' do let(:dossier) { create(:dossier, :with_entreprise, user: user) } @@ -122,7 +114,7 @@ describe Dossier do it 'does not create default champs' do expect(subject).not_to receive(:build_default_champs) - subject.update_attributes(nom_projet: 'plop') + subject.update_attributes(state: 'initiated') end end end @@ -443,11 +435,11 @@ describe Dossier do let(:procedure_1) { create(:procedure, administrateur: administrateur_1) } let(:procedure_2) { create(:procedure, administrateur: administrateur_2) } - let!(:dossier_0) { create(:dossier, nom_projet: 'je suis un brouillon', state: 'draft', procedure: procedure_1, user: create(:user, email: 'brouillon@clap.fr')) } - let!(:dossier_1) { create(:dossier, nom_projet: 'Projet de test', state: 'initiated', procedure: procedure_1, user: create(:user, email: 'contact@test.com')) } - let!(:dossier_2) { create(:dossier, nom_projet: 'Lili et Marcel', state: 'initiated', procedure: procedure_1, user: create(:user, email: 'plop@gmail.com')) } - let!(:dossier_3) { create(:dossier, nom_projet: 'Construction projet marcel', state: 'initiated', procedure: procedure_2, user: create(:user, email: 'peace@clap.fr')) } - let!(:dossier_archived) { create(:dossier, nom_projet: 'je suis un Marcel archivé', state: 'initiated', procedure: procedure_1, archived: true, user: create(:user, email: 'brouillonArchived@clap.fr')) } + let!(:dossier_0) { create(:dossier, state: 'draft', procedure: procedure_1, user: create(:user, email: 'brouillon@clap.fr')) } + let!(:dossier_1) { create(:dossier, state: 'initiated', procedure: procedure_1, user: create(:user, email: 'contact@test.com')) } + let!(:dossier_2) { create(:dossier, state: 'initiated', procedure: procedure_1, user: create(:user, email: 'plop@gmail.com')) } + let!(:dossier_3) { create(:dossier, state: 'initiated', procedure: procedure_2, user: create(:user, email: 'peace@clap.fr')) } + let!(:dossier_archived) { create(:dossier, state: 'initiated', procedure: procedure_1, archived: true, user: create(:user, email: 'brouillonArchived@clap.fr')) } let!(:etablissement_1) { create(:etablissement, entreprise: create(:entreprise, raison_sociale: 'OCTO Academy', dossier: dossier_1), dossier: dossier_1, siret: '41636169600051') } let!(:etablissement_2) { create(:etablissement, entreprise: create(:entreprise, raison_sociale: 'Plop octo', dossier: dossier_2), dossier: dossier_2, siret: '41816602300012') } @@ -465,12 +457,6 @@ describe Dossier do it { expect(subject.size).to eq(0) } end - describe 'search on file title' do - let(:terms) { 'Marcel' } - - it { expect(subject.size).to eq(1) } - end - describe 'search on contact email' do let(:terms) { 'clap' } @@ -536,7 +522,6 @@ describe Dossier do let(:dossier) { create(:dossier, :with_entreprise, user: user, procedure: procedure) } subject { dossier.as_csv } - it { expect(subject[:nom_projet]).to eq("Demande de subvention dans le cadre d'accompagnement d'enfant à l'étranger") } it { expect(subject[:archived]).to be_falsey } it { expect(subject['etablissement.siret']).to eq('44011762001530') } it { expect(subject['etablissement.siege_social']).to be_truthy } diff --git a/spec/views/admin/previsualisations/show.html.haml_spec.rb b/spec/views/admin/previsualisations/show.html.haml_spec.rb index 4d97de3a8..82263c78b 100644 --- a/spec/views/admin/previsualisations/show.html.haml_spec.rb +++ b/spec/views/admin/previsualisations/show.html.haml_spec.rb @@ -21,10 +21,6 @@ describe 'admin/previsualisations/show.html.haml', type: :view do expect(rendered).to have_selector("form[action='/users/dossiers/#{dossier_id}/description'][method=post]") end - it 'Nom du projet' do - expect(rendered).to have_selector('input[id=nom_projet][name=nom_projet]') - end - it 'Charger votre CERFA (PDF)' do expect(rendered).to have_selector('input[type=file][name=cerfa_pdf][id=cerfa_pdf]') end @@ -66,17 +62,12 @@ describe 'admin/previsualisations/show.html.haml', type: :view do context 'les valeurs sont réaffichées si elles sont présentes dans la BDD' do let!(:dossier) do create(:dossier, - nom_projet: 'Projet de test', user: user) end before do render end - - it 'Nom du projet' do - expect(rendered).to have_selector("input[id=nom_projet][value='#{dossier.nom_projet}']") - end end context 'Champs' do diff --git a/spec/views/backoffice/dossiers/index_html.haml_spec.rb b/spec/views/backoffice/dossiers/index_html.haml_spec.rb index 9127a12df..6406a6ece 100644 --- a/spec/views/backoffice/dossiers/index_html.haml_spec.rb +++ b/spec/views/backoffice/dossiers/index_html.haml_spec.rb @@ -6,12 +6,17 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do let!(:procedure) { create(:procedure, administrateur: administrateur) } - let!(:decorate_dossier_initiated) { create(:dossier, procedure: procedure, nom_projet: 'projet initiated', state: 'initiated').decorate } - let!(:decorate_dossier_replied) { create(:dossier, procedure: procedure, nom_projet: 'projet replied', state: 'replied').decorate } - let!(:decorate_dossier_closed) { create(:dossier, procedure: procedure, nom_projet: 'projet closed', state: 'closed').decorate } + let!(:decorate_dossier_initiated) { create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated').decorate } + let!(:decorate_dossier_replied) { create(:dossier, :with_entreprise, procedure: procedure, state: 'replied').decorate } + let!(:decorate_dossier_closed) { create(:dossier, :with_entreprise, procedure: procedure, state: 'closed').decorate } before do + + decorate_dossier_closed.entreprise.update_column(:raison_sociale, 'plip') + decorate_dossier_replied.entreprise.update_column(:raison_sociale, 'plop') + create :assign_to, gestionnaire: gestionnaire, procedure: procedure + sign_in gestionnaire end describe 'on tab a_traiter' do @@ -29,12 +34,12 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do subject { rendered } it { is_expected.to have_css('#backoffice_index') } it { is_expected.to have_content(procedure.libelle) } - it { is_expected.to have_content(decorate_dossier_initiated.nom_projet) } + it { is_expected.to have_content(decorate_dossier_initiated.entreprise.raison_sociale) } it { is_expected.to have_content(decorate_dossier_initiated.display_state) } it { is_expected.to have_content(decorate_dossier_initiated.last_update) } - it { is_expected.not_to have_content(decorate_dossier_replied.nom_projet) } - it { is_expected.not_to have_content(decorate_dossier_closed.nom_projet) } + it { is_expected.not_to have_content(decorate_dossier_replied.entreprise.raison_sociale) } + it { is_expected.not_to have_content(decorate_dossier_closed.entreprise.raison_sociale) } it { is_expected.to have_css("#suivre_dossier_#{gestionnaire.dossiers.waiting_for_gestionnaire.first.id}") } @@ -58,12 +63,12 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do subject { rendered } it { is_expected.to have_css('#backoffice_index') } it { is_expected.to have_content(procedure.libelle) } - it { is_expected.to have_content(decorate_dossier_replied.nom_projet) } + it { is_expected.to have_content(decorate_dossier_replied.entreprise.raison_sociale) } it { is_expected.to have_content(decorate_dossier_replied.display_state) } it { is_expected.to have_content(decorate_dossier_replied.last_update) } - it { is_expected.not_to have_content(decorate_dossier_initiated.nom_projet) } - it { is_expected.not_to have_content(decorate_dossier_closed.nom_projet) } + it { is_expected.not_to have_content(decorate_dossier_initiated.entreprise.raison_sociale) } + it { is_expected.not_to have_content(decorate_dossier_closed.entreprise.raison_sociale) } describe 'active tab' do it { is_expected.to have_selector('.active .text-info') } @@ -85,12 +90,12 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do it { is_expected.to have_css('#backoffice_index') } it { is_expected.to have_content(procedure.libelle) } - it { is_expected.to have_content(decorate_dossier_closed.nom_projet) } + it { is_expected.to have_content(decorate_dossier_closed.entreprise.raison_sociale) } it { is_expected.to have_content(decorate_dossier_closed.display_state) } it { is_expected.to have_content(decorate_dossier_closed.last_update) } - it { is_expected.not_to have_content(decorate_dossier_initiated.nom_projet) } - it { is_expected.not_to have_content(decorate_dossier_replied.nom_projet) } + it { is_expected.not_to have_content(decorate_dossier_initiated.entreprise.raison_sociale) } + it { is_expected.not_to have_content(decorate_dossier_replied.entreprise.raison_sociale) } it { is_expected.not_to have_css("#suivre_dossier_#{gestionnaire.dossiers.termine.first.id}") } diff --git a/spec/views/users/description/show.html.haml_spec.rb b/spec/views/users/description/show.html.haml_spec.rb index a6a283dc4..4a44776b7 100644 --- a/spec/views/users/description/show.html.haml_spec.rb +++ b/spec/views/users/description/show.html.haml_spec.rb @@ -22,10 +22,6 @@ describe 'users/description/show.html.haml', type: :view do expect(rendered).to have_selector("form[action='/users/dossiers/#{dossier_id}/description'][method=post]") end - it 'Nom du projet' do - expect(rendered).to have_selector('input[id=nom_projet][name=nom_projet]') - end - it 'Charger votre CERFA (PDF)' do expect(rendered).to have_selector('input[type=file][name=cerfa_pdf][id=cerfa_pdf]') end @@ -64,22 +60,6 @@ describe 'users/description/show.html.haml', type: :view do end end - context 'les valeurs sont réaffichées si elles sont présentes dans la BDD' do - let!(:dossier) do - create(:dossier, - nom_projet: 'Projet de test', - user: user) - end - - before do - render - end - - it 'Nom du projet' do - expect(rendered).to have_selector("input[id=nom_projet][value='#{dossier.nom_projet}']") - end - end - context 'Champs' do let(:champs) { dossier.champs } let(:types_de_champ) { procedure.types_de_champ.where(type_champ: 'datetime').first } diff --git a/spec/views/users/dossiers/index_html.haml_spec.rb b/spec/views/users/dossiers/index_html.haml_spec.rb index 6b4a48edd..381e607fe 100644 --- a/spec/views/users/dossiers/index_html.haml_spec.rb +++ b/spec/views/users/dossiers/index_html.haml_spec.rb @@ -3,10 +3,17 @@ require 'spec_helper' describe 'users/dossiers/index.html.haml', type: :view do let(:user) { create(:user) } - let!(:dossier) { create(:dossier, user: user, state: 'initiated', nom_projet: 'projet de test').decorate } - let!(:dossier_2) { create(:dossier, user: user, state: 'replied', nom_projet: 'projet répondu').decorate } - let!(:dossier_3) { create(:dossier, user: user, state: 'replied', nom_projet: 'projet répondu 2').decorate } - let!(:dossier_termine) { create(:dossier, user: user, state: 'closed').decorate } + 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 } + + 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') + end describe 'params liste is a_traiter' do let(:dossiers_list) { user.dossiers.waiting_for_user('DESC') } @@ -32,14 +39,14 @@ describe 'users/dossiers/index.html.haml', type: :view do describe 'dossier replied is present' do it { is_expected.to have_content(dossier_2.procedure.libelle) } - it { is_expected.to have_content(dossier_2.nom_projet) } + 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) } end describe 'dossier initiated and closed are not present' do - it { is_expected.not_to have_content(dossier.nom_projet) } - it { is_expected.not_to have_content(dossier_termine.nom_projet) } + it { is_expected.not_to have_content(dossier.entreprise.raison_sociale) } + it { is_expected.not_to have_content(dossier_termine.entreprise.raison_sociale) } end describe 'badges on tabs' do @@ -69,14 +76,14 @@ describe 'users/dossiers/index.html.haml', type: :view do describe 'dossier initiated is present' do it { is_expected.to have_content(dossier.procedure.libelle) } - it { is_expected.to have_content(dossier.nom_projet) } + 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.nom_projet) } - it { is_expected.not_to have_content(dossier_termine.nom_projet) } + it { is_expected.not_to have_content(dossier_2.entreprise.raison_sociale) } + it { is_expected.not_to have_content(dossier_termine.entreprise.raison_sociale) } end end @@ -100,14 +107,14 @@ describe 'users/dossiers/index.html.haml', type: :view do describe 'dossier termine is present' do it { is_expected.to have_content(dossier_termine.procedure.libelle) } - it { is_expected.to have_content(dossier_termine.nom_projet) } + 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) } end describe 'dossier initiated and replied are not present' do - it { is_expected.not_to have_content(dossier.nom_projet) } - it { is_expected.not_to have_content(dossier_2.nom_projet) } + it { is_expected.not_to have_content(dossier.entreprise.raison_sociale) } + it { is_expected.not_to have_content(dossier_2.entreprise.raison_sociale) } end end end \ No newline at end of file