remove useless function in admin dossier controller and fix tests
This commit is contained in:
parent
92e522eb3d
commit
4f5587cb66
9 changed files with 42 additions and 36 deletions
|
@ -11,8 +11,8 @@ class Admin::DossierController < ApplicationController
|
||||||
@commentaire_email = current_user.email
|
@commentaire_email = current_user.email
|
||||||
|
|
||||||
@formulaire = @dossier.formulaire
|
@formulaire = @dossier.formulaire
|
||||||
@liste_pieces_jointes = @dossier.types_piece_jointe
|
|
||||||
@array_id_pj_valides = PieceJointe.get_array_id_pj_valid_for_dossier @dossier.id
|
|
||||||
@dossier = @dossier.decorate
|
@dossier = @dossier.decorate
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
redirect_start
|
redirect_start
|
||||||
|
|
|
@ -3,9 +3,9 @@ class DescriptionController < ApplicationController
|
||||||
@dossier = Dossier.find(params[:dossier_id])
|
@dossier = Dossier.find(params[:dossier_id])
|
||||||
@dossier = @dossier.decorate
|
@dossier = @dossier.decorate
|
||||||
|
|
||||||
@array_id_pj_valides = PieceJointe.get_array_id_pj_valid_for_dossier @dossier.id
|
|
||||||
@formulaire = @dossier.formulaire
|
@formulaire = @dossier.formulaire
|
||||||
@liste_pieces_jointes = @dossier.types_piece_jointe
|
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
redirect_to url_for(controller: :start, action: :error_dossier)
|
redirect_to url_for(controller: :start, action: :error_dossier)
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,6 +2,7 @@ class PieceJointe < ActiveRecord::Base
|
||||||
belongs_to :dossier
|
belongs_to :dossier
|
||||||
belongs_to :type_piece_jointe
|
belongs_to :type_piece_jointe
|
||||||
delegate :api_entreprise, :libelle, to: :type_piece_jointe
|
delegate :api_entreprise, :libelle, to: :type_piece_jointe
|
||||||
|
alias_attribute :type, :type_piece_jointe_id
|
||||||
mount_uploader :content, PieceJointeUploader
|
mount_uploader :content, PieceJointeUploader
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%h1#dossier_id{:class => 'text-info', :style => 'text-align:right'}
|
%h1#dossier_id.text-info{ :style => 'text-align:right'}
|
||||||
= "Dossier n°#{@dossier.id}"
|
= "Dossier n°#{@dossier.id}"
|
||||||
|
|
||||||
%script{type: 'text/javascript'}
|
%script{type: 'text/javascript'}
|
||||||
|
@ -11,7 +11,7 @@
|
||||||
%br
|
%br
|
||||||
%br
|
%br
|
||||||
|
|
||||||
.content{class: 'row'}
|
.content.row
|
||||||
#map_qp.col-lg-6.col-md-6{style: 'height:500px'}
|
#map_qp.col-lg-6.col-md-6{style: 'height:500px'}
|
||||||
#pieces_jointes.col-lg-6.col-md-6
|
#pieces_jointes.col-lg-6.col-md-6
|
||||||
%h3.text-info Liste des pièces jointes
|
%h3.text-info Liste des pièces jointes
|
||||||
|
@ -22,20 +22,20 @@
|
||||||
%th{class:'col-lg-6'}
|
%th{class:'col-lg-6'}
|
||||||
='CERFA'
|
='CERFA'
|
||||||
%td.col-lg-4.col-md-4
|
%td.col-lg-4.col-md-4
|
||||||
- if @array_id_pj_valides.include?(0)
|
- if !@dossier.cerfa.empty?
|
||||||
%a{ href: "#{@dossier.get_pj(0).content}", target: '_blank' } Consulter
|
%a{ href: "#{@dossier.cerfa.content}", target: '_blank' } Consulter
|
||||||
- else
|
- else
|
||||||
= 'Pièce non fournie'
|
= 'Pièce non fournie'
|
||||||
|
|
||||||
-@liste_pieces_jointes.each do |pj|
|
-@dossier.pieces_jointes.each do |piece_jointe|
|
||||||
%tr{id: "piece_jointe_#{pj.id}"}
|
%tr{id: "piece_jointe_#{piece_jointe.type}"}
|
||||||
%th{class:'col-lg-6'}
|
%th{class:'col-lg-6'}
|
||||||
=pj.libelle
|
=piece_jointe.libelle
|
||||||
%td.col-lg-4.col-md-4
|
%td.col-lg-4.col-md-4
|
||||||
- if pj.api_entreprise
|
- if piece_jointe.api_entreprise
|
||||||
%a{ href: '' } Récupérer
|
%a{ href: '' } Récupérer
|
||||||
- elsif @array_id_pj_valides.include?(pj.id)
|
- elsif !piece_jointe.empty?
|
||||||
%a{ href: "#{@dossier.get_pj(pj.id).content}", target: '_blank' } Consulter
|
%a{ href: "#{piece_jointe.content}", target: '_blank' } Consulter
|
||||||
- else
|
- else
|
||||||
= 'Pièce non fournie'
|
= 'Pièce non fournie'
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
%h3 Documents administratifs
|
%h3 Documents administratifs
|
||||||
|
|
||||||
%br
|
%br
|
||||||
//TODO a refactorer DO
|
//TODO a refactorer
|
||||||
%table{class:'table', style:'width:55%; margin-left:5%'}
|
%table{class:'table', style:'width:55%; margin-left:5%'}
|
||||||
%tr
|
%tr
|
||||||
%th{class:'col-lg-6'}
|
%th{class:'col-lg-6'}
|
||||||
|
@ -51,31 +51,31 @@
|
||||||
%a{style:'font-size:0.9em; padding-left:3px', id: 'lien_cerfa' ,href: "#{@formulaire.lien_demarche}", :target => '_blank'} Lien CERFA
|
%a{style:'font-size:0.9em; padding-left:3px', id: 'lien_cerfa' ,href: "#{@formulaire.lien_demarche}", :target => '_blank'} Lien CERFA
|
||||||
|
|
||||||
%td{class:'col-lg-5'}
|
%td{class:'col-lg-5'}
|
||||||
-if @array_id_pj_valides.include?(0)
|
-if !@dossier.cerfa.empty?
|
||||||
%span.btn.btn-sm.btn-file.btn-success
|
%span.btn.btn-sm.btn-file.btn-success
|
||||||
="Modifier"
|
Modifier
|
||||||
%input{type: 'file', name:'cerfa_pdf', id:'cerfa_pdf', accept: ".pdf"}
|
%input{type: 'file', name:'cerfa_pdf', id:'cerfa_pdf', accept: ".pdf"}
|
||||||
-else
|
-else
|
||||||
%span.btn.btn-sm.btn-file.btn-info
|
%span.btn.btn-sm.btn-file.btn-info
|
||||||
="Choisir"
|
Choisir
|
||||||
%input{type: 'file', name:'cerfa_pdf', id:'cerfa_pdf', accept: ".pdf"}
|
%input{type: 'file', name:'cerfa_pdf', id:'cerfa_pdf', accept: ".pdf"}
|
||||||
|
|
||||||
-@liste_pieces_jointes.each do |pj|
|
- @dossier.pieces_jointes.each do |piece_jointe|
|
||||||
%tr
|
%tr
|
||||||
%th{class:'col-lg-6'}
|
%th.col-lg-6
|
||||||
=pj.libelle
|
= piece_jointe.libelle
|
||||||
%td{class:'col-lg-5'}
|
%td.col-lg-5
|
||||||
-if pj.api_entreprise
|
-if piece_jointe.api_entreprise
|
||||||
%span.text-success{id: "piece_jointe_#{pj.id}"} Nous l'avons récupéré pour vous.
|
%span.text-success{ id: "piece_jointe_#{piece_jointe.type}" } Nous l'avons récupéré pour vous.
|
||||||
-else
|
-else
|
||||||
-if @array_id_pj_valides.include?(pj.id)
|
-if piece_jointe.empty?
|
||||||
%span.btn.btn-sm.btn-file.btn-success
|
|
||||||
="Modifier"
|
|
||||||
%input{type: 'file', name:"piece_jointe_#{pj.id}", id:"piece_jointe_#{pj.id}", accept: ".pdf"}
|
|
||||||
-else
|
|
||||||
%span.btn.btn-sm.btn-file.btn-info
|
%span.btn.btn-sm.btn-file.btn-info
|
||||||
="Choisir"
|
Choisir
|
||||||
%input{type: 'file', name:"piece_jointe_#{pj.id}", id:"piece_jointe_#{pj.id}", accept: ".pdf"}
|
= file_field_tag "piece_jointe_#{piece_jointe.type}", accept: '.pdf'
|
||||||
|
-else
|
||||||
|
%span.btn.btn-sm.btn-file.btn-success
|
||||||
|
Modifier
|
||||||
|
= file_field_tag "piece_jointe_#{piece_jointe.type}", accept: '.pdf'
|
||||||
//END
|
//END
|
||||||
|
|
||||||
%div{style: 'text-align:right'}
|
%div{style: 'text-align:right'}
|
||||||
|
|
|
@ -12,11 +12,11 @@ RSpec.describe DemandesController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'POST #upated' do
|
describe 'POST #upated' do
|
||||||
context 'dans tous les cas on affiche la carte' do
|
context 'when dossier is not linked to formulaire' do
|
||||||
it {
|
it 'redirect to carte controller' do
|
||||||
post :update, :dossier_id => dossier_id, :formulaire => '1'
|
post :update, :dossier_id => dossier_id, :formulaire => '1'
|
||||||
expect(response).to redirect_to(controller: :carte, action: :show, dossier_id: dossier_id)
|
expect(response).to redirect_to(controller: :carte, action: :show, dossier_id: dossier_id)
|
||||||
}
|
end
|
||||||
end
|
end
|
||||||
context 'when dossier is already linked to formaulaire' do
|
context 'when dossier is already linked to formaulaire' do
|
||||||
let(:dossier) { create(:dossier) }
|
let(:dossier) { create(:dossier) }
|
||||||
|
|
|
@ -10,6 +10,7 @@ feature '_Commentaires_Flux Admin/Dossier#Show Page' do
|
||||||
let(:body) { 'Commentaire de test' }
|
let(:body) { 'Commentaire de test' }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
dossier.build_default_pieces_jointes
|
||||||
login_admin
|
login_admin
|
||||||
visit "/admin/dossier/#{dossier_id}"
|
visit "/admin/dossier/#{dossier_id}"
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,6 +5,7 @@ feature 'Admin/Dossier#Show Page' do
|
||||||
let(:dossier_id) { dossier.id }
|
let(:dossier_id) { dossier.id }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
dossier.build_default_pieces_jointes
|
||||||
login_admin
|
login_admin
|
||||||
visit "/admin/dossier/#{dossier_id}"
|
visit "/admin/dossier/#{dossier_id}"
|
||||||
end
|
end
|
||||||
|
@ -61,10 +62,12 @@ feature 'Admin/Dossier#Show Page' do
|
||||||
|
|
||||||
context 'Devis' do
|
context 'Devis' do
|
||||||
let(:id_piece_jointe){388}
|
let(:id_piece_jointe){388}
|
||||||
let(:piece_jointe_388) {File.open('./spec/support/files/piece_jointe_388.pdf')}
|
let(:content) {File.open('./spec/support/files/piece_jointe_388.pdf')}
|
||||||
let!(:piece_jointe) { create(:piece_jointe, dossier: dossier, type_piece_jointe_id: id_piece_jointe, content: piece_jointe_388) }
|
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
piece_jointe = dossier.pieces_jointes.where(type_piece_jointe_id: 388).first
|
||||||
|
piece_jointe.content = content
|
||||||
|
piece_jointe.save!
|
||||||
visit "/admin/dossier/#{dossier_id}"
|
visit "/admin/dossier/#{dossier_id}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ feature 'Description#Show Page' do
|
||||||
let(:dossier_id) { dossier.id }
|
let(:dossier_id) { dossier.id }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
dossier.build_default_pieces_jointes
|
||||||
visit "/dossiers/#{dossier_id}/description"
|
visit "/dossiers/#{dossier_id}/description"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue