Adding feature test for procedure_creation

This commit is contained in:
JC 2016-12-14 17:13:40 +01:00
parent 03bfbb1462
commit 4f7bcba8a3
17 changed files with 144 additions and 44 deletions

View file

@ -45,4 +45,4 @@ class Admin::TypesDeChampController < AdminController
def create_facade
@types_de_champ_facade = AdminTypesDeChampFacades.new false, @procedure
end
end
end

View file

@ -16,7 +16,7 @@
%tr
%td.col-md-11.col-lg-11{style:'padding-top: 11px; font-size:15px'}= accompagnateur.email
%td.center
%a.btn.btn-success{href: "#{admin_procedure_accompagnateurs_path(procedure_id: @procedure.id, accompagnateur_id: accompagnateur.id, to: AccompagnateurService::ASSIGN)}", 'data-method' => 'put'}
%a.btn.btn-success.gestionnaire-affectation{href: "#{admin_procedure_accompagnateurs_path(procedure_id: @procedure.id, accompagnateur_id: accompagnateur.id, to: AccompagnateurService::ASSIGN)}", 'data-method' => 'put'}
.fa.fa-arrow-right

View file

@ -19,7 +19,7 @@
.col-md-2.col-lg-2
%br
%br
= f.submit 'Valider', class: 'btn btn-info', style: 'float:left'
= f.submit 'Valider', class: 'btn btn-info', style: 'float:left', id: 'add-gestionnaire-email'
.col-md-6.col-lg-6
%h3.text-success Affectés
= smart_listing_render :accompagnateurs_assign

View file

@ -1,5 +1,5 @@
-{email: 'Email*'}.each do |key, value|
.form-group
%h4
=value
=f.text_field key, class: 'form-control', placeholder: value
= value
= f.text_field key, class: 'form-control', placeholder: value

View file

@ -12,8 +12,8 @@
= form_for @gestionnaire, url: {controller: 'admin/gestionnaires', action: :create} do |f|
.row
.col-md-5.col-lg-5
=render partial: 'informations', locals: {f: f}
= render partial: 'informations', locals: {f: f}
.col-md-2.col-lg-2
%br
%br
=f.submit 'Valider', class: 'btn btn-info', style: 'float:left'
= f.submit 'Valider', class: 'btn btn-info', style: 'float:left'

View file

@ -20,7 +20,7 @@
.form-group
%br &nbsp;
- if ff.object.id.nil?
= f.submit('Ajouter la pièce', class: 'btn btn-success')
= f.submit('Ajouter la pièce', class: 'btn btn-success', id: 'add_piece_justificative')
- else
= link_to("", admin_procedure_piece_justificative_path(@procedure, ff.object.id), method: :delete, remote: true, id: "delete_type_de_piece_justificative_#{ff.object.id}", class: %w(form-control btn btn-danger fa fa-trash-o) )

View file

@ -4,12 +4,12 @@
-{libelle: 'Libellé*', description: 'Description*', organisation: 'Organisation', direction: 'Direction', lien_site_web: 'Lien site internet', lien_notice: 'Lien notice'}.each do |key, value|
.form-group
%h4
=value
= value
- if key == :description
= f.text_area key, rows: '6', placeholder: 'Description du projet', class: 'form-control wysihtml5'
- else
=f.text_field key, class: 'form-control', placeholder: value
= f.text_field key, class: 'form-control', placeholder: value
.row
.col-md-6.col-lg-6

View file

@ -15,7 +15,7 @@
%td.col-md-6.col-lg-6
= link_to(procedure.libelle, "/admin/procedures/#{procedure.id}")
- if @active_class
%td= link_to procedure.lien, procedure.lien
%td= link_to procedure.lien, procedure.lien, class: 'procedure-lien'
%td
= procedure.created_at_fr
%td

View file

