2015-08-10 11:05:06 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
RSpec.describe DemandesController, type: :controller do
|
2015-08-18 15:15:34 +02:00
|
|
|
let(:dossier) { create(:dossier, formulaire_id: '') }
|
2015-08-13 15:55:19 +02:00
|
|
|
let (:dossier_id) { dossier.id }
|
2015-08-10 11:05:06 +02:00
|
|
|
|
|
|
|
describe "GET #show" do
|
|
|
|
it "returns http success" do
|
|
|
|
get :show, :dossier_id => dossier_id
|
|
|
|
expect(response).to have_http_status(:success)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-08-18 15:15:34 +02:00
|
|
|
describe 'POST #upated' do
|
2015-08-20 12:20:54 +02:00
|
|
|
context 'when dossier is not linked to formulaire' do
|
|
|
|
it 'redirect to carte controller' do
|
2015-08-18 15:15:34 +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)
|
2015-08-20 12:20:54 +02:00
|
|
|
end
|
2015-08-10 11:05:06 +02:00
|
|
|
end
|
2015-08-18 15:15:34 +02:00
|
|
|
context 'when dossier is already linked to formaulaire' do
|
|
|
|
let(:dossier) { create(:dossier) }
|
|
|
|
subject { post :update, :dossier_id => dossier_id, :formulaire => '1' }
|
|
|
|
it 'raise error' do
|
|
|
|
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
|