Merge branch 'develop' into staging

This commit is contained in:
JC 2016-10-25 17:42:01 +02:00
commit 9442f43848
4 changed files with 59 additions and 2 deletions

View file

@ -131,6 +131,15 @@ class Users::DossiersController < UsersController
}
end
def destroy
dossier = Dossier.find(params[:id])
if dossier.brouillon?
dossier.destroy
flash.notice = 'Brouillon supprimé'
end
redirect_to url_for users_dossiers_path
end
private
def check_siret

View file

@ -5,6 +5,8 @@
%th.col-md-5.col-lg-5= smart_listing.sortable 'Procédure', 'procedure.libelle'
%th.col-md-2.col-lg-2= smart_listing.sortable 'État', 'state'
%th.col-md-2.col-lg-2= smart_listing.sortable 'Date de mise à jour', 'updated_at'
- if @liste == "brouillon"
%th.col-md-2.col-lg-2= 'Action'
- @dossiers.each do |dossier|
- if dossier.kind_of? Invite
-invite = dossier
@ -20,9 +22,9 @@
= link_to(dossier.procedure.libelle, users_dossier_recapitulatif_path(dossier)) unless dossier.brouillon?
= link_to(dossier.procedure.libelle, users_dossier_description_path(dossier)) if dossier.brouillon?
%td{id: "dossier_#{dossier.id}_state"}= dossier.display_state
%td= dossier.last_update
%td= link_to('X', url_for(controller: 'dossiers', action: :destroy, id: dossier.id), 'data-method' => :delete, class: 'btn-sm btn-danger') if @liste == "brouillon"
= smart_listing.paginate
= smart_listing.pagination_per_page_links

View file

@ -0,0 +1,6 @@
default:
openstack_tenant: "ovh_fake_tenant_name"
openstack_api_key: "ovh_fake_password"
openstack_username: "ovh_fake_username"
openstack_auth_url: "https://auth.cloud.ovh.net/v2.0/tokens"
openstack_region: "SBG1"

View file

@ -388,6 +388,46 @@ describe Users::DossiersController, type: :controller do
end
end
describe 'DELETE #destroy' do
let(:user) { create(:user) }
let!(:dossier_draft) { create :dossier, state: "draft", user: user }
let!(:dossier_not_draft) { create :dossier, state: "initiated", user: user }
subject { delete :destroy, id: dossier.id }
before do
sign_in user
end
context 'when dossier is draft' do
let(:dossier) { dossier_draft }
it { expect(subject.status).to eq 302 }
describe 'flash notice' do
before do
subject
end
it { expect(flash[:notice]).to be_present }
end
it 'destroy dossier is call' do
expect_any_instance_of(Dossier).to receive(:destroy)
subject
end
it { expect { subject }.to change { Dossier.count }.by(-1) }
end
context 'when dossier is not a draft' do
let(:dossier) { dossier_not_draft }
it { expect { subject }.to change { Dossier.count }.by(0) }
end
end
describe 'PUT #change_siret' do
let(:dossier) { create(:dossier, :with_entreprise, user: user, procedure: procedure) }