Delete on Factory Dossier :with_user

This commit is contained in:
Xavier J 2016-01-18 17:18:04 +01:00
parent 1551ae82cd
commit e0d980e804
27 changed files with 55 additions and 60 deletions

View file

@ -18,7 +18,7 @@ describe Admin::PiecesJustificativesController, type: :controller do
end
context 'when procedure have at least a file' do
let!(:dossier) { create(:dossier, :with_user, procedure: procedure, state: :initiated) }
let!(:dossier) { create(:dossier, procedure: procedure, state: :initiated) }
it { is_expected.to redirect_to admin_procedure_path id: procedure_id }
end

View file

@ -67,7 +67,7 @@ describe Admin::ProceduresController, type: :controller do
end
context 'when procedure have at least a file' do
let!(:dossier) { create(:dossier, :with_user, procedure: procedure, state: :initiated) }
let!(:dossier) { create(:dossier, procedure: procedure, state: :initiated) }
it { is_expected.to redirect_to admin_procedure_path id: procedure_id }
end

View file

@ -20,7 +20,7 @@ describe Admin::TypesDeChampController, type: :controller do
end
context 'when procedure have at least a file' do
let!(:dossier) { create(:dossier, :with_user, procedure: procedure, state: :initiated) }
let!(:dossier) { create(:dossier, procedure: procedure, state: :initiated) }
it { is_expected.to redirect_to admin_procedure_path id: procedure_id }
end

View file

@ -1,7 +1,7 @@
require 'spec_helper'
describe Backoffice::CommentairesController, type: :controller do
let(:dossier) { create(:dossier, :with_user) }
let(:dossier) { create(:dossier) }
let(:dossier_id) { dossier.id }
let(:email_commentaire) { 'test@test.com' }
let(:texte_commentaire) { 'Commentaire de test' }

View file

@ -1,8 +1,8 @@
require 'rails_helper'
describe Backoffice::DossiersController, type: :controller do
let(:dossier) { create(:dossier, :with_entreprise, :with_user) }
let(:dossier_archived) { create(:dossier, :with_entreprise, :with_user, archived: true) }
let(:dossier) { create(:dossier, :with_entreprise) }
let(:dossier_archived) { create(:dossier, :with_entreprise, archived: true) }
let(:dossier_id) { dossier.id }
let(:bad_dossier_id) { Dossier.count + 10 }

View file

@ -1,7 +1,7 @@
require 'spec_helper'
describe Users::CommentairesController, type: :controller do
let(:dossier) { create(:dossier, :with_user) }
let(:dossier) { create(:dossier) }
let(:dossier_id) { dossier.id }
let(:email_commentaire) { 'test@test.com' }
let(:texte_commentaire) { 'Commentaire de test' }

View file

@ -5,9 +5,9 @@ RSpec.describe Users::CarteController, type: :controller do
let(:module_api_carto) { create(:module_api_carto, :with_api_carto) }
let(:procedure) { create(:procedure, module_api_carto: module_api_carto) }
let(:dossier) { create(:dossier, :with_user, procedure: procedure) }
let(:dossier) { create(:dossier, procedure: procedure) }
let(:dossier_with_no_carto) { create(:dossier, :with_user, :with_procedure) }
let(:dossier_with_no_carto) { create(:dossier, :with_procedure) }
let!(:entreprise) { create(:entreprise, dossier: dossier) }
let!(:etablissement) { create(:etablissement, dossier: dossier) }
let(:bad_dossier_id) { Dossier.count + 1000 }
@ -60,7 +60,7 @@ RSpec.describe Users::CarteController, type: :controller do
end
context 'En train de modifier la localisation' do
let(:dossier) { create(:dossier, :with_procedure, :with_user, state: 'initiated') }
let(:dossier) { create(:dossier, :with_procedure, state: 'initiated') }
before do
post :save, dossier_id: dossier.id, json_latlngs: ''
end
@ -99,7 +99,7 @@ RSpec.describe Users::CarteController, type: :controller do
context 'when json_latlngs params is empty' do
context 'when dossier have quartier prioritaire in database' do
let!(:dossier) { create(:dossier, :with_user, :with_procedure, :with_two_quartier_prioritaires) }
let!(:dossier) { create(:dossier, :with_procedure, :with_two_quartier_prioritaires) }
before do
dossier.reload
@ -146,7 +146,7 @@ RSpec.describe Users::CarteController, type: :controller do
context 'when json_latlngs params is empty' do
context 'when dossier have cadastres in database' do
let!(:dossier) { create(:dossier, :with_user, :with_procedure, :with_two_cadastres) }
let!(:dossier) { create(:dossier, :with_procedure, :with_two_cadastres) }
before do
dossier.reload
@ -190,7 +190,7 @@ RSpec.describe Users::CarteController, type: :controller do
describe '#get_position' do
context 'Geocodeur renvoie des positions nil' do
let(:etablissement) { create(:etablissement, adresse: bad_adresse, numero_voie: 'dzj', type_voie: 'fzjfk', nom_voie: 'hdidjkz', complement_adresse: 'fjef', code_postal: 'fjeiefk', localite: 'zjfkfz') }
let(:dossier) { create(:dossier, :with_procedure, :with_user, etablissement: etablissement) }
let(:dossier) { create(:dossier, :with_procedure, etablissement: etablissement) }
before do
stub_request(:get, /http:\/\/api-adresse[.]data[.]gouv[.]fr\/search[?]limit=1&q=/)
.to_return(status: 200, body: '{"query": "babouba", "version": "draft", "licence": "ODbL 1.0", "features": [], "type": "FeatureCollection", "attribution": "BAN"}', headers: {})