@ -1,27 +1,27 @@
%li{ class: ('active' if active == 'Informations') }
= link_to('Informations', admin_procedure_path(@procedure))
= link_to 'Informations', admin_procedure_path(@procedure), id: 'onglet-infos'
%li{ class: ('active' if active == 'Accompagnateurs') }
= link_to(t('dynamics.admin.procedure.onglets.accompagnateurs'), admin_procedure_accompagnateurs_path(@procedure))
= link_to t('dynamics.admin.procedure.onglets.accompagnateurs'), admin_procedure_accompagnateurs_path(@procedure), id: 'onglet-accompagnateurs'
%li{ class: ('disabled' if @procedure.locked?) || ('active' if active == 'Description') }
= link_to_unless(@procedure.locked?, 'Description', edit_admin_procedure_path(@procedure)) do
= link_to('Description', '#')
= link_to_unless(@procedure.locked?, 'Description', edit_admin_procedure_path(@procedure), id: 'onglet-description') do
= link_to 'Description', '#', id: 'onglet-description'
%li{ class: ('disabled' if @procedure.locked?) || ('active' if active == 'Champs') }
= link_to_unless(@procedure.locked?, 'Champs', admin_procedure_types_de_champ_path(@procedure)) do
= link_to('Champs', '#')
= link_to_unless(@procedure.locked?, 'Champs', admin_procedure_types_de_champ_path(@procedure), id: 'onglet-champs') do
= link_to 'Champs', '#', id: 'onglet-champs'
%li{ class: ('disabled' if @procedure.locked?) || ('active' if active == 'Pieces') }
= link_to_unless(@procedure.locked?, 'Pièces justificatives', admin_procedure_pieces_justificatives_path(@procedure)) do
= link_to('Pièces justificatives', '#')
= link_to_unless(@procedure.locked?, 'Pièces justificatives', admin_procedure_pieces_justificatives_path(@procedure), id: 'onglet-pieces') do
= link_to 'Pièces justificatives', '#', id: 'onglet-pieces'
%li{ class: ('disabled' if @procedure.locked?) || ('active' if active == 'Champs privés') }
= link_to_unless(@procedure.locked?, 'Champs privés', admin_procedure_types_de_champ_private_path(@procedure)) do
= link_to('Champs privés', '#')
= link_to_unless(@procedure.locked?, 'Champs privés', admin_procedure_types_de_champ_private_path(@procedure), id: 'onglet-private-champs') do
= link_to 'Champs privés', '#', id: 'onglet-private-champs'
%li{ class: ('active' if active == 'E-mails') }
= link_to('E-mails', admin_procedure_mails_path(@procedure))
= link_to 'E-mails', admin_procedure_mails_path(@procedure), id: 'onglet-emails'
%li{ class: ('active' if active == 'Prévisualisation'), style: 'float:right' }
= link_to('Prévisualisation', admin_procedure_previsualisation_path(@procedure), {style: 'font-style: italic;'})
= link_to 'Prévisualisation', admin_procedure_previsualisation_path(@procedure), id: 'onglet-preview'

View file

@ -7,10 +7,8 @@
%div.carret-down
Procédures
%a{href:'/admin/procedures/new'}
%div.col-lg-2.col-md-2.action
%div#new-procedure.col-lg-2.col-md-2.action
Nouvelle
%div.body
= smart_listing_render :procedures

View file

@ -4,5 +4,5 @@
#procedure_new.section.section-label
= form_for @procedure, url: {controller: 'admin/procedures', action: :create}, multipart: true do |f|
=render partial: 'informations', locals: {f: f}
=f.submit 'Valider', class: 'btn btn-info', style: 'float:right'
= render partial: 'informations', locals: {f: f}
= f.submit 'Valider', class: 'btn btn-info', id: 'save-procedure', style: 'float:right'

View file

