A gestionnaire can only see procédures publiées

This commit is contained in:
gregoirenovel 2017-07-18 15:26:33 +02:00 committed by Mathieu Magnin
parent 55a4f1288f
commit 7ff7710803
20 changed files with 31 additions and 31 deletions

View file

@ -7,7 +7,7 @@ class Gestionnaire < ActiveRecord::Base
has_one :preference_smart_listing_page, dependent: :destroy
has_many :assign_to, dependent: :destroy
has_many :procedures, through: :assign_to
has_many :procedures, -> { publiees_ou_archivees }, through: :assign_to
has_many :dossiers, -> { state_not_brouillon }, through: :procedures
has_many :followed_dossiers, through: :follows, source: :dossier
has_many :follows

View file

@ -2,7 +2,7 @@ require 'spec_helper'
describe Backoffice::Dossiers::ProcedureController, type: :controller do
let(:gestionnaire) { create :gestionnaire }
let(:procedure) { create :procedure }
let(:procedure) { create :procedure, :published }
let(:archived) { false }
let(:dossier) { create :dossier, procedure: procedure, archived: archived, state: 'initiated'}

View file

@ -4,8 +4,8 @@ describe Backoffice::DossiersController, type: :controller do
before do
@request.env['HTTP_REFERER'] = TPS::Application::URL
end
let(:procedure) { create :procedure }
let(:procedure2) { create :procedure }
let(:procedure) { create :procedure, :published }
let(:procedure2) { create :procedure, :published }
let(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: :initiated) }
let(:dossier2) { create(:dossier, :with_entreprise, procedure: procedure2, state: :initiated) }
@ -38,8 +38,8 @@ describe Backoffice::DossiersController, type: :controller do
context 'when gestionnaire is assign to many proceudure' do
before do
create :assign_to, procedure: create(:procedure), gestionnaire: gestionnaire
create :assign_to, procedure: create(:procedure), gestionnaire: gestionnaire
create :assign_to, procedure: create(:procedure, :published), gestionnaire: gestionnaire
create :assign_to, procedure: create(:procedure, :published), gestionnaire: gestionnaire
end
it { expect(gestionnaire.procedures.count).to eq 3 }

View file

@ -2,7 +2,7 @@ require 'spec_helper'
describe NewGestionnaire::DossiersController, type: :controller do
let(:gestionnaire) { create(:gestionnaire) }
let(:procedure) { create(:procedure, gestionnaires: [gestionnaire]) }
let(:procedure) { create(:procedure, :published, gestionnaires: [gestionnaire]) }
let(:dossier) { create(:dossier, :replied, procedure: procedure) }
describe 'attestation' do
@ -11,7 +11,7 @@ describe NewGestionnaire::DossiersController, type: :controller do
context 'when a dossier has an attestation' do
let(:fake_pdf) { double(read: 'pdf content') }
let!(:dossier) { create(:dossier, :replied, attestation: Attestation.new, procedure: procedure) }
let!(:procedure) { create(:procedure, gestionnaires: [gestionnaire]) }
let!(:procedure) { create(:procedure, :published, gestionnaires: [gestionnaire]) }
let!(:dossier) { create(:dossier, :replied, attestation: Attestation.new, procedure: procedure) }
it 'returns the attestation pdf' do
@ -77,7 +77,7 @@ describe NewGestionnaire::DossiersController, type: :controller do
end
describe "#show" do
let(:procedure) { create(:procedure, gestionnaires: [gestionnaire]) }
let(:procedure) { create(:procedure, :published, gestionnaires: [gestionnaire]) }
let(:dossier){ create(:dossier, :replied, procedure: procedure) }
subject { get :show, params: { procedure_id: procedure.id, dossier_id: dossier.id } }

View file

@ -68,7 +68,7 @@ describe NewGestionnaire::ProceduresController, type: :controller do
subject
end
it { expect(assigns(:procedures)).to include(procedure1, procedure2, procedure3) }
it { expect(assigns(:procedures)).to include(procedure1, procedure2) }
end
context "with dossiers" do

View file

@ -20,7 +20,7 @@ describe RootController, type: :controller do
context 'when gestionnaire is affect to a procedure' do
before do
create :assign_to, procedure: (create :procedure), gestionnaire: gestionnaire
create :assign_to, procedure: (create :procedure, :published), gestionnaire: gestionnaire
end
it { expect(subject).to redirect_to(backoffice_dossiers_procedure_path(id: Procedure.all.first.id)) }

View file

@ -2,8 +2,8 @@ require 'spec_helper'
describe DossiersListFacades do
let(:gestionnaire) { create :gestionnaire }
let(:procedure) { create :procedure, libelle: 'Ma procédure' }
let(:procedure_2) { create :procedure, libelle: 'Ma seconde procédure' }
let(:procedure) { create :procedure, :published, libelle: 'Ma procédure' }
let(:procedure_2) { create :procedure, :published, libelle: 'Ma seconde procédure' }
let!(:preference) { create :preference_list_dossier,
gestionnaire: gestionnaire,

View file

@ -5,7 +5,7 @@ FactoryGirl.define do
before(:create) do |dossier, _evaluator|
unless dossier.procedure
procedure = create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ, :with_type_de_champ_private)
procedure = create(:procedure, :published, :with_two_type_de_piece_justificative, :with_type_de_champ, :with_type_de_champ_private)
dossier.procedure = procedure
end
end

View file

@ -1,7 +1,7 @@
require 'spec_helper'
feature 'add commentaire on backoffice' do
let(:procedure) { create(:procedure) }
let(:procedure) { create(:procedure, :published) }
let(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'updated') }
let(:dossier_id) { dossier.id }
let!(:commentaire) { create(:commentaire, dossier: dossier, email: 'toto@toto.com') }