View file

@ -1,7 +1,7 @@
require 'spec_helper'
describe Users::RecapitulatifController, type: :controller do
let(:dossier) { create(:dossier, :with_user, :with_procedure) }
let(:dossier) { create(:dossier, :with_procedure) }
let(:bad_dossier_id) { Dossier.count + 100000 }
before do

View file

@ -1,7 +1,7 @@
require 'spec_helper'
describe DossierDecorator do
let(:dossier) { create(:dossier, :with_user, updated_at: Time.new(2015, 12, 24, 14, 10)) }
let(:dossier) { create(:dossier, updated_at: Time.new(2015, 12, 24, 14, 10)) }
subject { dossier.decorate }
describe 'last_update' do

View file

@ -3,13 +3,13 @@ require 'spec_helper'
describe AdminProceduresShowFacades do
let!(:procedure) { create(:procedure) }
let!(:dossier_0) { create(:dossier, :with_user, procedure: procedure, state: 'draft') }
let!(:dossier_1) { create(:dossier, :with_user, procedure: procedure, state: 'initiated') }
let!(:dossier_2) { create(:dossier, :with_user, procedure: procedure, state: 'validated') }
let!(:dossier_3) { create(:dossier, :with_user, procedure: procedure, state: 'validated') }
let!(:dossier_4) { create(:dossier, :with_user, procedure: procedure, archived: true, state: 'validated') }
let!(:dossier_5) { create(:dossier, :with_user, procedure: procedure, archived: true, state: 'validated') }
let!(:dossier_6) { create(:dossier, :with_user, procedure: procedure, archived: true, state: 'initiated') }
let!(:dossier_0) { create(:dossier, procedure: procedure, state: 'draft') }
let!(:dossier_1) { create(:dossier, procedure: procedure, state: 'initiated') }
let!(:dossier_2) { create(:dossier, procedure: procedure, state: 'validated') }
let!(:dossier_3) { create(:dossier, procedure: procedure, state: 'validated') }
let!(:dossier_4) { create(:dossier, procedure: procedure, archived: true, state: 'validated') }
let!(:dossier_5) { create(:dossier, procedure: procedure, archived: true, state: 'validated') }
let!(:dossier_6) { create(:dossier, procedure: procedure, archived: true, state: 'initiated') }
subject { AdminProceduresShowFacades.new procedure }

View file

@ -2,6 +2,7 @@ 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]
trait :with_entreprise do
after(:build) do |dossier, _evaluator|
@ -19,12 +20,6 @@ FactoryGirl.define do
end
end
trait :with_user do
after(:build) do |dossier, _evaluator|
dossier.user = create(:user)
end
end
trait :with_two_quartier_prioritaires do
after(:build) do |dossier, _evaluator|

View file

@ -17,7 +17,7 @@ feature 'procedure locked' do
end
context 'when procedure have at least a file' do
before do
create(:dossier, :with_user, procedure: procedure, state: :initiated)
create(:dossier, procedure: procedure, state: :initiated)
visit admin_procedure_path(procedure)
end

View file

@ -1,7 +1,7 @@
require 'spec_helper'
feature 'add commentaire on backoffice' do
let(:dossier) { create(:dossier, :with_entreprise, :with_procedure, :with_user) }
let(:dossier) { create(:dossier, :with_entreprise, :with_procedure) }
let(:dossier_id) { dossier.id }
let!(:commentaire) { create(:commentaire, dossier: dossier, email: 'toto@toto.com') }
let(:email_commentaire) { 'test@test.com' }

View file

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

View file