@ -4,11 +4,11 @@
-unless @facade.procedure.published?
- if @facade.procedure.gestionnaires.size == 0
%a.action_button.btn.btn-success{style:'float: right; margin-top: 10px', disabled: 'disabled', 'data-toggle' => :tooltip, title: 'Vous ne pouvez pas publier une procédure sans qu\'aucun accompagnateur ne soit affecté à celle-ci.'}
%a.action_button.btn.btn-success{style:'float: right; margin-top: 10px', disabled: 'disabled', 'data-toggle' => :tooltip, title: 'Vous ne pouvez pas publier une procédure sans qu\'aucun accompagnateur ne soit affecté à celle-ci.', id: 'publish-procedure'}
%i.fa.fa-eraser
Publier
-else
%a#publish.btn.btn-success{"data-target" => "#publishModal", "data-toggle" => "modal", :type => "button", style:'float: right; margin-top: 10px'}
- else
%a.btn.btn-success{"data-target" => "#publishModal", "data-toggle" => "modal", :type => "button", style:'float: right; margin-top: 10px', id: 'publish-procedure'}
%i.fa.fa-eraser
Publier
@ -20,14 +20,14 @@
=render partial: '/admin/procedures/modal_transfer'
-if @facade.procedure.archived?
- if @facade.procedure.archived?
%a#reenable.btn.btn-small.btn-default.text-info{"data-target" => "#publishModal", "data-toggle" => "modal", :type => "button", style:'float: right; margin-top: 10px'}
%i.fa.fa-eraser
Réactiver
=render partial: '/admin/procedures/modal_publish'
= render partial: '/admin/procedures/modal_publish'
-elsif @facade.procedure.published?
- elsif @facade.procedure.published?
= form_tag admin_procedure_archive_path(procedure_id: @facade.procedure.id, archive: !@facade.procedure.archived?), method: :put, style:'float: right; margin-top: 10px' do
%button#archive.btn.btn-small.btn-default.text-info{type: :button}
%i.fa.fa-eraser
@ -48,12 +48,12 @@
%div
%h3 Lien procédure
%div{style:'margin-left:3%'}
-if @facade.procedure.archived?
- if @facade.procedure.archived?
%b
Cette procédure a été archivée et n'est plus accessible par le public.
-elsif @facade.procedure.published?
- elsif @facade.procedure.published?
= @facade.procedure.lien
-else
- else
%b
Cette procédure n'a pas encore été publiée et n'est donc pas accessible par le public.
@ -123,5 +123,5 @@
= javascript_include_tag "https://code.highcharts.com/highcharts.js", "chartkick"
- if @facade.dossiers_for_pie_highchart.blank?
Aucune statistique pour le moment
-else
- else
=pie_chart @facade.dossiers_for_pie_highchart

View file

@ -9,19 +9,19 @@
%div#menu-block
%div.split-hr-left
#procedure_list
%a{:href => "#{url_for :admin_procedures_draft}"}
%a{:href => "#{url_for :admin_procedures_draft}", id: "draft-procedures"}
%div.procedure_list_element{class: @draft_class}
= "Brouillons"
.badge.progress-bar-default
= current_administrateur.procedures.where(published: false, archived: false).count
%a{:href => "#{url_for :admin_procedures}"}
%a{:href => "#{url_for :admin_procedures}", id: "active-procedures"}
%div.procedure_list_element{class: @active_class}
= "Actives"
.badge.progress-bar-success
= current_administrateur.procedures.where(published: true, archived: false).count
%a{:href => "#{url_for :admin_procedures_archived}"}
%a{:href => "#{url_for :admin_procedures_archived}", id: "archived-procedures"}
%div.procedure_list_element{class: @archived_class}
="Archivées"
.badge.progress-bar-purple

View file

@ -14,7 +14,7 @@
- @dossier.types_de_piece_justificative.order('order_place ASC').each do |type_de_piece_justificative|
%tr
%th.col-lg-6
%th.col-lg-6.piece-libelle
= type_de_piece_justificative.libelle
%td.col-lg-5
-if type_de_piece_justificative.api_entreprise

View file

@ -51,4 +51,4 @@
- unless champ.description.empty? || champ.type_champ == 'engagement'
.row
.col-lg-8.col-md-8{class: 'description_div', id:"description_champs_#{champ.id}"}
= champ.description
= champ.description

View file

