demarches-normaliennes/spec/controllers/demandes_controller_spec.rb

30 lines
970 B
Ruby
Raw Normal View History

2015-08-10 11:05:06 +02:00
require 'spec_helper'
RSpec.describe DemandesController, type: :controller do
let(:dossier) { create(:dossier, formulaire_id: '') }
2015-08-20 16:25:54 +02:00
let(:dossier_id) { dossier.id }
2015-08-10 11:05:06 +02:00
2015-08-20 16:52:36 +02:00
describe 'GET #show' do
it 'returns http success' do
get :show, dossier_id: dossier_id
2015-08-10 11:05:06 +02:00
expect(response).to have_http_status(:success)
end
end
describe 'POST #upated' do
context 'when dossier is not linked to formulaire' do
it 'redirect to carte controller' do
2015-08-20 16:52:36 +02:00
post :update, dossier_id: dossier_id, formulaire: '1'
2015-08-17 17:08:13 +02:00
expect(response).to redirect_to(controller: :carte, action: :show, dossier_id: dossier_id)
end
2015-08-10 11:05:06 +02:00
end
context 'when dossier is already linked to formaulaire' do
let(:dossier) { create(:dossier) }
2015-08-20 16:52:36 +02:00
subject { post :update, dossier_id: dossier_id, formulaire: '1' }
it 'raise error' do
2015-08-20 16:52:36 +02:00
expect { subject }.to raise_error("La modification du formulaire n'est pas possible")
end
end
2015-08-10 11:05:06 +02:00
end
end