@ -5,7 +5,7 @@ feature 'on backoffice page' do
let(:gestionnaire) { create(:gestionnaire, administrateur: administrateur) }
let(:procedure) { create(:procedure, administrateur: administrateur) }
let!(:dossier) { create(:dossier, :with_user, :with_entreprise, procedure: procedure, state: 'initiated') }
let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated') }
before do
visit backoffice_path
end

View file

@ -37,8 +37,8 @@ feature 'search file on gestionnaire backoffice' do
context 'when terms input does return result' do
let!(:procedure) { create(:procedure, administrateur: administrateur) }
let!(:dossier) { create(:dossier, :with_entreprise, :with_user, procedure: procedure, state: 'initiated') }
let!(:dossier_2) { create(:dossier, :with_user, procedure: procedure, state: 'initiated', nom_projet: 'Projet de test') }
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(:terms) { dossier.nom_projet }

View file

@ -1,7 +1,7 @@
require 'spec_helper'
feature 'user is on description page' do
let(:dossier) { create(:dossier, :with_entreprise, :with_procedure, :with_user) }
let(:dossier) { create(:dossier, :with_entreprise, :with_procedure) }
before do
visit users_dossier_description_path dossier

View file

@ -5,7 +5,7 @@ feature 'user access to the list of his dossier' do
let(:user) { create(:user) }
let!(:last_updated_dossier) { create(:dossier, :with_procedure, user: user, state: 'replied')}
let!(:dossier1) { create(:dossier, :with_procedure, user: user, nom_projet: 'mon permier dossier', state: 'replied') }
let!(:dossier2) { create(:dossier, :with_user, nom_projet: 'mon deuxième dossier') }
let!(:dossier2) { create(:dossier, nom_projet: 'mon deuxième dossier') }
before do
last_updated_dossier.update_attributes(nom_projet: 'salut la compagnie')

View file

@ -131,7 +131,7 @@ describe Dossier do
end
describe '#next_step' do
let(:dossier) { create(:dossier, :with_user) }
let(:dossier) { create(:dossier) }
let(:role) { 'user' }
let(:action) { 'initiate' }
@ -390,18 +390,18 @@ describe Dossier do
let(:procedure_admin) { create(:procedure, administrateur: admin) }
let(:procedure_admin_2) { create(:procedure, administrateur: admin_2) }
let!(:dossier1) { create(:dossier, :with_user, procedure: procedure_admin, state: 'draft') }
let!(:dossier2) { create(:dossier, :with_user, procedure: procedure_admin, state: 'initiated') } #a_traiter
let!(:dossier3) { create(:dossier, :with_user, procedure: procedure_admin, state: 'initiated') } #a_traiter
let!(:dossier4) { create(:dossier, :with_user, procedure: procedure_admin, state: 'replied') } #en_attente
let!(:dossier5) { create(:dossier, :with_user, procedure: procedure_admin, state: 'updated') } #a_traiter
let!(:dossier6) { create(:dossier, :with_user, procedure: procedure_admin_2, state: 'validated') } #en_attente
let!(:dossier7) { create(:dossier, :with_user, procedure: procedure_admin_2, state: 'submitted') } #a_traiter
let!(:dossier8) { create(:dossier, :with_user, procedure: procedure_admin_2, state: 'closed') } #termine
let!(:dossier9) { create(:dossier, :with_user, procedure: procedure_admin, state: 'closed') } #termine
let!(:dossier10) { create(:dossier, :with_user, procedure: procedure_admin, state: 'initiated', archived: true) } #a_traiter #archived
let!(:dossier11) { create(:dossier, :with_user, procedure: procedure_admin, state: 'replied', archived: true) } #en_attente #archived
let!(:dossier12) { create(:dossier, :with_user, procedure: procedure_admin, state: 'closed', archived: true) } #termine #archived
let!(:dossier1) { create(:dossier, procedure: procedure_admin, state: 'draft') }
let!(:dossier2) { create(:dossier, procedure: procedure_admin, state: 'initiated') } #a_traiter
let!(:dossier3) { create(:dossier, procedure: procedure_admin, state: 'initiated') } #a_traiter
let!(:dossier4) { create(:dossier, procedure: procedure_admin, state: 'replied') } #en_attente
let!(:dossier5) { create(:dossier, procedure: procedure_admin, state: 'updated') } #a_traiter
let!(:dossier6) { create(:dossier, procedure: procedure_admin_2, state: 'validated') } #en_attente
let!(:dossier7) { create(:dossier, procedure: procedure_admin_2, state: 'submitted') } #a_traiter
let!(:dossier8) { create(:dossier, procedure: procedure_admin_2, state: 'closed') } #termine
let!(:dossier9) { create(:dossier, procedure: procedure_admin, state: 'closed') } #termine
let!(:dossier10) { create(:dossier, procedure: procedure_admin, state: 'initiated', archived: true) } #a_traiter #archived
let!(:dossier11) { create(:dossier, procedure: procedure_admin, state: 'replied', archived: true) } #en_attente #archived
let!(:dossier12) { create(:dossier, procedure: procedure_admin, state: 'closed', archived: true) } #termine #archived
describe '#waiting_for_gestionnaire' do
subject { gestionnaire.dossiers.waiting_for_gestionnaire }