@ -0,0 +1,101 @@
require 'spec_helper'
feature 'as an administrateur I wanna create a new procedure', js: true do
let(:administrateur) { create(:administrateur) }
before do
login_as administrateur, scope: :administrateur
visit root_path
end
context 'Right after sign_in I shall see all procedure states links' do
scenario 'Finding draft procedures' do
page.find_by_id('draft-procedures').click
expect(page).to have_current_path(admin_procedures_draft_path, only_path: true)
end
scenario 'Finding active procedures' do
page.find_by_id('active-procedures').click
expect(page).to have_current_path(admin_procedures_path, only_path: true)
end
scenario 'Finding archived procedures' do
page.find_by_id('archived-procedures').click
expect(page).to have_current_path(admin_procedures_archived_path, only_path: true)
end
end
context 'Creating a new procedure' do
scenario 'Finding new procedure link' do
page.find_by_id('new-procedure').click
expect(page).to have_current_path(new_admin_procedure_path, only_path: true)
end
scenario 'Finding save button for new procedure, libelle and description required' do
page.find_by_id('new-procedure').click
page.find_by_id('save-procedure').click
page.find_by_id('flash_message').visible?
fill_in 'procedure_libelle', with: 'libelle de la procedure'
page.execute_script("$('#procedure_description').data('wysihtml5').editor.setValue('description de la procedure')")
page.find_by_id('save-procedure').click
expect(page).to have_current_path(admin_procedure_types_de_champ_path(Procedure.first.id.to_s))
end
end
context 'Editing a new procedure' do
before 'Create procedure' do
page.find_by_id('new-procedure').click
fill_in 'procedure_libelle', with: 'libelle de la procedure'
page.execute_script("$('#procedure_description').data('wysihtml5').editor.setValue('description de la procedure')")
page.find_by_id('save-procedure').click
end
scenario 'Add champ, add file, visualize them in procedure preview' do
page.find_by_id('procedure_types_de_champ_attributes_0_libelle').set 'libelle de champ'
page.find_by_id('add_type_de_champ').click
page.find_by_id('procedure_types_de_champ_attributes_1_libelle')
expect(Procedure.first.types_de_champ.first.libelle).to eq('libelle de champ')
page.find_by_id('onglet-pieces').click
expect(page).to have_current_path(admin_procedure_pieces_justificatives_path(Procedure.first.id.to_s))
page.find_by_id('procedure_types_de_piece_justificative_attributes_0_libelle').set 'libelle de piece'
page.find_by_id('add_piece_justificative').click
page.find_by_id('procedure_types_de_piece_justificative_attributes_1_libelle')
page.find_by_id('onglet-preview').click
expect(page).to have_current_path(admin_procedure_previsualisation_path(Procedure.first.id.to_s))
expect(page.find_by_id('champs_1')['placeholder']).to eq('libelle de champ')
expect(page.first('.piece-libelle').text).to eq('libelle de piece')
end
scenario 'After adding champ and file, check impossibility to publish procedure, add accompagnateur and make publication' do
page.find_by_id('procedure_types_de_champ_attributes_0_libelle').set 'libelle de champ'
page.find_by_id('add_type_de_champ').click
page.find_by_id('onglet-pieces').click
page.find_by_id('procedure_types_de_piece_justificative_attributes_0_libelle').set 'libelle de piece'
page.find_by_id('add_piece_justificative').click
page.find_by_id('onglet-infos').click
expect(page).to have_current_path(admin_procedure_path(Procedure.first.id.to_s))
expect(page.find_by_id('publish-procedure')['disabled']).to eq('disabled')
page.find_by_id('onglet-accompagnateurs').click
expect(page).to have_current_path(admin_procedure_accompagnateurs_path(Procedure.first.id.to_s))
page.find_by_id('gestionnaire_email').set 'gestionnaire@apientreprise.fr'
page.find_by_id('add-gestionnaire-email').click
page.first('.gestionnaire-affectation').click
page.find_by_id('onglet-infos').click
expect(page).to have_selector('#publish-procedure', visible: true)
page.find_by_id('publish-procedure').click
expect(page.find_by_id('procedure_path')['value']).to eq('libelle_de_la_procedure')
page.find_by_id('publish').click
expect(page).to have_selector('.procedure-lien')
end
end
end

View file

@ -34,11 +34,12 @@ require 'factory_girl'
require 'capybara/poltergeist'
Capybara.javascript_driver = :poltergeist
Capybara.ignore_hidden_elements = false
Capybara.register_driver :poltergeist do |app|
Capybara::Poltergeist::Driver.new(app, js_errors: true, port: 44_678 + ENV['TEST_ENV_NUMBER'].to_i, phantomjs_options: ['--proxy-type=none'], timeout: 180)
end
# ActiveSupport::Deprecation.silenced = true
#ActiveSupport::Deprecation.silenced = true
Capybara.default_max_wait_time = 1