View file

@ -1,7 +1,7 @@
require 'spec_helper'
feature 'when gestionnaire come to /backoffice and is not authenticated' do
let(:procedure) { create(:procedure) }
let(:procedure) { create(:procedure, :published) }
let!(:dossier) { create(:dossier, procedure: procedure) }
before do
visit backoffice_path

View file

@ -1,7 +1,7 @@
require 'spec_helper'
feature 'backoffice: flux de commentaires' do
let(:procedure) { create(:procedure) }
let(:procedure) { create(:procedure, :published) }
let(:gestionnaire) { create(:gestionnaire) }
let(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'updated') }
let(:dossier_id) { dossier.id }

View file

@ -3,8 +3,8 @@ require 'spec_helper'
feature 'As an Accompagnateur I can navigate and use each functionnality around procedures and their dossiers' do
let(:user) { create(:user) }
let(:gestionnaire) { create(:gestionnaire) }
let(:procedure_1) { create(:procedure, :with_type_de_champ, libelle: 'procedure 1') }
let(:procedure_2) { create(:procedure, :with_type_de_champ, libelle: 'procedure 2') }
let(:procedure_1) { create(:procedure, :published, :with_type_de_champ, libelle: 'procedure 1') }
let(:procedure_2) { create(:procedure, :published, :with_type_de_champ, libelle: 'procedure 2') }
before 'Assign procedures to Accompagnateur and generating dossiers for each' do
create :assign_to, gestionnaire: gestionnaire, procedure: procedure_1

View file

@ -3,7 +3,7 @@ require 'spec_helper'
feature 'usage of pref list dossier lateral panel', js: true do
let(:administrateur) { create(:administrateur) }
let(:gestionnaire) { create(:gestionnaire, administrateurs: [administrateur]) }
let(:procedure) { create(:procedure, administrateur: administrateur) }
let(:procedure) { create(:procedure, :published, administrateur: administrateur) }
before do
create(:dossier, :with_entreprise, procedure: procedure, state: 'updated')

View file

@ -3,7 +3,7 @@ require 'spec_helper'
feature 'usage of pref list dossier lateral panel by procedure', js: true do
let(:administrateur) { create(:administrateur) }
let(:gestionnaire) { create(:gestionnaire, administrateurs: [administrateur]) }
let(:procedure) { create(:procedure, :with_type_de_champ, administrateur: administrateur) }
let(:procedure) { create(:procedure, :published, :with_type_de_champ, administrateur: administrateur) }
before do
create(:dossier, :with_entreprise, procedure: procedure, state: 'updated')

View file

@ -3,8 +3,8 @@ require 'spec_helper'
feature 'on backoffice page', js: true do
let(:administrateur) { create(:administrateur) }
let(:gestionnaire) { create(:gestionnaire, administrateurs: [administrateur]) }
let(:procedure) { create(:procedure, administrateur: administrateur) }
let(:procedure_individual) { create :procedure, libelle: 'procedure individual', administrateur: administrateur, for_individual: true }
let(:procedure) { create(:procedure, :published, administrateur: administrateur) }
let(:procedure_individual) { create :procedure, :published, libelle: 'procedure individual', administrateur: administrateur, for_individual: true }
let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'updated') }
let!(:dossier_individual) { create :dossier, procedure: procedure_individual, state: 'updated' }

View file

@ -11,7 +11,7 @@ feature 'search file on gestionnaire backoffice' do
context 'when gestionnaire is logged in' do
context 'when he click on search button' do
let(:terms) { '' }
let!(:procedure) { create(:procedure, administrateur: administrateur) }
let!(:procedure) { create(:procedure, :published, administrateur: administrateur) }
before do
create :assign_to, gestionnaire: gestionnaire, procedure: procedure

View file

@ -2,9 +2,9 @@ require 'spec_helper'
describe Gestionnaire, type: :model do
let(:admin) { create :administrateur }
let!(:procedure) { create :procedure, administrateur: admin }
let!(:procedure_2) { create :procedure, administrateur: admin }
let!(:procedure_3) { create :procedure, administrateur: admin }
let!(:procedure) { create :procedure, :published, administrateur: admin }
let!(:procedure_2) { create :procedure, :published, administrateur: admin }
let!(:procedure_3) { create :procedure, :published, administrateur: admin }
let(:gestionnaire) { create :gestionnaire, procedure_filter: procedure_filter, administrateurs: [admin] }
let(:procedure_filter) { nil }
let!(:procedure_assign) { create :assign_to, gestionnaire: gestionnaire, procedure: procedure }

View file

@ -19,8 +19,8 @@ describe Search do
create :assign_to, gestionnaire: gestionnaire_2, procedure: procedure_2
end
let(:procedure_1) { create(:procedure, administrateur: administrateur_1) }
let(:procedure_2) { create(:procedure, administrateur: administrateur_2) }
let(:procedure_1) { create(:procedure, :published, administrateur: administrateur_1) }
let(:procedure_2) { create(:procedure, :published, administrateur: administrateur_2) }
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')) }

View file

@ -1,7 +1,7 @@
require 'spec_helper'
describe AccompagnateurService do
let(:procedure) { create :procedure }
let(:procedure) { create :procedure, :published }
let(:accompagnateur) { create :gestionnaire }
let(:accompagnateur_service) { AccompagnateurService.new accompagnateur, procedure, to}

View file

@ -4,7 +4,7 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do
let(:administrateur) { create(:administrateur) }
let(:gestionnaire) { create(:gestionnaire, administrateurs: [administrateur]) }
let!(:procedure) { create(:procedure, administrateur: administrateur) }
let!(:procedure) { create(:procedure, :published, administrateur: administrateur) }
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 }