Merge branch 'dev'
This commit is contained in:
commit
7b047d9eb6
31 changed files with 96 additions and 292 deletions
|
@ -57,6 +57,9 @@ jobs:
|
|||
- run:
|
||||
name: Run rubocop
|
||||
command: bundle exec rubocop -R
|
||||
- run:
|
||||
name: Run brakeman
|
||||
command: bundle exec brakeman -z
|
||||
- run:
|
||||
name: Run haml-lint
|
||||
command: bundle exec haml-lint app/views/
|
||||
|
|
1
Gemfile
1
Gemfile
|
@ -126,6 +126,7 @@ group :test do
|
|||
end
|
||||
|
||||
group :development do
|
||||
gem 'brakeman', require: false
|
||||
# Access an IRB console on exception pages or by using <%= console %> in views
|
||||
gem 'web-console'
|
||||
gem 'rack-handlers'
|
||||
|
|
|
@ -91,6 +91,7 @@ GEM
|
|||
sass (>= 3.3.4)
|
||||
bootstrap-wysihtml5-rails (0.3.3.8)
|
||||
railties (>= 3.0)
|
||||
brakeman (3.7.0)
|
||||
browser (2.3.0)
|
||||
builder (3.2.3)
|
||||
byebug (9.0.6)
|
||||
|
@ -682,6 +683,7 @@ DEPENDENCIES
|
|||
bootstrap-datepicker-rails
|
||||
bootstrap-sass (~> 3.3.5)
|
||||
bootstrap-wysihtml5-rails (~> 0.3.3.8)
|
||||
brakeman
|
||||
browser
|
||||
byebug
|
||||
capybara
|
||||
|
|
|
@ -73,7 +73,8 @@ Pour exécuter les tests de l'application, plusieurs possibilités :
|
|||
|
||||
## Linting
|
||||
|
||||
- Faire tourner RuboCop : `bundle exec rubocop`
|
||||
- Faire tourner RuboCop : `bundle exec rubocop -R`
|
||||
- Faire tourner Brakeman : `bundle exec brakeman -z`
|
||||
- Linter les fichiers HAML : `bundle exec haml-lint app/views/`
|
||||
- Linter les fichiers SCSS : `bundle exec scss-lint app/assets/stylesheets/`
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ class Admin::AccompagnateursController < AdminController
|
|||
array: true
|
||||
|
||||
not_assign_scope = current_administrateur.gestionnaires.where.not(id: assign_scope.ids)
|
||||
not_assign_scope = not_assign_scope.where("email LIKE '%#{params[:filter]}%'") if params[:filter]
|
||||
not_assign_scope = not_assign_scope.where("email LIKE ?", "%#{params[:filter]}%") if params[:filter]
|
||||
|
||||
@accompagnateurs_not_assign = smart_listing_create :accompagnateurs_not_assign,
|
||||
not_assign_scope,
|
||||
|
|
|
@ -43,7 +43,7 @@ class Admin::ProceduresController < AdminController
|
|||
end
|
||||
|
||||
def hide
|
||||
procedure = Procedure.find(params[:id])
|
||||
procedure = current_administrateur.procedures.find(params[:id])
|
||||
procedure.hide!
|
||||
|
||||
flash.notice = "Procédure supprimée, en cas d'erreur contactez nous : contact@tps.apientreprise.fr"
|
||||
|
@ -51,7 +51,7 @@ class Admin::ProceduresController < AdminController
|
|||
end
|
||||
|
||||
def destroy
|
||||
procedure = Procedure.find(params[:id])
|
||||
procedure = current_administrateur.procedures.find(params[:id])
|
||||
|
||||
return render json: {}, status: 401 if procedure.publiee_ou_archivee?
|
||||
|
||||
|
@ -192,7 +192,7 @@ class Admin::ProceduresController < AdminController
|
|||
.joins(', procedures')
|
||||
.where("procedures.id = procedure_paths.procedure_id")
|
||||
.where("procedures.archived_at" => nil)
|
||||
.where("path LIKE '%#{params[:request]}%'")
|
||||
.where("path LIKE ?", "%#{params[:request]}%")
|
||||
.pluck(:path, :administrateur_id)
|
||||
.inject([]) {
|
||||
|acc, value| acc.push({label: value.first, mine: value.second == current_administrateur.id})
|
||||
|
|
|
@ -51,7 +51,7 @@ class Backoffice::DossiersController < Backoffice::DossiersListController
|
|||
end
|
||||
|
||||
def download_dossiers_tps
|
||||
procedure = Procedure.find_by(id: params[:procedure_id])
|
||||
procedure = current_gestionnaire.procedures.find_by(id: params[:procedure_id])
|
||||
export = procedure.generate_export
|
||||
|
||||
respond_to do |format|
|
||||
|
|
|
@ -38,7 +38,7 @@ class DossierFacades
|
|||
end
|
||||
|
||||
def commentaires
|
||||
@dossier.ordered_commentaires.where(champ_id: @champ_id).decorate
|
||||
@dossier.commentaires.where(champ_id: @champ_id).decorate
|
||||
end
|
||||
|
||||
def procedure
|
||||
|
|
|
@ -128,10 +128,6 @@ class Dossier < ActiveRecord::Base
|
|||
champs.joins(', types_de_piece_justificative').where("pieces_justificatives.type_de_piece_justificative_id = types_de_piece_justificative.id AND types_de_piece_justificative.procedure_id = #{procedure.id}").order('order_place ASC')
|
||||
end
|
||||
|
||||
def ordered_commentaires
|
||||
commentaires.order(created_at: :desc)
|
||||
end
|
||||
|
||||
def next_step! role, action, motivation = nil
|
||||
unless %w(initiate follow update comment receive refuse without_continuation close).include?(action)
|
||||
fail 'action is not valid'
|
||||
|
@ -242,8 +238,8 @@ class Dossier < ActiveRecord::Base
|
|||
def data_with_champs
|
||||
serialized_dossier = DossierTableExportSerializer.new(self)
|
||||
data = serialized_dossier.attributes.values
|
||||
data += self.champs.order('type_de_champ_id ASC').map(&:value)
|
||||
data += self.champs_private.order('type_de_champ_id ASC').map(&:value)
|
||||
data += self.ordered_champs.map(&:value)
|
||||
data += self.ordered_champs_private.map(&:value)
|
||||
data += self.export_entreprise_data.values
|
||||
return data
|
||||
end
|
||||
|
@ -251,8 +247,8 @@ class Dossier < ActiveRecord::Base
|
|||
def export_headers
|
||||
serialized_dossier = DossierTableExportSerializer.new(self)
|
||||
headers = serialized_dossier.attributes.keys
|
||||
headers += self.procedure.types_de_champ.order('id ASC').map { |types_de_champ| types_de_champ.libelle.parameterize.underscore.to_sym }
|
||||
headers += self.procedure.types_de_champ_private.order('id ASC').map { |types_de_champ| types_de_champ.libelle.parameterize.underscore.to_sym }
|
||||
headers += self.procedure.types_de_champ.order(:order_place).map { |types_de_champ| types_de_champ.libelle.parameterize.underscore.to_sym }
|
||||
headers += self.procedure.types_de_champ_private.order(:order_place).map { |types_de_champ| types_de_champ.libelle.parameterize.underscore.to_sym }
|
||||
headers += self.export_entreprise_data.keys
|
||||
return headers
|
||||
end
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
require 'spec_helper'
|
||||
require 'uri'
|
||||
|
||||
describe Admin::ProceduresController, type: :controller do
|
||||
let(:admin) { create(:administrateur) }
|
||||
|
@ -54,9 +55,9 @@ describe Admin::ProceduresController, type: :controller do
|
|||
end
|
||||
|
||||
describe 'DELETE #destroy' do
|
||||
let(:procedure_draft) { create :procedure, published_at: nil, archived_at: nil }
|
||||
let(:procedure_published) { create :procedure, published_at: Time.now, archived_at: nil }
|
||||
let(:procedure_archived) { create :procedure, published_at: nil, archived_at: Time.now }
|
||||
let(:procedure_draft) { create :procedure, administrateur: admin, published_at: nil, archived_at: nil }
|
||||
let(:procedure_published) { create :procedure, administrateur: admin, published_at: Time.now, archived_at: nil }
|
||||
let(:procedure_archived) { create :procedure, administrateur: admin, published_at: nil, archived_at: Time.now }
|
||||
|
||||
subject { delete :destroy, params: {id: procedure.id} }
|
||||
|
||||
|
@ -91,6 +92,14 @@ describe Admin::ProceduresController, type: :controller do
|
|||
|
||||
it { expect(subject.status).to eq 401 }
|
||||
end
|
||||
|
||||
context "when administrateur does not own the procedure" do
|
||||
let(:procedure_not_owned) { create :procedure, administrateur: create(:administrateur), published_at: nil, archived_at: nil }
|
||||
|
||||
subject { delete :destroy, params: {id: procedure_not_owned.id} }
|
||||
|
||||
it { expect{ subject }.to raise_error(ActiveRecord::RecordNotFound) }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #edit' do
|
||||
|
@ -468,7 +477,7 @@ describe Admin::ProceduresController, type: :controller do
|
|||
subject
|
||||
end
|
||||
|
||||
subject { get :path_list, params: {request: procedure2.path} }
|
||||
subject { get :path_list, params: { request: URI.encode(procedure2.path) } }
|
||||
|
||||
it { expect(response.status).to eq(200) }
|
||||
it { expect(body.size).to eq(1) }
|
||||
|
@ -527,4 +536,25 @@ describe Admin::ProceduresController, type: :controller do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "POST hide" do
|
||||
subject { post :hide, params: { id: procedure.id } }
|
||||
|
||||
context "when procedure is not owned by administrateur" do
|
||||
let!(:procedure) { create :procedure, administrateur: create(:administrateur) }
|
||||
|
||||
it { expect{ subject }.to raise_error(ActiveRecord::RecordNotFound) }
|
||||
end
|
||||
|
||||
context "when procedure is owned by administrateur" do
|
||||
let!(:procedure) { create :procedure, administrateur: admin }
|
||||
|
||||
before do
|
||||
subject
|
||||
procedure.reload
|
||||
end
|
||||
|
||||
it { expect(procedure.hidden_at).to_not eq nil }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -227,8 +227,8 @@ describe API::V1::DossiersController do
|
|||
subject { super()[:type_de_champ] }
|
||||
|
||||
it { expect(subject.keys.include?(:id)).to be_truthy }
|
||||
it { expect(subject[:libelle]).to eq('Description') }
|
||||
it { expect(subject[:description]).to eq('description de votre projet') }
|
||||
it { expect(subject[:libelle]).to include('Libelle du champ') }
|
||||
it { expect(subject[:description]).to include('description du champ') }
|
||||
it { expect(subject.keys.include?(:order_place)).to be_truthy }
|
||||
it { expect(subject[:type_champ]).to eq('text') }
|
||||
end
|
||||
|
@ -260,8 +260,8 @@ describe API::V1::DossiersController do
|
|||
subject { super()[:type_de_champ] }
|
||||
|
||||
it { expect(subject.keys.include?(:id)).to be_truthy }
|
||||
it { expect(subject[:libelle]).to eq('Description') }
|
||||
it { expect(subject[:description]).to eq('description de votre projet') }
|
||||
it { expect(subject[:libelle]).to include('Libelle champ privé') }
|
||||
it { expect(subject[:description]).to include('description du champ privé') }
|
||||
it { expect(subject.keys.include?(:order_place)).to be_truthy }
|
||||
it { expect(subject[:type_champ]).to eq('text') }
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
FactoryGirl.define do
|
||||
factory :type_de_champ_private do
|
||||
libelle 'Description'
|
||||
description 'description de votre projet'
|
||||
sequence(:libelle) { |n| "Libelle champ privé #{n}" }
|
||||
sequence(:description) { |n| "description du champ privé #{n}" }
|
||||
type_champ 'text'
|
||||
order_place 1
|
||||
mandatory false
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
FactoryGirl.define do
|
||||
factory :type_de_champ_public do
|
||||
libelle 'Description'
|
||||
description 'description de votre projet'
|
||||
sequence(:libelle) { |n| "Libelle du champ #{n}" }
|
||||
sequence(:description) { |n| "description du champ #{n}" }
|
||||
type_champ 'text'
|
||||
order_place 1
|
||||
mandatory false
|
||||
|
|
|
@ -1,22 +1,6 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Administrateur, type: :model do
|
||||
describe 'database column' do
|
||||
it { is_expected.to have_db_column(:email) }
|
||||
it { is_expected.to have_db_column(:encrypted_password) }
|
||||
it { is_expected.to have_db_column(:reset_password_token) }
|
||||
it { is_expected.to have_db_column(:reset_password_sent_at) }
|
||||
it { is_expected.to have_db_column(:remember_created_at) }
|
||||
it { is_expected.to have_db_column(:sign_in_count) }
|
||||
it { is_expected.to have_db_column(:current_sign_in_at) }
|
||||
it { is_expected.to have_db_column(:last_sign_in_at) }
|
||||
it { is_expected.to have_db_column(:current_sign_in_ip) }
|
||||
it { is_expected.to have_db_column(:last_sign_in_ip) }
|
||||
it { is_expected.to have_db_column(:created_at) }
|
||||
it { is_expected.to have_db_column(:updated_at) }
|
||||
it { is_expected.to have_db_column(:api_token) }
|
||||
end
|
||||
|
||||
describe 'assocations' do
|
||||
it { is_expected.to have_and_belong_to_many(:gestionnaires) }
|
||||
it { is_expected.to have_many(:procedures) }
|
||||
|
|
|
@ -1,18 +1,6 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Cerfa do
|
||||
describe 'database columns' do
|
||||
it { is_expected.to have_db_column(:content) }
|
||||
it { is_expected.to have_db_column(:original_filename) }
|
||||
it { is_expected.to have_db_column(:content_secure_token) }
|
||||
it { is_expected.to have_db_column(:created_at) }
|
||||
end
|
||||
|
||||
describe 'associations' do
|
||||
it { is_expected.to belong_to(:dossier) }
|
||||
it { is_expected.to belong_to(:user) }
|
||||
end
|
||||
|
||||
describe 'empty?', vcr: { cassette_name: 'models_cerfa_empty' } do
|
||||
subject { create(:cerfa, content: content) }
|
||||
context 'when content exist' do
|
||||
|
|
|
@ -1,19 +1,4 @@
|
|||
shared_examples 'champ_spec' do
|
||||
describe 'database columns' do
|
||||
it { is_expected.to have_db_column(:value) }
|
||||
end
|
||||
|
||||
describe 'associations' do
|
||||
it { is_expected.to belong_to(:dossier) }
|
||||
it { is_expected.to belong_to(:type_de_champ) }
|
||||
end
|
||||
|
||||
describe 'delegation' do
|
||||
it { is_expected.to delegate_method(:libelle).to(:type_de_champ) }
|
||||
it { is_expected.to delegate_method(:type_champ).to(:type_de_champ) }
|
||||
it { is_expected.to delegate_method(:order_place).to(:type_de_champ) }
|
||||
end
|
||||
|
||||
describe 'mandatory_and_blank?' do
|
||||
let(:type_de_champ) { TypeDeChamp.new(mandatory: mandatory) }
|
||||
let(:champ) { Champ.new(type_de_champ: type_de_champ, value: value) }
|
||||
|
|
|
@ -3,40 +3,6 @@ require 'spec_helper'
|
|||
describe Dossier do
|
||||
let(:user) { create(:user) }
|
||||
|
||||
describe 'database columns' do
|
||||
it { is_expected.to have_db_column(:autorisation_donnees) }
|
||||
it { is_expected.to have_db_column(:created_at) }
|
||||
it { is_expected.to have_db_column(:updated_at) }
|
||||
it { is_expected.to have_db_column(:state) }
|
||||
it { is_expected.to have_db_column(:procedure_id) }
|
||||
it { is_expected.to have_db_column(:user_id) }
|
||||
end
|
||||
|
||||
describe 'associations' do
|
||||
it { is_expected.to belong_to(:procedure) }
|
||||
it { is_expected.to have_many(:pieces_justificatives) }
|
||||
it { is_expected.to have_many(:champs) }
|
||||
it { is_expected.to have_many(:commentaires) }
|
||||
it { is_expected.to have_many(:quartier_prioritaires) }
|
||||
it { is_expected.to have_many(:cadastres) }
|
||||
it { is_expected.to have_many(:cerfa) }
|
||||
it { is_expected.to have_one(:etablissement) }
|
||||
it { is_expected.to have_one(:entreprise) }
|
||||
it { is_expected.to have_one(:individual) }
|
||||
it { is_expected.to belong_to(:user) }
|
||||
it { is_expected.to have_many(:invites) }
|
||||
it { is_expected.to have_many(:follows) }
|
||||
it { is_expected.to have_many(:notifications) }
|
||||
end
|
||||
|
||||
describe 'delegation' do
|
||||
it { is_expected.to delegate_method(:siren).to(:entreprise) }
|
||||
it { is_expected.to delegate_method(:siret).to(:etablissement) }
|
||||
it { is_expected.to delegate_method(:types_de_piece_justificative).to(:procedure) }
|
||||
it { is_expected.to delegate_method(:types_de_champ).to(:procedure) }
|
||||
it { is_expected.to delegate_method(:france_connect_information).to(:user) }
|
||||
end
|
||||
|
||||
describe 'methods' do
|
||||
let(:dossier) { create(:dossier, :with_entreprise, user: user) }
|
||||
|
||||
|
@ -497,7 +463,7 @@ describe Dossier do
|
|||
describe '#export_headers' do
|
||||
subject { dossier.export_headers }
|
||||
|
||||
it { expect(subject).to include(:description) }
|
||||
it { expect(subject).to include(dossier.champs.first.libelle.parameterize.underscore.to_sym) }
|
||||
it { expect(subject).to include(:individual_gender) }
|
||||
it { expect(subject).to include(:individual_nom) }
|
||||
it { expect(subject).to include(:individual_prenom) }
|
||||
|
|
|
@ -1,14 +1,6 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe DropDownList do
|
||||
describe 'database columns' do
|
||||
it { is_expected.to have_db_column(:value) }
|
||||
end
|
||||
|
||||
describe 'associations' do
|
||||
it { is_expected.to belong_to(:type_de_champ) }
|
||||
end
|
||||
|
||||
let(:dropdownlist) { create :drop_down_list, value: value }
|
||||
|
||||
describe '#options' do
|
||||
|
|
|
@ -1,24 +1,4 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Entreprise do
|
||||
describe 'databse columns' do
|
||||
it { is_expected.to have_db_column(:siren) }
|
||||
it { is_expected.to have_db_column(:capital_social) }
|
||||
it { is_expected.to have_db_column(:numero_tva_intracommunautaire) }
|
||||
it { is_expected.to have_db_column(:forme_juridique) }
|
||||
it { is_expected.to have_db_column(:forme_juridique_code) }
|
||||
it { is_expected.to have_db_column(:nom_commercial) }
|
||||
it { is_expected.to have_db_column(:raison_sociale) }
|
||||
it { is_expected.to have_db_column(:siret_siege_social) }
|
||||
it { is_expected.to have_db_column(:code_effectif_entreprise) }
|
||||
it { is_expected.to have_db_column(:date_creation) }
|
||||
it { is_expected.to have_db_column(:nom) }
|
||||
it { is_expected.to have_db_column(:prenom) }
|
||||
end
|
||||
|
||||
describe 'associations' do
|
||||
it { is_expected.to belong_to(:dossier) }
|
||||
it { is_expected.to have_one(:etablissement) }
|
||||
it { is_expected.to have_one(:rna_information) }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,27 +1,6 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Etablissement do
|
||||
describe 'database columns' do
|
||||
it { is_expected.to have_db_column(:siret) }
|
||||
it { is_expected.to have_db_column(:siege_social) }
|
||||
it { is_expected.to have_db_column(:naf) }
|
||||
it { is_expected.to have_db_column(:libelle_naf) }
|
||||
it { is_expected.to have_db_column(:adresse) }
|
||||
it { is_expected.to have_db_column(:numero_voie) }
|
||||
it { is_expected.to have_db_column(:type_voie) }
|
||||
it { is_expected.to have_db_column(:nom_voie) }
|
||||
it { is_expected.to have_db_column(:complement_adresse) }
|
||||
it { is_expected.to have_db_column(:code_postal) }
|
||||
it { is_expected.to have_db_column(:localite) }
|
||||
it { is_expected.to have_db_column(:code_insee_localite) }
|
||||
end
|
||||
|
||||
describe 'associations' do
|
||||
it { is_expected.to belong_to(:dossier) }
|
||||
it { is_expected.to belong_to(:entreprise) }
|
||||
it { is_expected.to have_many(:exercices) }
|
||||
end
|
||||
|
||||
describe '#geo_adresse' do
|
||||
let(:etablissement) { create(:etablissement) }
|
||||
|
||||
|
|
|
@ -1,13 +1,4 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Exercice do
|
||||
describe 'database columns' do
|
||||
it { is_expected.to have_db_column(:ca) }
|
||||
it { is_expected.to have_db_column(:dateFinExercice) }
|
||||
it { is_expected.to have_db_column(:date_fin_exercice_timestamp) }
|
||||
end
|
||||
|
||||
describe 'associations' do
|
||||
it { is_expected.to belong_to(:etablissement) }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,20 +1,6 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe FranceConnectInformation, type: :model do
|
||||
describe 'database columns' do
|
||||
it { is_expected.to have_db_column(:given_name) }
|
||||
it { is_expected.to have_db_column(:family_name) }
|
||||
it { is_expected.to have_db_column(:email_france_connect) }
|
||||
it { is_expected.to have_db_column(:birthdate) }
|
||||
it { is_expected.to have_db_column(:gender) }
|
||||
it { is_expected.to have_db_column(:birthplace) }
|
||||
it { is_expected.to have_db_column(:france_connect_particulier_id) }
|
||||
end
|
||||
|
||||
describe 'associations' do
|
||||
it { is_expected.to belong_to(:user) }
|
||||
end
|
||||
|
||||
describe 'validation' do
|
||||
context 'france_connect_particulier_id' do
|
||||
it { is_expected.not_to allow_value(nil).for(:france_connect_particulier_id) }
|
||||
|
|
|
@ -13,30 +13,6 @@ describe Gestionnaire, type: :model do
|
|||
create :assign_to, gestionnaire: gestionnaire, procedure: procedure_2
|
||||
end
|
||||
|
||||
describe 'database column' do
|
||||
it { is_expected.to have_db_column(:email) }
|
||||
it { is_expected.to have_db_column(:encrypted_password) }
|
||||
it { is_expected.to have_db_column(:reset_password_token) }
|
||||
it { is_expected.to have_db_column(:reset_password_sent_at) }
|
||||
it { is_expected.to have_db_column(:remember_created_at) }
|
||||
it { is_expected.to have_db_column(:sign_in_count) }
|
||||
it { is_expected.to have_db_column(:current_sign_in_at) }
|
||||
it { is_expected.to have_db_column(:last_sign_in_at) }
|
||||
it { is_expected.to have_db_column(:current_sign_in_ip) }
|
||||
it { is_expected.to have_db_column(:last_sign_in_ip) }
|
||||
it { is_expected.to have_db_column(:created_at) }
|
||||
it { is_expected.to have_db_column(:updated_at) }
|
||||
end
|
||||
|
||||
describe 'association' do
|
||||
it { is_expected.to have_one(:preference_smart_listing_page) }
|
||||
it { is_expected.to have_and_belong_to_many(:administrateurs) }
|
||||
it { is_expected.to have_many(:procedures) }
|
||||
it { is_expected.to have_many(:dossiers) }
|
||||
it { is_expected.to have_many(:follows) }
|
||||
it { is_expected.to have_many(:preference_list_dossiers) }
|
||||
end
|
||||
|
||||
describe '#toggle_follow_dossier' do
|
||||
let!(:dossier) { create :dossier, procedure: procedure }
|
||||
|
||||
|
|
|
@ -1,15 +1,6 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Invite do
|
||||
describe 'database columns' do
|
||||
it { is_expected.to have_db_column(:email) }
|
||||
end
|
||||
|
||||
describe 'associations' do
|
||||
it { is_expected.to belong_to(:dossier) }
|
||||
it { is_expected.to belong_to(:user) }
|
||||
end
|
||||
|
||||
describe 'an email can be used for multiple dossier' do
|
||||
let(:email1) { 'plop@octo.com' }
|
||||
|
||||
|
|
|
@ -1,20 +1,6 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe PieceJustificative do
|
||||
describe 'database columns' do
|
||||
it { is_expected.to have_db_column(:content) }
|
||||
it { is_expected.to have_db_column(:original_filename) }
|
||||
it { is_expected.to have_db_column(:content_secure_token) }
|
||||
it { is_expected.to have_db_column(:created_at) }
|
||||
end
|
||||
|
||||
describe 'associations' do
|
||||
it { is_expected.to belong_to(:dossier) }
|
||||
it { is_expected.to belong_to(:type_de_piece_justificative) }
|
||||
it { is_expected.to belong_to(:user) }
|
||||
it { is_expected.to have_one(:commentaire) }
|
||||
end
|
||||
|
||||
describe 'validations' do
|
||||
context 'content' do
|
||||
it { is_expected.not_to allow_value(nil).for(:content) }
|
||||
|
@ -22,11 +8,6 @@ describe PieceJustificative do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'delegation' do
|
||||
it { is_expected.to delegate_method(:libelle).to(:type_de_piece_justificative) }
|
||||
it { is_expected.to delegate_method(:api_entreprise).to(:type_de_piece_justificative) }
|
||||
end
|
||||
|
||||
describe '#empty?', vcr: { cassette_name: 'model_piece_justificative' } do
|
||||
let(:piece_justificative) { create(:piece_justificative, content: content) }
|
||||
subject { piece_justificative.empty? }
|
||||
|
|
|
@ -306,7 +306,7 @@ describe PreferenceListDossier do
|
|||
describe 'first champs' do
|
||||
subject { super()["type_de_champ_#{procedure.types_de_champ.first.id}"] }
|
||||
|
||||
it { expect(subject[:libelle]).to eq 'Description' }
|
||||
it { expect(subject[:libelle]).to eq procedure.types_de_champ.first.libelle }
|
||||
it { expect(subject[:table]).to eq 'champs' }
|
||||
it { expect(subject[:attr]).to eq procedure.types_de_champ.first.id }
|
||||
it { expect(subject[:attr_decorate]).to eq 'value' }
|
||||
|
@ -324,7 +324,7 @@ describe PreferenceListDossier do
|
|||
describe 'first champs' do
|
||||
subject { super()["type_de_champ_private_#{procedure.types_de_champ_private.first.id}"] }
|
||||
|
||||
it { expect(subject[:libelle]).to eq 'Description' }
|
||||
it { expect(subject[:libelle]).to eq procedure.types_de_champ_private.first.libelle }
|
||||
it { expect(subject[:table]).to eq 'champs_private' }
|
||||
it { expect(subject[:attr]).to eq procedure.types_de_champ_private.first.id }
|
||||
it { expect(subject[:attr_decorate]).to eq 'value' }
|
||||
|
|
|
@ -336,6 +336,39 @@ describe Procedure do
|
|||
|
||||
it { expect(subject[:data].size).to eq(2) }
|
||||
it { expect(subject[:headers]).to eq(dossier.export_headers) }
|
||||
|
||||
context 'with ordered champs' do
|
||||
let(:tc_2) { create(:type_de_champ_public, order_place: 2) }
|
||||
let(:tc_1) { create(:type_de_champ_public, order_place: 1) }
|
||||
let(:tcp_2) { create(:type_de_champ_private, order_place: 2) }
|
||||
let(:tcp_1) { create(:type_de_champ_private, order_place: 1) }
|
||||
|
||||
before do
|
||||
procedure.types_de_champ << tc_2 << tc_1
|
||||
procedure.types_de_champ_private << tcp_2 << tcp_1
|
||||
|
||||
dossier.build_default_champs
|
||||
dossier.champs.find_by(type_de_champ: tc_1).update_attributes(value: "value 1")
|
||||
dossier.champs.find_by(type_de_champ: tc_2).update_attributes(value: "value 2")
|
||||
dossier.champs_private.find_by(type_de_champ: tcp_1).update_attributes(value: "private value 1")
|
||||
dossier.champs_private.find_by(type_de_champ: tcp_2).update_attributes(value: "private value 2")
|
||||
|
||||
dossier2.build_default_champs
|
||||
dossier2.champs.find_by(type_de_champ: tc_1).update_attributes(value: "value 1")
|
||||
dossier2.champs.find_by(type_de_champ: tc_2).update_attributes(value: "value 2")
|
||||
dossier2.champs_private.find_by(type_de_champ: tcp_1).update_attributes(value: "private value 1")
|
||||
dossier2.champs_private.find_by(type_de_champ: tcp_2).update_attributes(value: "private value 2")
|
||||
end
|
||||
|
||||
it { expect(subject[:headers].index(tc_1.libelle.parameterize.underscore.to_sym)).to be < subject[:headers].index(tc_2.libelle.parameterize.underscore.to_sym) }
|
||||
it { expect(subject[:headers].index(tcp_1.libelle.parameterize.underscore.to_sym)).to be < subject[:headers].index(tcp_2.libelle.parameterize.underscore.to_sym) }
|
||||
|
||||
it { expect(subject[:data][0].index("value 1")).to be < subject[:data].first.index("value 2") }
|
||||
it { expect(subject[:data][0].index("private value 1")).to be < subject[:data].first.index("private value 2") }
|
||||
|
||||
it { expect(subject[:data][1].index("value 1")).to be < subject[:data].first.index("value 2") }
|
||||
it { expect(subject[:data][1].index("private value 1")).to be < subject[:data].first.index("private value 2") }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when there is a draft dossier' do
|
||||
|
|
|
@ -1,16 +1,4 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe RNAInformation do
|
||||
describe 'databse columns' do
|
||||
it { is_expected.to have_db_column(:association_id) }
|
||||
it { is_expected.to have_db_column(:titre) }
|
||||
it { is_expected.to have_db_column(:objet) }
|
||||
it { is_expected.to have_db_column(:date_creation) }
|
||||
it { is_expected.to have_db_column(:date_publication) }
|
||||
it { is_expected.to have_db_column(:date_declaration) }
|
||||
end
|
||||
|
||||
describe 'associations' do
|
||||
it { is_expected.to belong_to(:entreprise) }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,16 +1,4 @@
|
|||
shared_examples 'type_de_champ_spec' do
|
||||
describe 'database columns' do
|
||||
it { is_expected.to have_db_column(:libelle) }
|
||||
it { is_expected.to have_db_column(:type_champ) }
|
||||
it { is_expected.to have_db_column(:order_place) }
|
||||
it { is_expected.to have_db_column(:description) }
|
||||
end
|
||||
|
||||
describe 'associations' do
|
||||
it { is_expected.to belong_to(:procedure) }
|
||||
it { is_expected.to have_many(:champ) }
|
||||
end
|
||||
|
||||
describe 'validation' do
|
||||
context 'libelle' do
|
||||
it { is_expected.not_to allow_value(nil).for(:libelle) }
|
||||
|
|
|
@ -3,21 +3,6 @@ require 'spec_helper'
|
|||
describe TypeDePieceJustificative do
|
||||
let!(:procedure) { create(:procedure) }
|
||||
|
||||
describe 'database columns' do
|
||||
it { is_expected.to have_db_column(:libelle) }
|
||||
it { is_expected.to have_db_column(:description) }
|
||||
it { is_expected.to have_db_column(:api_entreprise) }
|
||||
it { is_expected.to have_db_column(:created_at) }
|
||||
it { is_expected.to have_db_column(:updated_at) }
|
||||
it { is_expected.to have_db_column(:order_place) }
|
||||
it { is_expected.to have_db_column(:lien_demarche) }
|
||||
end
|
||||
|
||||
describe 'associations' do
|
||||
it { is_expected.to have_many(:pieces_justificatives) }
|
||||
it { is_expected.to belong_to(:procedure) }
|
||||
end
|
||||
|
||||
describe 'validation' do
|
||||
context 'libelle' do
|
||||
it { is_expected.not_to allow_value(nil).for(:libelle) }
|
||||
|
|
|
@ -1,28 +1,6 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe User, type: :model do
|
||||
describe 'database columns' do
|
||||
it { is_expected.to have_db_column(:email) }
|
||||
it { is_expected.to have_db_column(:encrypted_password) }
|
||||
it { is_expected.to have_db_column(:reset_password_token) }
|
||||
it { is_expected.to have_db_column(:reset_password_sent_at) }
|
||||
it { is_expected.to have_db_column(:remember_created_at) }
|
||||
it { is_expected.to have_db_column(:sign_in_count) }
|
||||
it { is_expected.to have_db_column(:current_sign_in_at) }
|
||||
it { is_expected.to have_db_column(:last_sign_in_at) }
|
||||
it { is_expected.to have_db_column(:current_sign_in_ip) }
|
||||
it { is_expected.to have_db_column(:last_sign_in_ip) }
|
||||
it { is_expected.to have_db_column(:created_at) }
|
||||
it { is_expected.to have_db_column(:updated_at) }
|
||||
it { is_expected.to have_db_column(:siret) }
|
||||
it { is_expected.to have_db_column(:loged_in_with_france_connect) }
|
||||
end
|
||||
describe 'associations' do
|
||||
it { is_expected.to have_many(:dossiers) }
|
||||
it { is_expected.to have_many(:invites) }
|
||||
it { is_expected.to have_many(:piece_justificative) }
|
||||
it { is_expected.to have_many(:cerfa) }
|
||||
end
|
||||
describe '#find_for_france_connect' do
|
||||
let(:siret) { '00000000000000' }
|
||||
context 'when user exist' do
|
||||
|
|
Loading…
Reference in a new issue