View file

@ -87,7 +87,7 @@ describe Procedure do
context 'when procedure have dossier with state draft' do
before do
create(:dossier, :with_user, procedure: procedure, state: :draft)
create(:dossier, procedure: procedure, state: :draft)
end
it { is_expected.to be_falsey }
@ -95,7 +95,7 @@ describe Procedure do
context 'when procedure have dossier with state initiated' do
before do
create(:dossier, :with_user, procedure: procedure, state: :initiated)
create(:dossier, procedure: procedure, state: :initiated)
end
it { is_expected.to be_truthy }

View file

@ -1,7 +1,7 @@
require 'spec_helper'
RSpec.shared_examples 'not owner of dossier' do |controller, redirect|
let(:dossier_2) { create(:dossier, :with_user) }
let(:dossier_2) { create(:dossier) }
before do
get controller, dossier_id: dossier_2.id

View file

@ -5,9 +5,9 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do
let(:gestionnaire) { create(:gestionnaire, administrateur: administrateur) }
let!(:procedure) { create(:procedure, administrateur: administrateur) }
let!(:decorate_dossier_initiated) { create(:dossier, :with_user, procedure: procedure, nom_projet: 'projet initiated', state: 'initiated').decorate }
let!(:decorate_dossier_replied) { create(:dossier, :with_user, procedure: procedure, nom_projet: 'projet replied', state: 'replied').decorate }
let!(:decorate_dossier_closed) { create(:dossier, :with_user, procedure: procedure, nom_projet: 'projet closed', state: 'closed').decorate }
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 }
describe 'on tab a_traiter' do
before do

View file

@ -1,7 +1,7 @@
require 'spec_helper'
describe 'backoffice/dossiers/show.html.haml', type: :view do
let!(:dossier) { create(:dossier, :with_entreprise, :with_procedure, :with_user, state: state) }
let!(:dossier) { create(:dossier, :with_entreprise, :with_procedure, state: state) }
let(:state) { 'draft' }
let(:dossier_id) { dossier.id }
let(:gestionnaire) { create(:gestionnaire) }

View file

@ -1,7 +1,7 @@
require 'spec_helper'
describe 'dossiers/_infos_dossier.html.haml', type: :view do
let(:dossier) { create(:dossier, :with_entreprise, :with_user, procedure: create(:procedure, :with_api_carto, :with_type_de_champ)) }
let(:dossier) { create(:dossier, :with_entreprise, procedure: create(:procedure, :with_api_carto, :with_type_de_champ)) }
before do
assign(:facade, DossierFacades.new(dossier.id, dossier.user.email))

View file

@ -2,7 +2,7 @@ require 'spec_helper'
describe 'users/carte/show.html.haml', type: :view do
let(:state) { 'draft' }
let(:dossier) { create(:dossier, :with_procedure, :with_user, state: state) }
let(:dossier) { create(:dossier, :with_procedure, state: state) }
let(:dossier_id) { dossier.id }
before do

View file

@ -1,7 +1,7 @@
require 'spec_helper'
describe 'users/recapitulatif/_commentaires_flux.html.haml', type: :view do
let(:dossier) { create(:dossier, :with_procedure, :with_user) }
let(:dossier) { create(:dossier, :with_procedure) }
let(:dossier_id) { dossier.id }
let(:email_commentaire) { 'mon_mail_de_commentaire@test.com' }
let!(:commentaire) { create(:commentaire, dossier: dossier, email: email_commentaire, body: 'ma super description') }

View file

@ -1,7 +1,7 @@
require 'spec_helper'
describe 'users/recapitulatif/show.html.haml', type: :view do
let(:dossier) { create(:dossier, :with_user, :with_entreprise, state: state, procedure: create(:procedure, :with_api_carto)) }
let(:dossier) { create(:dossier, :with_entreprise, state: state, procedure: create(:procedure, :with_api_carto)) }
let(:dossier_id) { dossier.id }
let(:state) { 'draft' }