Merge branch 'develop' into develop_v2
# Conflicts: # Gemfile.lock # db/schema.rb
This commit is contained in:
commit
647eaa4ba8
34 changed files with 509 additions and 122 deletions
|
@ -115,7 +115,7 @@ 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, :created_at, :updated_at, :archived, :mandataire_social, :total_commentaire, :entreprise, :etablissement, :cerfa, :types_de_piece_justificative, :pieces_justificatives, :champs, :champs_private, :commentaires, :state] }
|
||||
let(:field_list) { [:id, :created_at, :updated_at, :archived, :mandataire_social, :entreprise, :etablissement, :cerfa, :types_de_piece_justificative, :pieces_justificatives, :champs, :champs_private, :commentaires, :state] }
|
||||
subject { body[:dossier] }
|
||||
|
||||
it 'return REST code 200', :show_in_doc do
|
||||
|
@ -128,7 +128,6 @@ describe API::V1::DossiersController do
|
|||
it { expect(subject[:updated_at]).to eq('2008-09-01T08:05:00.000Z') }
|
||||
it { expect(subject[:archived]).to eq(dossier.archived) }
|
||||
it { expect(subject[:mandataire_social]).to eq(dossier.mandataire_social) }
|
||||
it { expect(subject[:total_commentaire]).to eq(dossier.total_commentaire) }
|
||||
|
||||
it { expect(subject.keys).to match_array(field_list) }
|
||||
|
||||
|
|
52
spec/features/backoffice/flux_de_commentaires_spec.rb
Normal file
52
spec/features/backoffice/flux_de_commentaires_spec.rb
Normal file
|
@ -0,0 +1,52 @@
|
|||
require 'spec_helper'
|
||||
|
||||
feature 'backoffice: flux de commentaires' do
|
||||
let(:gestionnaire) { create(:gestionnaire) }
|
||||
let(:dossier) { create(:dossier, :with_entreprise) }
|
||||
let(:dossier_id) { dossier.id }
|
||||
|
||||
let(:champ1) { dossier.champs.first }
|
||||
let(:champ2) { create(:champ, dossier: dossier, type_de_champ: create(:type_de_champ_public, libelle: "subtitle")) }
|
||||
|
||||
let!(:commentaire1) { create(:commentaire, dossier: dossier, champ: champ1) }
|
||||
let!(:commentaire2) { create(:commentaire, dossier: dossier) }
|
||||
let!(:commentaire3) { create(:commentaire, dossier: dossier, champ: champ2) }
|
||||
let!(:commentaire4) { create(:commentaire, dossier: dossier, champ: champ1) }
|
||||
|
||||
before do
|
||||
login_as gestionnaire, scope: :gestionnaire
|
||||
visit backoffice_dossier_path(dossier)
|
||||
end
|
||||
|
||||
scenario "seuls les commentaires généraux sont affichés" do
|
||||
comments = find("#commentaires_flux")
|
||||
expect(comments).to have_selector(".description", count: 1)
|
||||
end
|
||||
|
||||
scenario "affichage des commentaires du champs", js: true do
|
||||
find("#liste_champs th", text: champ1.libelle).click_link("COM")
|
||||
expect(page).to have_css("#modalCommentairesDossierParChamp.in")
|
||||
|
||||
modal = find("#modalCommentairesDossierParChamp")
|
||||
expect(modal).to have_css(".description", count: 2)
|
||||
end
|
||||
|
||||
scenario "crée un commentaire sur un champ", js: true do
|
||||
# ouverture modale
|
||||
find("#liste_champs th", text: champ1.libelle).click_link("COM")
|
||||
|
||||
# ajout du commentaire
|
||||
form = find("#modalCommentairesDossierParChamp").find("#commentaire_new")
|
||||
form.fill_in("texte_commentaire", with: "le corps du commentaire sur le champ #{champ1.libelle}")
|
||||
form.click_on("Poster")
|
||||
|
||||
# le commentaire ne s'ajoute pas aux commentaires généraux
|
||||
comments = find("#commentaires_flux")
|
||||
expect(comments).to have_selector(".description", count: 1)
|
||||
|
||||
# ajout du commentaire aux commentaires du champs
|
||||
find("#liste_champs th", text: champ1.libelle).click_link("COM")
|
||||
modal = find("#modalCommentairesDossierParChamp")
|
||||
expect(modal).to have_css(".description", count: 3)
|
||||
end
|
||||
end
|
|
@ -65,7 +65,7 @@ feature 'usage of pref list dossier lateral panel', js: true do
|
|||
expect(page).not_to have_css('#delete_pref_list_entreprise_siren')
|
||||
end
|
||||
|
||||
scenario 'dossier is brought up to date' do
|
||||
scenario 'dossier is brought up to date', js: true do
|
||||
wait_for_ajax
|
||||
expect(page).not_to have_selector("a.sortable[data-attr='entreprise.siren']")
|
||||
end
|
||||
|
|
53
spec/features/users/flux_de_commentaires_spec.rb
Normal file
53
spec/features/users/flux_de_commentaires_spec.rb
Normal file
|
@ -0,0 +1,53 @@
|
|||
require 'spec_helper'
|
||||
|
||||
feature 'users: flux de commentaires' do
|
||||
let(:user) { create(:user) }
|
||||
let(:dossier) { create(:dossier, :with_entreprise, user: user, state: "replied") }
|
||||
let(:dossier_id) { dossier.id }
|
||||
|
||||
let(:champ1) { dossier.champs.first }
|
||||
let(:champ2) { create(:champ, dossier: dossier, type_de_champ: create(:type_de_champ_public, libelle: "subtitle")) }
|
||||
|
||||
let!(:commentaire1) { create(:commentaire, dossier: dossier, champ: champ1) }
|
||||
let!(:commentaire2) { create(:commentaire, dossier: dossier) }
|
||||
let!(:commentaire3) { create(:commentaire, dossier: dossier, champ: champ2) }
|
||||
let!(:commentaire4) { create(:commentaire, dossier: dossier, champ: champ1) }
|
||||
|
||||
before do
|
||||
login_as user, scope: :user
|
||||
visit users_dossier_recapitulatif_path(dossier)
|
||||
end
|
||||
|
||||
scenario "seuls les commentaires généraux sont affichés" do
|
||||
comments = find("#commentaires_flux")
|
||||
expect(comments).to have_selector(".description", count: 1)
|
||||
end
|
||||
|
||||
scenario "affichage des commentaires du champs", js: true do
|
||||
th = find("#liste_champs th", text: champ1.libelle)
|
||||
th.click_link("COM")
|
||||
expect(page).to have_css("#modalCommentairesDossierParChamp.in")
|
||||
|
||||
modal = find("#modalCommentairesDossierParChamp")
|
||||
expect(modal).to have_css(".description", count: 2)
|
||||
end
|
||||
|
||||
scenario "crée un commentaire sur un champ", js: true do
|
||||
# ouverture modale
|
||||
find("#liste_champs th", text: champ1.libelle).click_link("COM")
|
||||
|
||||
# ajout du commentaire
|
||||
form = find("#modalCommentairesDossierParChamp").find("#commentaire_new")
|
||||
form.fill_in("texte_commentaire", with: "le corps du commentaire sur le champ #{champ1.libelle}")
|
||||
form.click_on("Poster")
|
||||
|
||||
# le commentaire ne s'ajoute pas aux commentaires généraux
|
||||
comments = find("#commentaires_flux")
|
||||
expect(comments).to have_selector(".description", count: 1)
|
||||
|
||||
# ajout du commentaire aux commentaires du champs
|
||||
find("#liste_champs th", text: champ1.libelle).click_link("COM")
|
||||
modal = find("#modalCommentairesDossierParChamp")
|
||||
expect(modal).to have_css(".description", count: 3)
|
||||
end
|
||||
end
|
|
@ -578,45 +578,192 @@ describe Dossier do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#as_csv?' do
|
||||
describe '#convert_specific_hash_values_to_string(hash_to_convert)' do
|
||||
let(:procedure) { create(:procedure) }
|
||||
let(:dossier) { create(:dossier, :with_entreprise, user: user, procedure: procedure) }
|
||||
subject { dossier.as_csv }
|
||||
let(:dossier_serialized_attributes) { DossierSerializer.new(dossier).attributes }
|
||||
|
||||
it { expect(subject[:archived]).to be_falsey }
|
||||
it { expect(subject['etablissement.siret']).to eq('44011762001530') }
|
||||
it { expect(subject['etablissement.siege_social']).to be_truthy }
|
||||
it { expect(subject['etablissement.naf']).to eq('4950Z') }
|
||||
it { expect(subject['etablissement.libelle_naf']).to eq('Transports par conduites') }
|
||||
it { expect(subject['etablissement.adresse']).to eq("GRTGAZ IMMEUBLE BORA 6 RUE RAOUL NORDLING 92270 BOIS COLOMBES") }
|
||||
it { expect(subject['etablissement.numero_voie']).to eq('6') }
|
||||
it { expect(subject['etablissement.type_voie']).to eq('RUE') }
|
||||
it { expect(subject['etablissement.nom_voie']).to eq('RAOUL NORDLING') }
|
||||
it { expect(subject['etablissement.complement_adresse']).to eq('IMMEUBLE BORA') }
|
||||
it { expect(subject['etablissement.code_postal']).to eq('92270') }
|
||||
it { expect(subject['etablissement.localite']).to eq('BOIS COLOMBES') }
|
||||
it { expect(subject['etablissement.code_insee_localite']).to eq('92009') }
|
||||
it { expect(subject['entreprise.siren']).to eq('440117620') }
|
||||
it { expect(subject['entreprise.capital_social']).to eq(537100000) }
|
||||
it { expect(subject['entreprise.numero_tva_intracommunautaire']).to eq('FR27440117620') }
|
||||
it { expect(subject['entreprise.forme_juridique']).to eq("SA à conseil d'administration (s.a.i.)") }
|
||||
it { expect(subject['entreprise.forme_juridique_code']).to eq('5599') }
|
||||
it { expect(subject['entreprise.nom_commercial']).to eq('GRTGAZ') }
|
||||
it { expect(subject['entreprise.raison_sociale']).to eq('GRTGAZ') }
|
||||
it { expect(subject['entreprise.siret_siege_social']).to eq('44011762001530') }
|
||||
it { expect(subject['entreprise.code_effectif_entreprise']).to eq('51') }
|
||||
it { expect(subject['entreprise.date_creation']).to eq('Thu, 28 Jan 2016 10:16:29 UTC +00:0') }
|
||||
it { expect(subject['entreprise.nom']).to be_nil }
|
||||
it { expect(subject['entreprise.prenom']).to be_nil }
|
||||
subject { dossier.convert_specific_hash_values_to_string(dossier_serialized_attributes) }
|
||||
|
||||
it { expect(dossier_serialized_attributes[:id]).to be_an(Integer) }
|
||||
it { expect(dossier_serialized_attributes[:created_at]).to be_a(Time) }
|
||||
it { expect(dossier_serialized_attributes[:updated_at]).to be_a(Time) }
|
||||
it { expect(dossier_serialized_attributes[:archived]).to be_in([true, false]) }
|
||||
it { expect(dossier_serialized_attributes[:mandataire_social]).to be_in([true, false]) }
|
||||
it { expect(dossier_serialized_attributes[:state]).to be_a(String) }
|
||||
|
||||
it { expect(subject[:id]).to be_a(String) }
|
||||
it { expect(subject[:created_at]).to be_a(Time) }
|
||||
it { expect(subject[:updated_at]).to be_a(Time) }
|
||||
it { expect(subject[:archived]).to be_a(String) }
|
||||
it { expect(subject[:mandataire_social]).to be_a(String) }
|
||||
it { expect(subject[:state]).to be_a(String) }
|
||||
end
|
||||
|
||||
describe '#convert_specific_array_values_to_string(array_to_convert)' do
|
||||
let(:procedure) { create(:procedure) }
|
||||
let(:dossier) { create(:dossier, :with_entreprise, user: user, procedure: procedure) }
|
||||
let(:dossier_data_with_champs) { dossier.data_with_champs }
|
||||
|
||||
subject { dossier.convert_specific_hash_values_to_string(dossier_data_with_champs) }
|
||||
end
|
||||
|
||||
describe '#export_entreprise_data' do
|
||||
let(:procedure) { create(:procedure) }
|
||||
let(:dossier) { create(:dossier, :with_entreprise, user: user, procedure: procedure) }
|
||||
|
||||
subject { dossier.export_entreprise_data }
|
||||
|
||||
it { expect(subject[:etablissement_siret]).to eq('44011762001530') }
|
||||
it { expect(subject[:etablissement_siege_social]).to eq('true') }
|
||||
it { expect(subject[:etablissement_naf]).to eq('4950Z') }
|
||||
it { expect(subject[:etablissement_libelle_naf]).to eq('Transports par conduites') }
|
||||
it { expect(subject[:etablissement_adresse]).to eq('GRTGAZ IMMEUBLE BORA 6 RUE RAOUL NORDLING 92270 BOIS COLOMBES') }
|
||||
it { expect(subject[:etablissement_numero_voie]).to eq('6') }
|
||||
it { expect(subject[:etablissement_type_voie]).to eq('RUE') }
|
||||
it { expect(subject[:etablissement_nom_voie]).to eq('RAOUL NORDLING') }
|
||||
it { expect(subject[:etablissement_complement_adresse]).to eq('IMMEUBLE BORA') }
|
||||
it { expect(subject[:etablissement_code_postal]).to eq('92270') }
|
||||
it { expect(subject[:etablissement_localite]).to eq('BOIS COLOMBES') }
|
||||
it { expect(subject[:etablissement_code_insee_localite]).to eq('92009') }
|
||||
it { expect(subject[:entreprise_siren]).to eq('440117620') }
|
||||
it { expect(subject[:entreprise_capital_social]).to eq('537100000') }
|
||||
it { expect(subject[:entreprise_numero_tva_intracommunautaire]).to eq('FR27440117620') }
|
||||
it { expect(subject[:entreprise_forme_juridique]).to eq("SA à conseil d'administration (s.a.i.)") }
|
||||
it { expect(subject[:entreprise_forme_juridique_code]).to eq('5599') }
|
||||
it { expect(subject[:entreprise_nom_commercial]).to eq('GRTGAZ') }
|
||||
it { expect(subject[:entreprise_raison_sociale]).to eq('GRTGAZ') }
|
||||
it { expect(subject[:entreprise_siret_siege_social]).to eq('44011762001530') }
|
||||
it { expect(subject[:entreprise_code_effectif_entreprise]).to eq('51') }
|
||||
it { expect(subject[:entreprise_date_creation]).to eq('Thu, 28 Jan 2016 10:16:29 UTC +00:0') }
|
||||
it { expect(subject[:entreprise_nom]).to be_nil }
|
||||
it { expect(subject[:entreprise_prenom]).to be_nil }
|
||||
|
||||
it { expect(subject.count).to eq(EntrepriseSerializer.new(Entreprise.new).as_json.count + EtablissementSerializer.new(Etablissement.new).as_json.count) }
|
||||
end
|
||||
|
||||
describe '#export_default_columns' do
|
||||
let(:procedure) { create(:procedure) }
|
||||
let(:dossier) { create(:dossier, :with_entreprise, user: user, procedure: procedure) }
|
||||
subject { dossier.export_default_columns }
|
||||
|
||||
it { expect(subject[:archived]).to eq('false') }
|
||||
it { expect(subject[:etablissement_siret]).to eq('44011762001530') }
|
||||
it { expect(subject[:etablissement_siege_social]).to eq('true') }
|
||||
it { expect(subject[:etablissement_naf]).to eq('4950Z') }
|
||||
it { expect(subject[:etablissement_libelle_naf]).to eq('Transports par conduites') }
|
||||
it { expect(subject[:etablissement_adresse]).to eq('GRTGAZ IMMEUBLE BORA 6 RUE RAOUL NORDLING 92270 BOIS COLOMBES') }
|
||||
it { expect(subject[:etablissement_numero_voie]).to eq('6') }
|
||||
it { expect(subject[:etablissement_type_voie]).to eq('RUE') }
|
||||
it { expect(subject[:etablissement_nom_voie]).to eq('RAOUL NORDLING') }
|
||||
it { expect(subject[:etablissement_complement_adresse]).to eq('IMMEUBLE BORA') }
|
||||
it { expect(subject[:etablissement_code_postal]).to eq('92270') }
|
||||
it { expect(subject[:etablissement_localite]).to eq('BOIS COLOMBES') }
|
||||
it { expect(subject[:etablissement_code_insee_localite]).to eq('92009') }
|
||||
it { expect(subject[:entreprise_siren]).to eq('440117620') }
|
||||
it { expect(subject[:entreprise_capital_social]).to eq('537100000') }
|
||||
it { expect(subject[:entreprise_numero_tva_intracommunautaire]).to eq('FR27440117620') }
|
||||
it { expect(subject[:entreprise_forme_juridique]).to eq("SA à conseil d'administration (s.a.i.)") }
|
||||
it { expect(subject[:entreprise_forme_juridique_code]).to eq('5599') }
|
||||
it { expect(subject[:entreprise_nom_commercial]).to eq('GRTGAZ') }
|
||||
it { expect(subject[:entreprise_raison_sociale]).to eq('GRTGAZ') }
|
||||
it { expect(subject[:entreprise_siret_siege_social]).to eq('44011762001530') }
|
||||
it { expect(subject[:entreprise_code_effectif_entreprise]).to eq('51') }
|
||||
it { expect(subject[:entreprise_date_creation]).to eq('Thu, 28 Jan 2016 10:16:29 UTC +00:0') }
|
||||
it { expect(subject[:entreprise_nom]).to be_nil }
|
||||
it { expect(subject[:entreprise_prenom]).to be_nil }
|
||||
|
||||
context 'when dossier does not have enterprise' do
|
||||
let(:dossier) { create(:dossier, user: user, procedure: procedure) }
|
||||
subject { dossier.as_csv }
|
||||
subject { dossier.export_default_columns }
|
||||
|
||||
it { expect(subject[:archived]).to be_falsey }
|
||||
it { expect(subject[:archived]).to eq('false') }
|
||||
end
|
||||
end
|
||||
|
||||
describe '#export_headers' do
|
||||
let(:procedure) { create(:procedure, :with_type_de_champ) }
|
||||
let(:dossier) { create(:dossier, :with_entreprise, user: user, procedure: procedure) }
|
||||
subject { dossier.export_headers }
|
||||
|
||||
it { expect(subject).to include(:description) }
|
||||
it { expect(subject.count).to eq(DossierProcedureSerializer.new(dossier).attributes.count + dossier.procedure.types_de_champ.count + dossier.export_entreprise_data.count) }
|
||||
end
|
||||
|
||||
describe '#data_with_champs' do
|
||||
let(:procedure) { create(:procedure, :with_type_de_champ) }
|
||||
let(:dossier) { create(:dossier, :with_entreprise, user: user, procedure: procedure) }
|
||||
subject { dossier.data_with_champs }
|
||||
|
||||
it { expect(subject[0]).to be_a_kind_of(Integer) }
|
||||
it { expect(subject[1]).to be_a_kind_of(Time) }
|
||||
it { expect(subject[2]).to be_a_kind_of(Time) }
|
||||
it { expect(subject[3]).to be_in([true, false]) }
|
||||
it { expect(subject[4]).to be_in([true, false]) }
|
||||
it { expect(subject[5]).to eq("draft") }
|
||||
it { expect(subject.count).to eq(DossierProcedureSerializer.new(dossier).attributes.count + dossier.procedure.types_de_champ.count + dossier.export_entreprise_data.count) }
|
||||
end
|
||||
|
||||
describe '#Dossier.to_csv' do
|
||||
let!(:procedure) { create(:procedure) }
|
||||
let!(:dossier) { create(:dossier, :with_entreprise, user: user, procedure: procedure) }
|
||||
|
||||
subject do
|
||||
dossier_hash = {}
|
||||
dossier_splitted = Dossier.to_csv.split("\n").map { |cell| cell.split(",") }
|
||||
index = 0
|
||||
dossier_splitted[0].each do |column|
|
||||
dossier_hash.store(column.to_sym, dossier_splitted[1][index])
|
||||
index = index + 1
|
||||
end
|
||||
dossier_hash
|
||||
end
|
||||
|
||||
it { expect(subject[:archived]).to eq('false') }
|
||||
it { expect(subject[:etablissement_siret]).to eq('44011762001530') }
|
||||
it { expect(subject[:etablissement_siege_social]).to eq('true') }
|
||||
it { expect(subject[:etablissement_naf]).to eq('4950Z') }
|
||||
it { expect(subject[:etablissement_libelle_naf]).to eq('Transports par conduites') }
|
||||
it { expect(subject[:etablissement_adresse]).to eq('GRTGAZ IMMEUBLE BORA 6 RUE RAOUL NORDLING 92270 BOIS COLOMBES') }
|
||||
it { expect(subject[:etablissement_numero_voie]).to eq('6') }
|
||||
it { expect(subject[:etablissement_type_voie]).to eq('RUE') }
|
||||
it { expect(subject[:etablissement_nom_voie]).to eq('RAOUL NORDLING') }
|
||||
it { expect(subject[:etablissement_complement_adresse]).to eq('IMMEUBLE BORA') }
|
||||
it { expect(subject[:etablissement_code_postal]).to eq('92270') }
|
||||
it { expect(subject[:etablissement_localite]).to eq('BOIS COLOMBES') }
|
||||
it { expect(subject[:etablissement_code_insee_localite]).to eq('92009') }
|
||||
it { expect(subject[:entreprise_siren]).to eq('440117620') }
|
||||
it { expect(subject[:entreprise_capital_social]).to eq('537100000') }
|
||||
it { expect(subject[:entreprise_numero_tva_intracommunautaire]).to eq('FR27440117620') }
|
||||
it { expect(subject[:entreprise_forme_juridique]).to eq("SA à conseil d'administration (s.a.i.)") }
|
||||
it { expect(subject[:entreprise_forme_juridique_code]).to eq('5599') }
|
||||
it { expect(subject[:entreprise_nom_commercial]).to eq('GRTGAZ') }
|
||||
it { expect(subject[:entreprise_raison_sociale]).to eq('GRTGAZ') }
|
||||
it { expect(subject[:entreprise_siret_siege_social]).to eq('44011762001530') }
|
||||
it { expect(subject[:entreprise_code_effectif_entreprise]).to eq('51') }
|
||||
it { expect(subject[:entreprise_date_creation]).to eq('2016-01-28 10:16:29 UTC') }
|
||||
it { expect(subject[:entreprise_nom]).to be_nil }
|
||||
it { expect(subject[:entreprise_prenom]).to be_nil }
|
||||
end
|
||||
|
||||
describe '#Dossier.to_xlsx' do
|
||||
let!(:procedure) { create(:procedure) }
|
||||
let!(:dossier) { create(:dossier, :with_entreprise, user: user, procedure: procedure) }
|
||||
|
||||
subject { Dossier.to_xlsx }
|
||||
|
||||
it { expect(subject).is_a?(String) }
|
||||
end
|
||||
|
||||
describe '#Dossier.to_ods' do
|
||||
let!(:procedure) { create(:procedure) }
|
||||
let!(:dossier) { create(:dossier, :with_entreprise, user: user, procedure: procedure) }
|
||||
|
||||
subject { Dossier.to_ods }
|
||||
|
||||
it { expect(subject).is_a?(String) }
|
||||
end
|
||||
|
||||
describe '#reset!' do
|
||||
let!(:dossier) { create :dossier, :with_entreprise, autorisation_donnees: true }
|
||||
let!(:rna_information) { create :rna_information, entreprise: dossier.entreprise }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue