Merge branch 'develop' of ssh://37.187.249.111:2200/opt/git/tps into develop
This commit is contained in:
commit
ca4e5130c2
4 changed files with 59 additions and 19 deletions
|
@ -1,5 +1,17 @@
|
|||
class StartController < ApplicationController
|
||||
def index
|
||||
@procedure_id = params['procedure_id']
|
||||
@procedure = Procedure.find(@procedure_id)
|
||||
|
||||
if @procedure.nil?
|
||||
error_procedure
|
||||
end
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
error_procedure
|
||||
end
|
||||
|
||||
def error_procedure
|
||||
render :file => "#{Rails.root}/public/404.html", :status => 404
|
||||
end
|
||||
|
||||
def error_siret
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
%p.lead{id: 'pro_section'}
|
||||
%h2#titre_procedure.text-info
|
||||
Demande de subvention
|
||||
=@procedure.libelle
|
||||
|
||||
%br
|
||||
= form_tag(url_for({controller: :dossiers, action: :create}), class: 'form-inline', method: 'POST') do |f|
|
||||
.form-group.form-group-lg
|
||||
= text_field_tag :siret, nil, :class => "form-control", :placeholder => "Entrez votre Siret", :id => "siret", :name => "siret", :maxlength => 14, :style => 'margin-bottom:10px'
|
||||
%br
|
||||
= submit_tag "Commencer", class: %w(btn btn-lg btn-success), style: 'margin-top:20px;', data: { disable_with: "Commencer", submit: true}
|
||||
%input{type: 'hidden', value: "#{@procedure.id}", name: 'procedure_id', id: 'procedure_id'}
|
||||
|
|
|
@ -2,9 +2,27 @@ require 'spec_helper'
|
|||
|
||||
RSpec.describe StartController, type: :controller do
|
||||
describe 'GET #index' do
|
||||
it 'returns http success' do
|
||||
get :index
|
||||
expect(response).to have_http_status(:success)
|
||||
let!(:procedure) { create(:procedure) }
|
||||
before do
|
||||
get :index, procedure_id: procedure
|
||||
end
|
||||
|
||||
context 'when params procedure_id is present' do
|
||||
context 'when procedure_id is valid' do
|
||||
it { expect(response).to have_http_status(:success) }
|
||||
end
|
||||
|
||||
context 'when procedure_id is not valid' do
|
||||
let(:procedure) { '' }
|
||||
it { expect(response).to have_http_status(404) }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when params procedure_id is not present' do
|
||||
before do
|
||||
get :index
|
||||
end
|
||||
it { expect(response).to have_http_status(404) }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,27 +1,35 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'start/index.html.haml', type: :view do
|
||||
context 'si personne n\'est connecté' do
|
||||
before do
|
||||
render
|
||||
let(:procedure) { create(:procedure, libelle: 'Demande de subvention') }
|
||||
before do
|
||||
assign(:procedure, procedure)
|
||||
render
|
||||
end
|
||||
|
||||
it 'la section des professionnels est présente' do
|
||||
expect(rendered).to have_selector('#pro_section')
|
||||
end
|
||||
|
||||
context 'dans la section professionnel' do
|
||||
it 'le formulaire envoie vers /dossiers en #POST' do
|
||||
expect(rendered).to have_selector("form[action='/dossiers'][method=post]")
|
||||
end
|
||||
|
||||
it 'la section des professionnels est présente' do
|
||||
expect(rendered).to have_selector('#pro_section')
|
||||
it 'le champs "Numéro SIRET" est présent' do
|
||||
expect(rendered).to have_selector('input[id=siret][name=siret]')
|
||||
end
|
||||
|
||||
context 'dans la section professionnel' do
|
||||
it 'le formulaire envoie vers /dossiers en #POST' do
|
||||
expect(rendered).to have_selector("form[action='/dossiers'][method=post]")
|
||||
end
|
||||
it 'le titre de la procédure' do
|
||||
expect(rendered).to have_selector('#titre_procedure')
|
||||
end
|
||||
|
||||
it 'le champs "Numéro SIRET" est présent' do
|
||||
expect(rendered).to have_selector('input[id=siret][name=siret]')
|
||||
end
|
||||
context 'stockage de l\'ID de la procédure dans un champs hidden' do
|
||||
it {expect(rendered).to have_selector("input[type=hidden][id=procedure_id][name=procedure_id][value='#{procedure.id}']")}
|
||||
end
|
||||
|
||||
it 'le titre de la procédure' do
|
||||
expect(rendered).to have_selector('#titre_procedure')
|
||||
end
|
||||
it 'le titre de la procédure est présent sur la page' do
|
||||
expect(rendered).to have_content(procedure.libelle)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue