2015-08-10 11:05:06 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2015-09-23 19:20:03 +02:00
|
|
|
describe Users::RecapitulatifController, type: :controller do
|
|
|
|
let(:dossier) { create(:dossier, :with_user) }
|
|
|
|
let(:bad_dossier_id) { Dossier.count + 100000 }
|
2015-08-10 11:05:06 +02:00
|
|
|
|
2015-09-24 16:51:14 +02:00
|
|
|
before do
|
|
|
|
sign_in dossier.user
|
|
|
|
end
|
|
|
|
|
2015-08-20 16:52:36 +02:00
|
|
|
describe 'GET #show' do
|
|
|
|
it 'returns http success' do
|
2015-08-13 15:55:19 +02:00
|
|
|
get :show, dossier_id: dossier.id
|
2015-08-10 11:05:06 +02:00
|
|
|
expect(response).to have_http_status(:success)
|
|
|
|
end
|
|
|
|
|
2015-09-23 16:56:30 +02:00
|
|
|
it 'redirection vers siret si mauvais dossier ID' do
|
2015-08-13 15:55:19 +02:00
|
|
|
get :show, dossier_id: bad_dossier_id
|
2015-09-23 19:20:03 +02:00
|
|
|
expect(response).to redirect_to('/users/siret')
|
2015-08-10 11:05:06 +02:00
|
|
|
end
|
|
|
|
end
|
2015-09-24 16:51:14 +02:00
|
|
|
|
|
|
|
describe 'POST #propose' do
|
|
|
|
context 'when an user propose his dossier' do
|
|
|
|
before do
|
|
|
|
post :propose, dossier_id: dossier.id
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'dossier change his state for processed' do
|
|
|
|
dossier.reload
|
|
|
|
expect(dossier.state).to eq('proposed')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'a message informe user what his dossier is proposed' do
|
|
|
|
expect(flash[:notice]).to include('Dossier soumis avec succès.')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'POST #depose' do
|
|
|
|
context 'when an user depose his dossier' do
|
|
|
|
before do
|
|
|
|
dossier.confirmed!
|
|
|
|
post :depose, dossier_id: dossier.id
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'dossier change his state for deposed' do
|
|
|
|
dossier.reload
|
|
|
|
expect(dossier.state).to eq('deposited')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'a message informe user what his dossier is proposed' do
|
|
|
|
expect(flash[:notice]).to include('Dossier déposé avec succès.')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-08-10 11:05:06 +02:00
|
|
|
end
|