refacto.
split procedure into 3 screen desactivate order place for type de champ desactivate features test to rewrite them use ajax instead of pure js to manage type de champ
This commit is contained in:
parent
bd0430a6b8
commit
a2f4281f21
29 changed files with 828 additions and 632 deletions
|
@ -21,6 +21,12 @@ var ready = function () {
|
|||
|
||||
add_action_listener_on_click_for_button_up(".button_up");
|
||||
add_action_listener_on_click_for_button_down(".button_down");
|
||||
|
||||
$("#liste_champ").on("ajax:success", "div", function(event, data, status, xhr) {
|
||||
$(event.target).parents('.form-inline').fadeOut("slow", function() {
|
||||
return $(this).remove();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$(document).ready(ready);
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
class Admin::PiecesJustificativesController < AdminController
|
||||
|
||||
def edit
|
||||
@procedure = Procedure.find(params[:procedure_id])
|
||||
@types_de_piece_justificative = @procedure.types_de_piece_justificative
|
||||
end
|
||||
end
|
|
@ -1,5 +1,4 @@
|
|||
class Admin::ProceduresController < ApplicationController
|
||||
before_action :authenticate_administrateur!
|
||||
class Admin::ProceduresController < AdminController
|
||||
|
||||
def index
|
||||
@procedures = Procedure.all
|
||||
|
@ -35,7 +34,7 @@ class Admin::ProceduresController < ApplicationController
|
|||
end
|
||||
|
||||
def update
|
||||
# raise
|
||||
|
||||
@procedure = Procedure.find(params[:id])
|
||||
|
||||
unless @procedure.update_attributes(create_procedure_params)
|
||||
|
@ -55,83 +54,7 @@ class Admin::ProceduresController < ApplicationController
|
|||
|
||||
private
|
||||
|
||||
def process_new_types_de_champ_params
|
||||
unless params[:procedure][:new_type_de_champ].nil?
|
||||
params[:procedure][:new_type_de_champ].each do |new_type_de_champ|
|
||||
type_de_champ = TypeDeChamp.new
|
||||
|
||||
if new_type_de_champ[1]['_destroy'] == 'false'
|
||||
save_new_type_de_champ type_de_champ, new_type_de_champ[1]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def process_update_types_de_champ_params
|
||||
unless params[:procedure][:types_de_champ].nil?
|
||||
params[:procedure][:types_de_champ].each do |type_de_champ|
|
||||
tmp = TypeDeChamp.find(type_de_champ[0])
|
||||
if type_de_champ[1]['_destroy'] == 'false'
|
||||
save_new_type_de_champ tmp, type_de_champ[1]
|
||||
|
||||
elsif type_de_champ[1]['_destroy'] == 'true'
|
||||
tmp.destroy
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def process_new_types_de_piece_justificative_params
|
||||
unless params[:procedure][:new_type_de_piece_justificative].nil?
|
||||
params[:procedure][:new_type_de_piece_justificative].each do |new_type_de_piece_justificative|
|
||||
type_de_pj = TypeDePieceJustificative.new
|
||||
|
||||
if new_type_de_piece_justificative[1]['_destroy'] == 'false'
|
||||
save_new_type_de_piece_justificative type_de_pj, new_type_de_piece_justificative[1]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def process_update_types_de_piece_justificative_params
|
||||
unless params[:procedure][:types_de_piece_justificative].nil?
|
||||
params[:procedure][:types_de_piece_justificative].each do |type_de_piece_justificative|
|
||||
tmp = TypeDePieceJustificative.find(type_de_piece_justificative[0])
|
||||
|
||||
if type_de_piece_justificative[1]['_destroy'] == 'false'
|
||||
save_new_type_de_piece_justificative tmp, type_de_piece_justificative[1]
|
||||
|
||||
elsif type_de_piece_justificative[1]['_destroy'] == 'true'
|
||||
tmp.destroy
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
def save_new_type_de_champ database_object, source
|
||||
database_object.libelle = source[:libelle]
|
||||
database_object.type_champs = source[:type_champs]
|
||||
database_object.description = source[:description]
|
||||
database_object.order_place = source[:order_place]
|
||||
database_object.procedure = @procedure
|
||||
|
||||
database_object.save
|
||||
end
|
||||
|
||||
def save_new_type_de_piece_justificative database_object, source
|
||||
database_object.libelle = source[:libelle]
|
||||
database_object.description = source[:description]
|
||||
database_object.procedure = @procedure
|
||||
|
||||
database_object.save
|
||||
end
|
||||
|
||||
def create_procedure_params
|
||||
params.require(:procedure).permit(:libelle, :description, :organisation, :direction, :lien_demarche, :use_api_carto)
|
||||
|
||||
#params.require(:procedure).permit(:libelle, :description, :organisation, :direction, :lien_demarche, :use_api_carto, types_de_champ_attributes: [:libelle, :description, :order_place, :type_champs])
|
||||
end
|
||||
end
|
||||
|
|
33
app/controllers/admin/types_de_champ_controller.rb
Normal file
33
app/controllers/admin/types_de_champ_controller.rb
Normal file
|
@ -0,0 +1,33 @@
|
|||
class Admin::TypesDeChampController < AdminController
|
||||
|
||||
before_action :retrieve_procedure
|
||||
|
||||
def destroy
|
||||
@procedure.types_de_champ.destroy(params[:id])
|
||||
render json: { message: 'deleted' }, status: 200
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render json: { message: 'Champ not found' }, status: 404
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
def update
|
||||
@procedure.update_attributes(update_params)
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def update_params
|
||||
params.require(:procedure).permit(types_de_champ_attributes: [:libelle, :description, :order_place, :type_champs, :id])
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def retrieve_procedure
|
||||
@procedure = Procedure.find(params[:procedure_id])
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render json: { message: 'Procedure not found' }, status: 404
|
||||
end
|
||||
end
|
|
@ -1,7 +1,7 @@
|
|||
class AdminController < ApplicationController
|
||||
before_action :authenticate_administrateur!
|
||||
|
||||
def index
|
||||
redirect_to(controller: '/administrateurs/sessions', action: :new) unless administrateur_signed_in?
|
||||
redirect_to (admin_procedures_path)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@ class Procedure < ActiveRecord::Base
|
|||
has_many :types_de_piece_justificative
|
||||
has_many :types_de_champ
|
||||
has_many :dossiers
|
||||
accepts_nested_attributes_for :types_de_champ
|
||||
accepts_nested_attributes_for :types_de_champ,:reject_if => proc { |attributes| attributes['libelle'].blank? }, :allow_destroy => true
|
||||
|
||||
validates :libelle, presence: true, allow_blank: false, allow_nil: false
|
||||
validates :description, presence: true, allow_blank: false, allow_nil: false
|
||||
|
|
|
@ -10,5 +10,5 @@ class TypeDeChamp < ActiveRecord::Base
|
|||
|
||||
validates :libelle, presence: true, allow_blank: false, allow_nil: false
|
||||
validates :type_champs, presence: true, allow_blank: false, allow_nil: false
|
||||
validates :order_place, presence: true, allow_blank: false, allow_nil: false
|
||||
# validates :order_place, presence: true, allow_blank: false, allow_nil: false
|
||||
end
|
25
app/views/admin/pieces_justificatives/_form.html.haml
Normal file
25
app/views/admin/pieces_justificatives/_form.html.haml
Normal file
|
@ -0,0 +1,25 @@
|
|||
- types_de_piece_justificative.each do |type_de_piece_justificative|
|
||||
- type_de_piece_justificative.id.nil? ? object_for = "new_type_de_piece_justificative[#{index}]" : object_for = 'types_de_piece_justificative[]'
|
||||
|
||||
= f.fields_for object_for, type_de_piece_justificative do |ff|
|
||||
.form-inline{id:"type_de_piece_justificative_#{type_de_piece_justificative.id || index}", class: 'type_de_piece_justificative', style: 'padding-bottom:8px'}
|
||||
.form-group{ style: 'padding-right: 2%' }
|
||||
%h4 Libellé
|
||||
=ff.text_field :libelle, class: 'form-control libelle', placeholder: 'Libellé'
|
||||
|
||||
.form-group{ style: 'padding-right: 2%' }
|
||||
%h4
|
||||
Description
|
||||
=ff.text_area :description, class: 'form-control description', placeholder: 'Description'
|
||||
|
||||
=ff.hidden_field '_destroy', value: 'false', class: 'destroy'
|
||||
|
||||
.form-group{ id: "delete_type_de_piece_justificative_#{type_de_piece_justificative.id || index}_button", style: ("display:none" if type_de_piece_justificative.id.nil?) }
|
||||
%br
|
||||
%button.form-control.btn.btn-danger.fa.fa-trash-o{type: 'button', id: "delete_type_de_piece_justificative_#{type_de_piece_justificative.id || index}_procedure"}
|
||||
|
||||
-if type_de_piece_justificative.id.nil?
|
||||
.form-group#add_type_de_piece_justificative_button
|
||||
%br
|
||||
%button.form-control.btn.btn-success#add_type_de_piece_justificative_procedure{type: 'button'} Ajouter
|
||||
|
20
app/views/admin/pieces_justificatives/edit.html.haml
Normal file
20
app/views/admin/pieces_justificatives/edit.html.haml
Normal file
|
@ -0,0 +1,20 @@
|
|||
%ul.nav.nav-tabs
|
||||
%li
|
||||
= link_to('Description', admin_procedure_path(@procedure))
|
||||
%li
|
||||
= link_to('Champs', edit_admin_procedure_types_de_champ_path(@procedure))
|
||||
%li.active
|
||||
= link_to('Pièces justificatives', edit_admin_procedure_pieces_justificatives_path(@procedure))
|
||||
|
||||
= form_for [:admin, @procedure], remote: true do |f|
|
||||
#liste_piece_justificative
|
||||
-unless @types_de_piece_justificative.nil?
|
||||
= render partial: 'form', locals:{ types_de_piece_justificative: @types_de_piece_justificative, f: f }
|
||||
|
||||
#liste_delete_piece_justificative
|
||||
|
||||
#new_type_de_piece_justificative
|
||||
= render partial: 'form', locals:{ types_de_piece_justificative: [TypeDePieceJustificative.new], index: (@types_de_piece_justificative.nil? || @types_de_piece_justificative.last.nil? ? 0 : @procedure.types_de_piece_justificative.last.id+1), f: f }
|
||||
|
||||
%script{ type:'text/javascript' }
|
||||
="var types_de_piece_justificative_index = #{(@types_de_piece_justificative.nil? || @types_de_piece_justificative.last.nil? ? 0 : @procedure.types_de_piece_justificative.last.id+1)}"
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
%br
|
||||
|
||||
-{libelle: 'Libellé*', description: 'Description*', lien_demarche: 'Lien démarche', organisation: 'Organisation', direction: 'Direction'}.each do |key, value|
|
||||
|
@ -11,21 +12,3 @@
|
|||
%label{ style:'font-weight:normal' }
|
||||
=f.check_box :use_api_carto
|
||||
Utilisation de l'API Carto
|
||||
|
||||
%br
|
||||
%br
|
||||
%h3.text-info
|
||||
Liste des champs à remplir pour un dossier
|
||||
|
||||
=render partial: 'admin/procedures/types_de_champ/liste', locals: {f: f}
|
||||
|
||||
%br
|
||||
%br
|
||||
%h3.text-info
|
||||
Liste des pièces justificatives à fournir pour un dossier
|
||||
|
||||
=render partial: 'admin/procedures/types_de_piece_justificative/liste', locals: {f: f}
|
||||
|
||||
%br
|
||||
%div.small{style:'text-align:right'}
|
||||
*Attributs obligatoires
|
1
app/views/admin/procedures/list_type_de_champ.js.erb
Normal file
1
app/views/admin/procedures/list_type_de_champ.js.erb
Normal file
|
@ -0,0 +1 @@
|
|||
$("#champs").html("<%= escape_javascript(render partial: 'types_de_champ/liste', locals: { types_de_champ: @types_de_champ } ) %>");
|
|
@ -1,3 +1,13 @@
|
|||
%ul.nav.nav-tabs
|
||||
%li.active
|
||||
= link_to('Description', admin_procedure_path(@procedure))
|
||||
%li
|
||||
= link_to('Champs', edit_admin_procedure_types_de_champ_path(@procedure))
|
||||
%li
|
||||
= link_to('Pièces justificatives', edit_admin_procedure_pieces_justificatives_path(@procedure))
|
||||
|
||||
|
||||
|
||||
%h2.text-info
|
||||
=@procedure.libelle
|
||||
|
||||
|
|
|
@ -1,38 +1,76 @@
|
|||
- types_de_champ.each do |type_de_champ|
|
||||
- type_de_champ.id.nil? ? object_for = "new_type_de_champ[#{index}]" : object_for = 'types_de_champ[]'
|
||||
|
||||
= f.fields_for object_for, type_de_champ do |ff|
|
||||
.form-inline{id:"type_de_champ_#{type_de_champ.id || index}", class: 'type_de_champ', style: 'padding-bottom:8px'}
|
||||
.form-group{ style: 'padding-right: 2%' }
|
||||
/ - types_de_champ.each do |type_de_champ|
|
||||
= f.fields_for :types_de_champ, types_de_champ, remote: true do |ff|
|
||||
.form-inline
|
||||
.form-group
|
||||
%h4 Libellé
|
||||
= ff.text_field :libelle, class: 'form-control libelle', placeholder: 'Libellé'
|
||||
|
||||
.form-group{ style: 'padding-right: 2%' }
|
||||
.form-group
|
||||
%h4 Type
|
||||
= ff.select :type_champs, TypeDeChamp.type_champs, {}, {class: 'form-control type_champs'}
|
||||
|
||||
.form-group{ style: 'padding-right: 2%' }
|
||||
%h4
|
||||
Description
|
||||
.form-group
|
||||
%h4 Description
|
||||
= ff.text_area :description, class: 'form-control description', placeholder: 'Description'
|
||||
.form-group
|
||||
= ff.hidden_field :order_place
|
||||
= ff.hidden_field :id
|
||||
|
||||
-if order_place.nil?
|
||||
=ff.hidden_field :order_place, class: 'order_place'
|
||||
-else
|
||||
=ff.hidden_field :order_place, value: order_place, class: 'order_place'
|
||||
=ff.hidden_field '_destroy', value: 'false', class: 'destroy'
|
||||
|
||||
.form-group.order_type_de_champ_button{id: "order_type_de_champ_#{type_de_champ.id || index}_button", style: ("display:none" if type_de_champ.id.nil?)}
|
||||
/ .form-group.order_type_de_champ_button{id: "order_type_de_champ_#{type_de_champ.id || index}_button", style: ("display:none" if type_de_champ.id.nil?)}
|
||||
.form-group
|
||||
%br
|
||||
%button.form-control.btn.btn-default.button_up.fa.fa-chevron-up{type: 'button', id: "order_type_de_champ_#{type_de_champ.id || index}_up_procedure"}
|
||||
%button.form-control.btn.btn-default.button_down.fa.fa-chevron-down{type: 'button', id: "order_type_de_champ_#{type_de_champ.id || index}_down_procedure"}
|
||||
%button.form-control.btn.btn-default.button_up.fa.fa-chevron-up{type: 'button'}
|
||||
/ , id: "order_type_de_champ_#{type_de_champ.id || index}_up_procedure"}
|
||||
%button.form-control.btn.btn-default.button_down.fa.fa-chevron-down{type: 'button'}
|
||||
/ , id: "order_type_de_champ_#{type_de_champ.id || index}_down_procedure"}
|
||||
|
||||
.form-group{ id: "delete_type_de_champ_#{type_de_champ.id || index}_button", style: ("display:none" if type_de_champ.id.nil?)}
|
||||
/ .form-group{ id: "delete_type_de_champ_#{type_de_champ.id || index}_button", style: ("display:none" if type_de_champ.id.nil?)}
|
||||
- unless ff.object.id.nil?
|
||||
.form-group
|
||||
%br
|
||||
%button.form-control.btn.btn-danger.fa.fa-trash-o{type: 'button', id: "delete_type_de_champ_#{type_de_champ.id || index}_procedure"}
|
||||
= link_to("Delete", admin_procedure_type_de_champ_path(@procedure, ff.object.id), method: :delete, remote: true)
|
||||
/ %button.form-control.btn.btn-danger.fa.fa-trash-o{type: 'button'}
|
||||
/ , id: "delete_type_de_champ_#{type_de_champ.id || index}_procedure"}
|
||||
|
||||
-if type_de_champ.id.nil?
|
||||
-if ff.object.id.nil?
|
||||
.form-group#add_type_de_champ_button
|
||||
%br
|
||||
= ff.submit('Ajouter', :'data-remote' => true)
|
||||
%button.form-control.btn.btn-success#add_type_de_champ_procedure{type: 'button'} Ajouter
|
||||
|
||||
|
||||
/ - types_de_champ.each do |type_de_champ|
|
||||
/ - type_de_champ.id.nil? ? object_for = "new_type_de_champ[#{index}]" : object_for = 'types_de_champ[]'
|
||||
|
||||
/ = f.fields_for object_for, type_de_champ do |ff|
|
||||
/ .form-inline{id:"type_de_champ_#{type_de_champ.id || index}", class: 'type_de_champ', style: 'padding-bottom:8px'}
|
||||
/ .form-group{ style: 'padding-right: 2%' }
|
||||
/ %h4 Libellé
|
||||
/ =ff.text_field :libelle, class: 'form-control libelle', placeholder: 'Libellé'
|
||||
|
||||
/ .form-group{ style: 'padding-right: 2%' }
|
||||
/ %h4 Type
|
||||
/ =ff.select :type_champs, TypeDeChamp.type_champs, {}, {class: 'form-control type_champs'}
|
||||
|
||||
/ .form-group{ style: 'padding-right: 2%' }
|
||||
/ %h4 Description
|
||||
/ =ff.text_area :description, class: 'form-control description', placeholder: 'Description'
|
||||
|
||||
/ -if order_place.nil?
|
||||
/ =ff.hidden_field :order_place, class: 'order_place'
|
||||
/ -else
|
||||
/ =ff.hidden_field :order_place, value: order_place, class: 'order_place'
|
||||
/ =ff.hidden_field '_destroy', value: 'false', class: 'destroy'
|
||||
|
||||
/ .form-group.order_type_de_champ_button{id: "order_type_de_champ_#{type_de_champ.id || index}_button", style: ("display:none" if type_de_champ.id.nil?)}
|
||||
/ %br
|
||||
/ %button.form-control.btn.btn-default.button_up.fa.fa-chevron-up{type: 'button', id: "order_type_de_champ_#{type_de_champ.id || index}_up_procedure"}
|
||||
/ %button.form-control.btn.btn-default.button_down.fa.fa-chevron-down{type: 'button', id: "order_type_de_champ_#{type_de_champ.id || index}_down_procedure"}
|
||||
|
||||
/ .form-group{ id: "delete_type_de_champ_#{type_de_champ.id || index}_button", style: ("display:none" if type_de_champ.id.nil?)}
|
||||
/ %br
|
||||
/ %button.form-control.btn.btn-danger.fa.fa-trash-o{type: 'button', id: "delete_type_de_champ_#{type_de_champ.id || index}_procedure"}
|
||||
|
||||
/ -if type_de_champ.id.nil?
|
||||
/ .form-group#add_type_de_champ_button
|
||||
/ %br
|
||||
/ %button.form-control.btn.btn-success#add_type_de_champ_procedure{type: 'button'} Ajouter
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
#liste_champ
|
||||
-unless @types_de_champ.nil?
|
||||
=render partial: 'admin/procedures/types_de_champ/form', locals:{ types_de_champ: @types_de_champ, order_place: nil, f: f }
|
||||
=render partial: 'admin/procedures/types_de_champ/form', locals:{ types_de_champ: @types_de_champ, order_place: nil, f: f, procedure: procedure }
|
||||
|
||||
#liste_delete_champ
|
||||
|
||||
#new_type_de_champ
|
||||
=render partial: 'admin/procedures/types_de_champ/form', locals:{ types_de_champ: [TypeDeChamp.new], index: (@types_de_champ.nil? || @types_de_champ.last.nil? ? 0 : @procedure.types_de_champ.last.id+1), order_place: (@types_de_champ.nil? ? 1 : @types_de_champ.size+1), f: f }
|
||||
=render partial: 'admin/procedures/types_de_champ/form', locals:{ types_de_champ: [TypeDeChamp.new], index: (@types_de_champ.nil? || @types_de_champ.last.nil? ? 0 : @procedure.types_de_champ.last.id+1), order_place: (@types_de_champ.nil? ? 1 : @types_de_champ.size+1), f: f, procedure: procedure }
|
||||
|
||||
%script{ type:'text/javascript' }
|
||||
="var types_de_champ_index = #{(@types_de_champ.nil? || @types_de_champ.last.nil? ? 0 : @procedure.types_de_champ.last.id+1)}"
|
31
app/views/admin/types_de_champ/_fields.html.haml
Normal file
31
app/views/admin/types_de_champ/_fields.html.haml
Normal file
|
@ -0,0 +1,31 @@
|
|||
= f.fields_for :types_de_champ, types_de_champ, remote: true do |ff|
|
||||
.form-inline
|
||||
.form-group
|
||||
%h4 Libellé
|
||||
= ff.text_field :libelle, class: 'form-control libelle', placeholder: 'Libellé'
|
||||
.form-group
|
||||
%h4 Type
|
||||
= ff.select :type_champs, TypeDeChamp.type_champs, {}, {class: 'form-control type_champs'}
|
||||
.form-group
|
||||
%h4 Description
|
||||
= ff.text_area :description, class: 'form-control description', placeholder: 'Description'
|
||||
.form-group
|
||||
= ff.hidden_field :order_place
|
||||
= ff.hidden_field :id
|
||||
|
||||
/ .form-group.order_type_de_champ_button{id: "order_type_de_champ_#{type_de_champ.id || index}_button", style: ("display:none" if type_de_champ.id.nil?)}
|
||||
/ .form-group
|
||||
/ %br
|
||||
/ %button.form-control.btn.btn-default.button_up.fa.fa-chevron-up{type: 'button'}
|
||||
/ , id: "order_type_de_champ_#{type_de_champ.id || index}_up_procedure"}
|
||||
/ %button.form-control.btn.btn-default.button_down.fa.fa-chevron-down{type: 'button'}
|
||||
/ , id: "order_type_de_champ_#{type_de_champ.id || index}_down_procedure"}
|
||||
|
||||
/ .form-group{ id: "delete_type_de_champ_#{type_de_champ.id || index}_button", style: ("display:none" if type_de_champ.id.nil?)}
|
||||
- unless ff.object.id.nil?
|
||||
.form-group
|
||||
%br
|
||||
= link_to("Delete", admin_procedure_type_de_champ_path(@procedure, ff.object.id), method: :delete, remote: true)
|
||||
/ %button.form-control.btn.btn-danger.fa.fa-trash-o{type: 'button'}
|
||||
/ , id: "delete_type_de_champ_#{type_de_champ.id || index}_procedure"}
|
||||
|
5
app/views/admin/types_de_champ/_form.html.haml
Normal file
5
app/views/admin/types_de_champ/_form.html.haml
Normal file
|
@ -0,0 +1,5 @@
|
|||
= form_for [:admin, @procedure], url: admin_procedure_types_de_champ_path(@procedure) , remote: true do |f|
|
||||
= render partial: 'fields', locals: { types_de_champ: @procedure.types_de_champ, f: f }
|
||||
#new_type_de_champ
|
||||
= render partial: 'fields', locals: { types_de_champ: TypeDeChamp.new, f: f }
|
||||
= f.submit "Ajouter un champ", class: 'btn btn-success'
|
10
app/views/admin/types_de_champ/edit.html.haml
Normal file
10
app/views/admin/types_de_champ/edit.html.haml
Normal file
|
@ -0,0 +1,10 @@
|
|||
%ul.nav.nav-tabs
|
||||
%li
|
||||
= link_to('Description', admin_procedure_path(@procedure))
|
||||
%li.active
|
||||
= link_to('Champs', edit_admin_procedure_types_de_champ_path(@procedure))
|
||||
%li
|
||||
= link_to('Pièces justificatives', edit_admin_procedure_pieces_justificatives_path(@procedure))
|
||||
|
||||
#liste_champ
|
||||
= render partial: 'form'
|
1
app/views/admin/types_de_champ/update.js.erb
Normal file
1
app/views/admin/types_de_champ/update.js.erb
Normal file
|
@ -0,0 +1 @@
|
|||
$('#liste_champ').html("<%= escape_javascript(render partial: 'form', locals: { procedure: @procedure, types_de_champ: @types_de_champ } ) %>");
|
|
@ -42,7 +42,9 @@ Rails.application.routes.draw do
|
|||
namespace :admin do
|
||||
get 'sign_in' => '/administrateurs/sessions#new'
|
||||
resources :procedures do
|
||||
|
||||
resource :types_de_champ, only: [:edit, :update]
|
||||
resources :types_de_champ, only: [:destroy]
|
||||
resource :pieces_justificatives, only: [:edit, :update]
|
||||
end
|
||||
end
|
||||
|
||||
|
|
101
spec/controllers/admin/types_de_champ_controller_spec.rb
Normal file
101
spec/controllers/admin/types_de_champ_controller_spec.rb
Normal file
|
@ -0,0 +1,101 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Admin::TypesDeChampController, type: :controller do
|
||||
let(:admin) { create(:administrateur) }
|
||||
before do
|
||||
sign_in admin
|
||||
end
|
||||
|
||||
describe '#update' do
|
||||
let(:procedure) { create(:procedure) }
|
||||
let(:libelle) { 'mon libelle' }
|
||||
let(:type_champs) { 'text' }
|
||||
let(:description) { 'titi' }
|
||||
let(:order_place) { '' }
|
||||
let(:types_de_champ_id) { '' }
|
||||
|
||||
let(:procedure_params) do
|
||||
{ types_de_champ_attributes:
|
||||
{ '0' =>
|
||||
{
|
||||
libelle: libelle,
|
||||
type_champs: type_champs,
|
||||
description: description,
|
||||
order_place: order_place,
|
||||
id: types_de_champ_id
|
||||
}
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
let(:request) { put :update, format: :js, procedure_id: procedure.id, procedure: procedure_params }
|
||||
|
||||
context 'when procedure is found' do
|
||||
it { expect{ request }.to change(TypeDeChamp, :count).by(1) }
|
||||
|
||||
describe 'created type de champ' do
|
||||
before do
|
||||
request
|
||||
procedure.reload
|
||||
end
|
||||
subject { procedure.types_de_champ.first }
|
||||
|
||||
it { expect(subject.libelle).to eq('mon libelle') }
|
||||
it { expect(subject.type_champs).to eq('text') }
|
||||
it { expect(subject.description).to eq('titi') }
|
||||
# it { expect(subject.order_place).to eq('0') }
|
||||
end
|
||||
|
||||
context 'when type_de_champ already exist' do
|
||||
let(:procedure) { create(:procedure, :with_type_de_champ) }
|
||||
let(:type_de_champ) { procedure.types_de_champ.first }
|
||||
let(:types_de_champ_id) { type_de_champ.id }
|
||||
let(:libelle) { 'toto' }
|
||||
let(:type_champs) { 'text' }
|
||||
let(:description) { 'citrouille' }
|
||||
let(:order_place) { '0' }
|
||||
before do
|
||||
request
|
||||
procedure.reload
|
||||
end
|
||||
subject { procedure.types_de_champ.first }
|
||||
it { expect(subject.libelle).to eq('toto') }
|
||||
it { expect(subject.type_champs).to eq('text') }
|
||||
it { expect(subject.description).to eq('citrouille') }
|
||||
# it { expect(subject.order_place).to eq(0) }
|
||||
end
|
||||
end
|
||||
context 'when procedure is not found' do
|
||||
subject { put :update, format: :js, procedure_id: 9_999_999, procedure: procedure_params }
|
||||
it 'creates type de champ' do
|
||||
expect(subject.status).to eq(404)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#destroy' do
|
||||
before do
|
||||
delete :destroy, procedure_id: procedure.id, id: type_de_champ_id
|
||||
end
|
||||
context 'when type de champs does not exist' do
|
||||
let(:type_de_champ_id) { 99999999 }
|
||||
let(:procedure) { create(:procedure) }
|
||||
it { expect(subject.status).to eq(404) }
|
||||
end
|
||||
context 'when types_de_champ exists' do
|
||||
let(:procedure) { create(:procedure, :with_type_de_champ) }
|
||||
let(:type_de_champ_id) { procedure.types_de_champ.first.id }
|
||||
it { expect(subject.status).to eq(200) }
|
||||
it 'destroy type de champ' do
|
||||
procedure.reload
|
||||
expect(procedure.types_de_champ.count).to eq(0)
|
||||
end
|
||||
end
|
||||
context 'when procedure and type de champs are not linked' do
|
||||
let(:procedure) { create(:procedure) }
|
||||
let(:type_de_champ) { create(:type_de_champ) }
|
||||
let(:type_de_champ_id) { type_de_champ.id }
|
||||
it { expect(subject.status).to eq(404) }
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,74 +1,74 @@
|
|||
require 'spec_helper'
|
||||
|
||||
feature 'add a new type de champs', js: true do
|
||||
let(:administrateur) { create(:administrateur) }
|
||||
# feature 'add a new type de champs', js: true do
|
||||
# let(:administrateur) { create(:administrateur) }
|
||||
|
||||
before do
|
||||
login_as administrateur, scope: :administrateur
|
||||
end
|
||||
# before do
|
||||
# login_as administrateur, scope: :administrateur
|
||||
# end
|
||||
|
||||
context 'when create a new procedure' do
|
||||
before do
|
||||
visit new_admin_procedure_path
|
||||
end
|
||||
# context 'when create a new procedure' do
|
||||
# before do
|
||||
# visit new_admin_procedure_path
|
||||
# end
|
||||
|
||||
scenario 'page have form to created new type de champs' do
|
||||
expect(page).to have_css('#type_de_champ_0')
|
||||
expect(page).to have_css('input[name="procedure[new_type_de_champ[0]][libelle]"]')
|
||||
expect(page).to have_css('select[name="procedure[new_type_de_champ[0]][type_champs]"]')
|
||||
expect(page).to have_css('textarea[name="procedure[new_type_de_champ[0]][description]"]')
|
||||
expect(page).to have_css('input[name="procedure[new_type_de_champ[0]][order_place]"]', visible: false)
|
||||
expect(page).to have_css('input[name="procedure[new_type_de_champ[0]][_destroy]"]', visible: false)
|
||||
# scenario 'page have form to created new type de champs' do
|
||||
# expect(page).to have_css('#type_de_champ_0')
|
||||
# expect(page).to have_css('input[name="procedure[new_type_de_champ[0]][libelle]"]')
|
||||
# expect(page).to have_css('select[name="procedure[new_type_de_champ[0]][type_champs]"]')
|
||||
# expect(page).to have_css('textarea[name="procedure[new_type_de_champ[0]][description]"]')
|
||||
# expect(page).to have_css('input[name="procedure[new_type_de_champ[0]][order_place]"]', visible: false)
|
||||
# expect(page).to have_css('input[name="procedure[new_type_de_champ[0]][_destroy]"]', visible: false)
|
||||
|
||||
expect(page).to have_css('#order_type_de_champ_0_button', visible: false);
|
||||
expect(page).to have_css('#order_type_de_champ_0_up_procedure', visible: false);
|
||||
expect(page).to have_css('#order_type_de_champ_0_down_procedure', visible: false);
|
||||
# expect(page).to have_css('#order_type_de_champ_0_button', visible: false);
|
||||
# expect(page).to have_css('#order_type_de_champ_0_up_procedure', visible: false);
|
||||
# expect(page).to have_css('#order_type_de_champ_0_down_procedure', visible: false);
|
||||
|
||||
expect(page).to have_css('#new_type_de_champ #add_type_de_champ_button')
|
||||
end
|
||||
# expect(page).to have_css('#new_type_de_champ #add_type_de_champ_button')
|
||||
# end
|
||||
|
||||
context 'when user add a new champs type' do
|
||||
before do
|
||||
page.find_by_id('procedure_new_type_de_champ_0__libelle').set 'Libelle de test'
|
||||
page.find_by_id('procedure_new_type_de_champ_0__description').set 'Description de test'
|
||||
page.click_on 'add_type_de_champ_procedure'
|
||||
end
|
||||
# context 'when user add a new champs type' do
|
||||
# before do
|
||||
# page.find_by_id('procedure_new_type_de_champ_0__libelle').set 'Libelle de test'
|
||||
# page.find_by_id('procedure_new_type_de_champ_0__description').set 'Description de test'
|
||||
# page.click_on 'add_type_de_champ_procedure'
|
||||
# end
|
||||
|
||||
scenario 'a new champs type line is appeared with increment index id' do
|
||||
expect(page).to have_css('#type_de_champ_1')
|
||||
expect(page).to have_css('input[name="procedure[new_type_de_champ[1]][libelle]"]')
|
||||
expect(page).to have_css('select[name="procedure[new_type_de_champ[1]][type_champs]"]')
|
||||
expect(page).to have_css('textarea[name="procedure[new_type_de_champ[1]][description]"]')
|
||||
expect(page).to have_css('input[name="procedure[new_type_de_champ[1]][order_place]"]', visible: false)
|
||||
expect(page).to have_css('input[name="procedure[new_type_de_champ[1]][_destroy]"]', visible: false)
|
||||
# scenario 'a new champs type line is appeared with increment index id' do
|
||||
# expect(page).to have_css('#type_de_champ_1')
|
||||
# expect(page).to have_css('input[name="procedure[new_type_de_champ[1]][libelle]"]')
|
||||
# expect(page).to have_css('select[name="procedure[new_type_de_champ[1]][type_champs]"]')
|
||||
# expect(page).to have_css('textarea[name="procedure[new_type_de_champ[1]][description]"]')
|
||||
# expect(page).to have_css('input[name="procedure[new_type_de_champ[1]][order_place]"]', visible: false)
|
||||
# expect(page).to have_css('input[name="procedure[new_type_de_champ[1]][_destroy]"]', visible: false)
|
||||
|
||||
expect(page).to have_css('#order_type_de_champ_1_button', visible: false);
|
||||
expect(page).to have_css('#order_type_de_champ_1_up_procedure', visible: false);
|
||||
expect(page).to have_css('#order_type_de_champ_1_down_procedure', visible: false);
|
||||
end
|
||||
# expect(page).to have_css('#order_type_de_champ_1_button', visible: false);
|
||||
# expect(page).to have_css('#order_type_de_champ_1_up_procedure', visible: false);
|
||||
# expect(page).to have_css('#order_type_de_champ_1_down_procedure', visible: false);
|
||||
# end
|
||||
|
||||
scenario 'the first line is filled' do
|
||||
expect(page.find_by_id('procedure_new_type_de_champ_0__libelle').value).to eq('Libelle de test')
|
||||
expect(page.find_by_id('procedure_new_type_de_champ_0__description').value).to eq('Description de test')
|
||||
expect(page.find_by_id('procedure_new_type_de_champ_0__order_place', visible: false).value).to eq('1')
|
||||
end
|
||||
# scenario 'the first line is filled' do
|
||||
# expect(page.find_by_id('procedure_new_type_de_champ_0__libelle').value).to eq('Libelle de test')
|
||||
# expect(page.find_by_id('procedure_new_type_de_champ_0__description').value).to eq('Description de test')
|
||||
# expect(page.find_by_id('procedure_new_type_de_champ_0__order_place', visible: false).value).to eq('1')
|
||||
# end
|
||||
|
||||
scenario 'the first line have new button delete' do
|
||||
expect(page).to have_css('#delete_type_de_champ_0_button')
|
||||
expect(page).to have_css('#delete_type_de_champ_0_procedure')
|
||||
end
|
||||
# scenario 'the first line have new button delete' do
|
||||
# expect(page).to have_css('#delete_type_de_champ_0_button')
|
||||
# expect(page).to have_css('#delete_type_de_champ_0_procedure')
|
||||
# end
|
||||
|
||||
scenario 'the new line is empty' do
|
||||
expect(page.find_by_id('procedure_new_type_de_champ_1__libelle').value).to eq('')
|
||||
expect(page.find_by_id('procedure_new_type_de_champ_1__description').value).to eq('')
|
||||
expect(page.find_by_id('procedure_new_type_de_champ_1__order_place', visible: false).value).to eq('2')
|
||||
expect(page.find_by_id('procedure_new_type_de_champ_1___destroy', visible: false).value).to eq('false')
|
||||
end
|
||||
# scenario 'the new line is empty' do
|
||||
# expect(page.find_by_id('procedure_new_type_de_champ_1__libelle').value).to eq('')
|
||||
# expect(page.find_by_id('procedure_new_type_de_champ_1__description').value).to eq('')
|
||||
# expect(page.find_by_id('procedure_new_type_de_champ_1__order_place', visible: false).value).to eq('2')
|
||||
# expect(page.find_by_id('procedure_new_type_de_champ_1___destroy', visible: false).value).to eq('false')
|
||||
# end
|
||||
|
||||
scenario 'the button Ajouter is at side new line' do
|
||||
expect(page).to have_css('#new_type_de_champ #type_de_champ_1 #add_type_de_champ_button')
|
||||
expect(page).not_to have_css('#type_de_champ_0 #add_type_de_champ_button')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
# scenario 'the button Ajouter is at side new line' do
|
||||
# expect(page).to have_css('#new_type_de_champ #type_de_champ_1 #add_type_de_champ_button')
|
||||
# expect(page).not_to have_css('#type_de_champ_0 #add_type_de_champ_button')
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
|
|
|
@ -1,55 +1,55 @@
|
|||
require 'spec_helper'
|
||||
|
||||
feature 'add a new type de piece justificative', js: true do
|
||||
let(:administrateur) { create(:administrateur) }
|
||||
# feature 'add a new type de piece justificative', js: true do
|
||||
# let(:administrateur) { create(:administrateur) }
|
||||
|
||||
before do
|
||||
login_as administrateur, scope: :administrateur
|
||||
end
|
||||
# before do
|
||||
# login_as administrateur, scope: :administrateur
|
||||
# end
|
||||
|
||||
context 'when create a new procedure' do
|
||||
before do
|
||||
visit new_admin_procedure_path
|
||||
end
|
||||
# context 'when create a new procedure' do
|
||||
# before do
|
||||
# visit new_admin_procedure_path
|
||||
# end
|
||||
|
||||
scenario 'page have form to created new type de piece justificative' do
|
||||
expect(page).to have_css('#type_de_piece_justificative_0')
|
||||
expect(page).to have_css('input[name="procedure[new_type_de_piece_justificative[0]][libelle]"]')
|
||||
expect(page).to have_css('textarea[name="procedure[new_type_de_piece_justificative[0]][description]"]')
|
||||
expect(page).to have_css('input[name="procedure[new_type_de_piece_justificative[0]][_destroy]"]', visible: false)
|
||||
# scenario 'page have form to created new type de piece justificative' do
|
||||
# expect(page).to have_css('#type_de_piece_justificative_0')
|
||||
# expect(page).to have_css('input[name="procedure[new_type_de_piece_justificative[0]][libelle]"]')
|
||||
# expect(page).to have_css('textarea[name="procedure[new_type_de_piece_justificative[0]][description]"]')
|
||||
# expect(page).to have_css('input[name="procedure[new_type_de_piece_justificative[0]][_destroy]"]', visible: false)
|
||||
|
||||
expect(page).to have_css('#new_type_de_piece_justificative #add_type_de_piece_justificative_button')
|
||||
end
|
||||
# expect(page).to have_css('#new_type_de_piece_justificative #add_type_de_piece_justificative_button')
|
||||
# end
|
||||
|
||||
context 'when user add a new piece justificative type' do
|
||||
before do
|
||||
page.find_by_id('procedure_new_type_de_piece_justificative_0__libelle').set 'Libelle de test'
|
||||
page.find_by_id('procedure_new_type_de_piece_justificative_0__description').set 'Description de test'
|
||||
page.click_on 'add_type_de_piece_justificative_procedure'
|
||||
end
|
||||
# context 'when user add a new piece justificative type' do
|
||||
# before do
|
||||
# page.find_by_id('procedure_new_type_de_piece_justificative_0__libelle').set 'Libelle de test'
|
||||
# page.find_by_id('procedure_new_type_de_piece_justificative_0__description').set 'Description de test'
|
||||
# page.click_on 'add_type_de_piece_justificative_procedure'
|
||||
# end
|
||||
|
||||
scenario 'a new piece justificative type line is appeared with increment index id' do
|
||||
expect(page).to have_css('#type_de_piece_justificative_1')
|
||||
expect(page).to have_css('input[name="procedure[new_type_de_piece_justificative[1]][libelle]"]')
|
||||
expect(page).to have_css('textarea[name="procedure[new_type_de_piece_justificative[1]][description]"]')
|
||||
expect(page).to have_css('input[name="procedure[new_type_de_piece_justificative[1]][_destroy]"]', visible: false)
|
||||
end
|
||||
# scenario 'a new piece justificative type line is appeared with increment index id' do
|
||||
# expect(page).to have_css('#type_de_piece_justificative_1')
|
||||
# expect(page).to have_css('input[name="procedure[new_type_de_piece_justificative[1]][libelle]"]')
|
||||
# expect(page).to have_css('textarea[name="procedure[new_type_de_piece_justificative[1]][description]"]')
|
||||
# expect(page).to have_css('input[name="procedure[new_type_de_piece_justificative[1]][_destroy]"]', visible: false)
|
||||
# end
|
||||
|
||||
scenario 'the first line is filled' do
|
||||
expect(page.find_by_id('procedure_new_type_de_piece_justificative_0__libelle').value).to eq('Libelle de test')
|
||||
expect(page.find_by_id('procedure_new_type_de_piece_justificative_0__description').value).to eq('Description de test')
|
||||
end
|
||||
# scenario 'the first line is filled' do
|
||||
# expect(page.find_by_id('procedure_new_type_de_piece_justificative_0__libelle').value).to eq('Libelle de test')
|
||||
# expect(page.find_by_id('procedure_new_type_de_piece_justificative_0__description').value).to eq('Description de test')
|
||||
# end
|
||||
|
||||
scenario 'the new line is empty' do
|
||||
expect(page.find_by_id('procedure_new_type_de_piece_justificative_1__libelle').value).to eq('')
|
||||
expect(page.find_by_id('procedure_new_type_de_piece_justificative_1__description').value).to eq('')
|
||||
expect(page.find_by_id('procedure_new_type_de_piece_justificative_1___destroy', visible: false).value).to eq('false')
|
||||
end
|
||||
# scenario 'the new line is empty' do
|
||||
# expect(page.find_by_id('procedure_new_type_de_piece_justificative_1__libelle').value).to eq('')
|
||||
# expect(page.find_by_id('procedure_new_type_de_piece_justificative_1__description').value).to eq('')
|
||||
# expect(page.find_by_id('procedure_new_type_de_piece_justificative_1___destroy', visible: false).value).to eq('false')
|
||||
# end
|
||||
|
||||
scenario 'the button Ajouter is at side new line' do
|
||||
expect(page).to have_css('#new_type_de_piece_justificative #type_de_piece_justificative_1 #add_type_de_piece_justificative_button')
|
||||
expect(page).not_to have_css('#type_de_piece_justificative_0 #add_type_de_piece_justificative_button')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
# scenario 'the button Ajouter is at side new line' do
|
||||
# expect(page).to have_css('#new_type_de_piece_justificative #type_de_piece_justificative_1 #add_type_de_piece_justificative_button')
|
||||
# expect(page).not_to have_css('#type_de_piece_justificative_0 #add_type_de_piece_justificative_button')
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
|
|
|
@ -1,125 +1,125 @@
|
|||
require 'spec_helper'
|
||||
|
||||
feature 'config up and down button display', js: true do
|
||||
let(:administrateur) { create(:administrateur) }
|
||||
# feature 'config up and down button display', js: true do
|
||||
# let(:administrateur) { create(:administrateur) }
|
||||
|
||||
before do
|
||||
login_as administrateur, scope: :administrateur
|
||||
end
|
||||
# before do
|
||||
# login_as administrateur, scope: :administrateur
|
||||
# end
|
||||
|
||||
context 'when procedure have not type de champs' do
|
||||
let!(:procedure) { create(:procedure) }
|
||||
# context 'when procedure have not type de champs' do
|
||||
# let!(:procedure) { create(:procedure) }
|
||||
|
||||
before do
|
||||
visit admin_procedure_path id: procedure.id
|
||||
end
|
||||
# before do
|
||||
# visit admin_procedure_path id: procedure.id
|
||||
# end
|
||||
|
||||
scenario 'type_de_champ_0 have not up and down button visible' do
|
||||
expect(page.find_by_id('order_type_de_champ_0_up_procedure', visible: false).visible?).to be_falsey
|
||||
expect(page.find_by_id('order_type_de_champ_0_down_procedure', visible: false).visible?).to be_falsey
|
||||
end
|
||||
end
|
||||
# scenario 'type_de_champ_0 have not up and down button visible' do
|
||||
# expect(page.find_by_id('order_type_de_champ_0_up_procedure', visible: false).visible?).to be_falsey
|
||||
# expect(page.find_by_id('order_type_de_champ_0_down_procedure', visible: false).visible?).to be_falsey
|
||||
# end
|
||||
# end
|
||||
|
||||
context 'when procedure have one type de champs' do
|
||||
let!(:procedure) { create(:procedure, :with_type_de_champ) }
|
||||
# context 'when procedure have one type de champs' do
|
||||
# let!(:procedure) { create(:procedure, :with_type_de_champ) }
|
||||
|
||||
before do
|
||||
visit admin_procedure_path id: procedure.id
|
||||
end
|
||||
# before do
|
||||
# visit admin_procedure_path id: procedure.id
|
||||
# end
|
||||
|
||||
scenario 'type_de_champ_1 have not up and down button visible' do
|
||||
expect(page.find_by_id('order_type_de_champ_1_up_procedure', visible: false).visible?).to be_falsey
|
||||
expect(page.find_by_id('order_type_de_champ_1_down_procedure', visible: false).visible?).to be_falsey
|
||||
end
|
||||
# scenario 'type_de_champ_1 have not up and down button visible' do
|
||||
# expect(page.find_by_id('order_type_de_champ_1_up_procedure', visible: false).visible?).to be_falsey
|
||||
# expect(page.find_by_id('order_type_de_champ_1_down_procedure', visible: false).visible?).to be_falsey
|
||||
# end
|
||||
|
||||
scenario 'type_de_champ_2 have not up and down button visible' do
|
||||
expect(page.find_by_id('order_type_de_champ_2_up_procedure', visible: false).visible?).to be_falsey
|
||||
expect(page.find_by_id('order_type_de_champ_2_down_procedure', visible: false).visible?).to be_falsey
|
||||
end
|
||||
end
|
||||
# scenario 'type_de_champ_2 have not up and down button visible' do
|
||||
# expect(page.find_by_id('order_type_de_champ_2_up_procedure', visible: false).visible?).to be_falsey
|
||||
# expect(page.find_by_id('order_type_de_champ_2_down_procedure', visible: false).visible?).to be_falsey
|
||||
# end
|
||||
# end
|
||||
|
||||
context 'when procedure have two type de champs' do
|
||||
let!(:procedure) { create(:procedure, :with_type_de_champ) }
|
||||
let!(:type_de_champ) { create(:type_de_champ, procedure: procedure, order_place: 2) }
|
||||
# context 'when procedure have two type de champs' do
|
||||
# let!(:procedure) { create(:procedure, :with_type_de_champ) }
|
||||
# let!(:type_de_champ) { create(:type_de_champ, procedure: procedure, order_place: 2) }
|
||||
|
||||
before do
|
||||
visit admin_procedure_path id: procedure.id
|
||||
end
|
||||
# before do
|
||||
# visit admin_procedure_path id: procedure.id
|
||||
# end
|
||||
|
||||
scenario 'type_de_champ_1 have not up visible and down button visible' do
|
||||
expect(page.find_by_id('order_type_de_champ_1_up_procedure', visible: false).visible?).to be_falsey
|
||||
expect(page.find_by_id('order_type_de_champ_1_down_procedure').visible?).to be_truthy
|
||||
end
|
||||
# scenario 'type_de_champ_1 have not up visible and down button visible' do
|
||||
# expect(page.find_by_id('order_type_de_champ_1_up_procedure', visible: false).visible?).to be_falsey
|
||||
# expect(page.find_by_id('order_type_de_champ_1_down_procedure').visible?).to be_truthy
|
||||
# end
|
||||
|
||||
scenario 'type_de_champ_2 have up button visible and down button not visible' do
|
||||
expect(page.find_by_id('order_type_de_champ_2_up_procedure').visible?).to be_truthy
|
||||
expect(page.find_by_id('order_type_de_champ_2_down_procedure', visible: false).visible?).to be_falsey
|
||||
end
|
||||
# scenario 'type_de_champ_2 have up button visible and down button not visible' do
|
||||
# expect(page.find_by_id('order_type_de_champ_2_up_procedure').visible?).to be_truthy
|
||||
# expect(page.find_by_id('order_type_de_champ_2_down_procedure', visible: false).visible?).to be_falsey
|
||||
# end
|
||||
|
||||
scenario 'type_de_champ_3 have not up and down button visible' do
|
||||
expect(page.find_by_id('order_type_de_champ_3_up_procedure', visible: false).visible?).to be_falsey
|
||||
expect(page.find_by_id('order_type_de_champ_3_down_procedure', visible: false).visible?).to be_falsey
|
||||
end
|
||||
end
|
||||
# scenario 'type_de_champ_3 have not up and down button visible' do
|
||||
# expect(page.find_by_id('order_type_de_champ_3_up_procedure', visible: false).visible?).to be_falsey
|
||||
# expect(page.find_by_id('order_type_de_champ_3_down_procedure', visible: false).visible?).to be_falsey
|
||||
# end
|
||||
# end
|
||||
|
||||
context 'when procedure have two type de champs into database and one type de champs add to form' do
|
||||
let!(:procedure) { create(:procedure, :with_type_de_champ) }
|
||||
let!(:type_de_champ) { create(:type_de_champ, procedure: procedure, order_place: 2) }
|
||||
# context 'when procedure have two type de champs into database and one type de champs add to form' do
|
||||
# let!(:procedure) { create(:procedure, :with_type_de_champ) }
|
||||
# let!(:type_de_champ) { create(:type_de_champ, procedure: procedure, order_place: 2) }
|
||||
|
||||
before do
|
||||
visit admin_procedure_path id: procedure.id
|
||||
page.click_on 'add_type_de_champ_procedure'
|
||||
end
|
||||
# before do
|
||||
# visit admin_procedure_path id: procedure.id
|
||||
# page.click_on 'add_type_de_champ_procedure'
|
||||
# end
|
||||
|
||||
scenario 'type_de_champ_1 have not up visible and down button visible' do
|
||||
expect(page.find_by_id('order_type_de_champ_1_up_procedure', visible: false).visible?).to be_falsey
|
||||
expect(page.find_by_id('order_type_de_champ_1_down_procedure').visible?).to be_truthy
|
||||
end
|
||||
# scenario 'type_de_champ_1 have not up visible and down button visible' do
|
||||
# expect(page.find_by_id('order_type_de_champ_1_up_procedure', visible: false).visible?).to be_falsey
|
||||
# expect(page.find_by_id('order_type_de_champ_1_down_procedure').visible?).to be_truthy
|
||||
# end
|
||||
|
||||
scenario 'type_de_champ_2 have up button and down button visible' do
|
||||
expect(page.find_by_id('order_type_de_champ_2_up_procedure').visible?).to be_truthy
|
||||
expect(page.find_by_id('order_type_de_champ_2_down_procedure').visible?).to be_truthy
|
||||
end
|
||||
# scenario 'type_de_champ_2 have up button and down button visible' do
|
||||
# expect(page.find_by_id('order_type_de_champ_2_up_procedure').visible?).to be_truthy
|
||||
# expect(page.find_by_id('order_type_de_champ_2_down_procedure').visible?).to be_truthy
|
||||
# end
|
||||
|
||||
scenario 'type_de_champ_3 have up visible and down button not visible' do
|
||||
expect(page.find_by_id('order_type_de_champ_3_up_procedure').visible?).to be_truthy
|
||||
expect(page.find_by_id('order_type_de_champ_3_down_procedure', visible: false).visible?).to be_falsey
|
||||
end
|
||||
# scenario 'type_de_champ_3 have up visible and down button not visible' do
|
||||
# expect(page.find_by_id('order_type_de_champ_3_up_procedure').visible?).to be_truthy
|
||||
# expect(page.find_by_id('order_type_de_champ_3_down_procedure', visible: false).visible?).to be_falsey
|
||||
# end
|
||||
|
||||
scenario 'type_de_champ_4 have not up and down button visible' do
|
||||
expect(page.find_by_id('order_type_de_champ_4_up_procedure', visible: false).visible?).to be_falsey
|
||||
expect(page.find_by_id('order_type_de_champ_4_down_procedure', visible: false).visible?).to be_falsey
|
||||
end
|
||||
end
|
||||
# scenario 'type_de_champ_4 have not up and down button visible' do
|
||||
# expect(page.find_by_id('order_type_de_champ_4_up_procedure', visible: false).visible?).to be_falsey
|
||||
# expect(page.find_by_id('order_type_de_champ_4_down_procedure', visible: false).visible?).to be_falsey
|
||||
# end
|
||||
# end
|
||||
|
||||
context 'when procedure have two type de champs into database and one type de champs add to form and delete one type_de_champ' do
|
||||
let!(:procedure) { create(:procedure, :with_type_de_champ) }
|
||||
let!(:type_de_champ) { create(:type_de_champ, procedure: procedure, order_place: 2) }
|
||||
# context 'when procedure have two type de champs into database and one type de champs add to form and delete one type_de_champ' do
|
||||
# let!(:procedure) { create(:procedure, :with_type_de_champ) }
|
||||
# let!(:type_de_champ) { create(:type_de_champ, procedure: procedure, order_place: 2) }
|
||||
|
||||
before do
|
||||
visit admin_procedure_path id: procedure.id
|
||||
page.click_on 'add_type_de_champ_procedure'
|
||||
page.click_on 'delete_type_de_champ_3_procedure'
|
||||
end
|
||||
# before do
|
||||
# visit admin_procedure_path id: procedure.id
|
||||
# page.click_on 'add_type_de_champ_procedure'
|
||||
# page.click_on 'delete_type_de_champ_3_procedure'
|
||||
# end
|
||||
|
||||
scenario 'type_de_champ_1 have not up visible and down button visible' do
|
||||
expect(page.find_by_id('order_type_de_champ_1_up_procedure', visible: false).visible?).to be_falsey
|
||||
expect(page.find_by_id('order_type_de_champ_1_down_procedure').visible?).to be_truthy
|
||||
end
|
||||
# scenario 'type_de_champ_1 have not up visible and down button visible' do
|
||||
# expect(page.find_by_id('order_type_de_champ_1_up_procedure', visible: false).visible?).to be_falsey
|
||||
# expect(page.find_by_id('order_type_de_champ_1_down_procedure').visible?).to be_truthy
|
||||
# end
|
||||
|
||||
scenario 'type_de_champ_2 have up button visible and down button not visible' do
|
||||
expect(page.find_by_id('order_type_de_champ_2_up_procedure').visible?).to be_truthy
|
||||
expect(page.find_by_id('order_type_de_champ_2_down_procedure', visible: false).visible?).to be_falsey
|
||||
end
|
||||
# scenario 'type_de_champ_2 have up button visible and down button not visible' do
|
||||
# expect(page.find_by_id('order_type_de_champ_2_up_procedure').visible?).to be_truthy
|
||||
# expect(page.find_by_id('order_type_de_champ_2_down_procedure', visible: false).visible?).to be_falsey
|
||||
# end
|
||||
|
||||
scenario 'type_de_champ_3 have up and down button not visible' do
|
||||
expect(page.find_by_id('order_type_de_champ_3_up_procedure', visible: false).visible?).to be_falsey
|
||||
expect(page.find_by_id('order_type_de_champ_3_down_procedure', visible: false).visible?).to be_falsey
|
||||
end
|
||||
# scenario 'type_de_champ_3 have up and down button not visible' do
|
||||
# expect(page.find_by_id('order_type_de_champ_3_up_procedure', visible: false).visible?).to be_falsey
|
||||
# expect(page.find_by_id('order_type_de_champ_3_down_procedure', visible: false).visible?).to be_falsey
|
||||
# end
|
||||
|
||||
scenario 'type_de_champ_4 have not up and down button visible' do
|
||||
expect(page.find_by_id('order_type_de_champ_4_up_procedure', visible: false).visible?).to be_falsey
|
||||
expect(page.find_by_id('order_type_de_champ_4_down_procedure', visible: false).visible?).to be_falsey
|
||||
end
|
||||
end
|
||||
end
|
||||
# scenario 'type_de_champ_4 have not up and down button visible' do
|
||||
# expect(page.find_by_id('order_type_de_champ_4_up_procedure', visible: false).visible?).to be_falsey
|
||||
# expect(page.find_by_id('order_type_de_champ_4_down_procedure', visible: false).visible?).to be_falsey
|
||||
# end
|
||||
# end
|
||||
# end
|
|
@ -1,80 +1,80 @@
|
|||
require 'spec_helper'
|
||||
|
||||
feature 'delete a type de champs form', js: true do
|
||||
let(:administrateur) { create(:administrateur) }
|
||||
# feature 'delete a type de champs form', js: true do
|
||||
# let(:administrateur) { create(:administrateur) }
|
||||
|
||||
before do
|
||||
login_as administrateur, scope: :administrateur
|
||||
end
|
||||
# before do
|
||||
# login_as administrateur, scope: :administrateur
|
||||
# end
|
||||
|
||||
context 'when user click on type de trash button' do
|
||||
let!(:procedure) { create(:procedure, :with_type_de_champ) }
|
||||
# context 'when user click on type de trash button' do
|
||||
# let!(:procedure) { create(:procedure, :with_type_de_champ) }
|
||||
|
||||
before do
|
||||
visit admin_procedure_path id: procedure.id
|
||||
end
|
||||
# before do
|
||||
# visit admin_procedure_path id: procedure.id
|
||||
# end
|
||||
|
||||
context 'when user edit a type de champs already save in database' do
|
||||
let(:type_de_champ) { procedure.types_de_champ.first }
|
||||
# context 'when user edit a type de champs already save in database' do
|
||||
# let(:type_de_champ) { procedure.types_de_champ.first }
|
||||
|
||||
before do
|
||||
page.click_on 'delete_type_de_champ_1_procedure'
|
||||
end
|
||||
# before do
|
||||
# page.click_on 'delete_type_de_champ_1_procedure'
|
||||
# end
|
||||
|
||||
scenario 'form is mask for the user' do
|
||||
expect(page.find_by_id('type_de_champ_1', visible: false).visible?).to be_falsey
|
||||
end
|
||||
# scenario 'form is mask for the user' do
|
||||
# expect(page.find_by_id('type_de_champ_1', visible: false).visible?).to be_falsey
|
||||
# end
|
||||
|
||||
scenario 'delete attribut of type de champs is turn to true' do
|
||||
expect(page.find_by_id('type_de_champ_1', visible: false).find('input[class="destroy"]', visible: false).value).to eq('true')
|
||||
end
|
||||
# scenario 'delete attribut of type de champs is turn to true' do
|
||||
# expect(page.find_by_id('type_de_champ_1', visible: false).find('input[class="destroy"]', visible: false).value).to eq('true')
|
||||
# end
|
||||
|
||||
scenario 'attribut node is to move into div liste_delete_champ' do
|
||||
expect(page).to have_css('#liste_delete_champ #type_de_champ_1', visible: false)
|
||||
end
|
||||
end
|
||||
# scenario 'attribut node is to move into div liste_delete_champ' do
|
||||
# expect(page).to have_css('#liste_delete_champ #type_de_champ_1', visible: false)
|
||||
# end
|
||||
# end
|
||||
|
||||
context 'when user edit a type de champs just add on the form page' do
|
||||
before do
|
||||
page.click_on 'add_type_de_champ_procedure'
|
||||
page.click_on 'add_type_de_champ_procedure'
|
||||
page.click_on 'add_type_de_champ_procedure'
|
||||
page.click_on 'add_type_de_champ_procedure'
|
||||
page.click_on 'add_type_de_champ_procedure'
|
||||
page.click_on 'delete_type_de_champ_2_procedure'
|
||||
page.click_on 'delete_type_de_champ_3_procedure'
|
||||
end
|
||||
# context 'when user edit a type de champs just add on the form page' do
|
||||
# before do
|
||||
# page.click_on 'add_type_de_champ_procedure'
|
||||
# page.click_on 'add_type_de_champ_procedure'
|
||||
# page.click_on 'add_type_de_champ_procedure'
|
||||
# page.click_on 'add_type_de_champ_procedure'
|
||||
# page.click_on 'add_type_de_champ_procedure'
|
||||
# page.click_on 'delete_type_de_champ_2_procedure'
|
||||
# page.click_on 'delete_type_de_champ_3_procedure'
|
||||
# end
|
||||
|
||||
scenario 'form is mask for the user' do
|
||||
expect(page.find_by_id('type_de_champ_2', visible: false).visible?).to be_falsey
|
||||
expect(page.find_by_id('type_de_champ_3', visible: false).visible?).to be_falsey
|
||||
end
|
||||
# scenario 'form is mask for the user' do
|
||||
# expect(page.find_by_id('type_de_champ_2', visible: false).visible?).to be_falsey
|
||||
# expect(page.find_by_id('type_de_champ_3', visible: false).visible?).to be_falsey
|
||||
# end
|
||||
|
||||
scenario 'delete attribut of type de champs is turn to true' do
|
||||
expect(page.find_by_id('type_de_champ_2', visible: false).find('input[class="destroy"]', visible: false).value).to eq('true')
|
||||
expect(page.find_by_id('type_de_champ_3', visible: false).find('input[class="destroy"]', visible: false).value).to eq('true')
|
||||
end
|
||||
# scenario 'delete attribut of type de champs is turn to true' do
|
||||
# expect(page.find_by_id('type_de_champ_2', visible: false).find('input[class="destroy"]', visible: false).value).to eq('true')
|
||||
# expect(page.find_by_id('type_de_champ_3', visible: false).find('input[class="destroy"]', visible: false).value).to eq('true')
|
||||
# end
|
||||
|
||||
scenario 'attribut node is to move into div liste_delete_champ' do
|
||||
expect(page).to have_css('#liste_delete_champ #type_de_champ_2', visible: false)
|
||||
expect(page).to have_css('#liste_delete_champ #type_de_champ_3', visible: false)
|
||||
end
|
||||
# scenario 'attribut node is to move into div liste_delete_champ' do
|
||||
# expect(page).to have_css('#liste_delete_champ #type_de_champ_2', visible: false)
|
||||
# expect(page).to have_css('#liste_delete_champ #type_de_champ_3', visible: false)
|
||||
# end
|
||||
|
||||
scenario 'order_place type_de_champ_1_procedure is 1' do
|
||||
expect(page.find_by_id('type_de_champ_1').find("input[class='order_place']", visible: false).value).to eq('1')
|
||||
end
|
||||
# scenario 'order_place type_de_champ_1_procedure is 1' do
|
||||
# expect(page.find_by_id('type_de_champ_1').find("input[class='order_place']", visible: false).value).to eq('1')
|
||||
# end
|
||||
|
||||
scenario 'order_place type_de_champ_4_procedure is 2' do
|
||||
expect(page.find_by_id('type_de_champ_4').find("input[class='order_place']", visible: false).value).to eq('2')
|
||||
end
|
||||
# scenario 'order_place type_de_champ_4_procedure is 2' do
|
||||
# expect(page.find_by_id('type_de_champ_4').find("input[class='order_place']", visible: false).value).to eq('2')
|
||||
# end
|
||||
|
||||
scenario 'order_place type_de_champ_5_procedure is 3' do
|
||||
expect(page.find_by_id('type_de_champ_5').find("input[class='order_place']", visible: false).value).to eq('3')
|
||||
end
|
||||
# scenario 'order_place type_de_champ_5_procedure is 3' do
|
||||
# expect(page.find_by_id('type_de_champ_5').find("input[class='order_place']", visible: false).value).to eq('3')
|
||||
# end
|
||||
|
||||
scenario 'order_place type_de_champ_6_procedure is 4' do
|
||||
expect(page.find_by_id('type_de_champ_6').find("input[class='order_place']", visible: false).value).to eq('4')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
# scenario 'order_place type_de_champ_6_procedure is 4' do
|
||||
# expect(page.find_by_id('type_de_champ_6').find("input[class='order_place']", visible: false).value).to eq('4')
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
|
|
|
@ -1,52 +1,52 @@
|
|||
require 'spec_helper'
|
||||
|
||||
feature 'delete a type de piece_justificative form', js: true do
|
||||
let(:administrateur) { create(:administrateur) }
|
||||
# feature 'delete a type de piece_justificative form', js: true do
|
||||
# let(:administrateur) { create(:administrateur) }
|
||||
|
||||
before do
|
||||
login_as administrateur, scope: :administrateur
|
||||
end
|
||||
# before do
|
||||
# login_as administrateur, scope: :administrateur
|
||||
# end
|
||||
|
||||
context 'when user click on type de piece_justificative red X button' do
|
||||
let!(:procedure) { create(:procedure, :with_two_type_de_piece_justificative) }
|
||||
# context 'when user click on type de piece_justificative red X button' do
|
||||
# let!(:procedure) { create(:procedure, :with_two_type_de_piece_justificative) }
|
||||
|
||||
before do
|
||||
visit admin_procedure_path id: procedure.id
|
||||
end
|
||||
# before do
|
||||
# visit admin_procedure_path id: procedure.id
|
||||
# end
|
||||
|
||||
context 'when user edit a type de piece_justificative already save in database' do
|
||||
let(:type_de_piece_justificative) { procedure.types_de_piece_justificative.first }
|
||||
# context 'when user edit a type de piece_justificative already save in database' do
|
||||
# let(:type_de_piece_justificative) { procedure.types_de_piece_justificative.first }
|
||||
|
||||
before do
|
||||
page.click_on 'delete_type_de_piece_justificative_1_procedure'
|
||||
end
|
||||
# before do
|
||||
# page.click_on 'delete_type_de_piece_justificative_1_procedure'
|
||||
# end
|
||||
|
||||
scenario 'form is mask for the user' do
|
||||
expect(page.find_by_id('type_de_piece_justificative_1', visible: false).visible?).to be_falsey
|
||||
end
|
||||
# scenario 'form is mask for the user' do
|
||||
# expect(page.find_by_id('type_de_piece_justificative_1', visible: false).visible?).to be_falsey
|
||||
# end
|
||||
|
||||
scenario 'delete attribut of type de piece_justificative is turn to true' do
|
||||
expect(page.find_by_id('type_de_piece_justificative_1', visible: false).find('input[class="destroy"]', visible: false).value).to eq('true')
|
||||
end
|
||||
end
|
||||
# scenario 'delete attribut of type de piece_justificative is turn to true' do
|
||||
# expect(page.find_by_id('type_de_piece_justificative_1', visible: false).find('input[class="destroy"]', visible: false).value).to eq('true')
|
||||
# end
|
||||
# end
|
||||
|
||||
context 'when user edit a type de piece_justificative just add on the form page' do
|
||||
before do
|
||||
page.click_on 'add_type_de_piece_justificative_procedure'
|
||||
page.click_on 'add_type_de_piece_justificative_procedure'
|
||||
page.click_on 'delete_type_de_piece_justificative_2_procedure'
|
||||
page.click_on 'delete_type_de_piece_justificative_3_procedure'
|
||||
end
|
||||
# context 'when user edit a type de piece_justificative just add on the form page' do
|
||||
# before do
|
||||
# page.click_on 'add_type_de_piece_justificative_procedure'
|
||||
# page.click_on 'add_type_de_piece_justificative_procedure'
|
||||
# page.click_on 'delete_type_de_piece_justificative_2_procedure'
|
||||
# page.click_on 'delete_type_de_piece_justificative_3_procedure'
|
||||
# end
|
||||
|
||||
scenario 'form is mask for the user' do
|
||||
expect(page.find_by_id('type_de_piece_justificative_2', visible: false).visible?).to be_falsey
|
||||
expect(page.find_by_id('type_de_piece_justificative_3', visible: false).visible?).to be_falsey
|
||||
end
|
||||
# scenario 'form is mask for the user' do
|
||||
# expect(page.find_by_id('type_de_piece_justificative_2', visible: false).visible?).to be_falsey
|
||||
# expect(page.find_by_id('type_de_piece_justificative_3', visible: false).visible?).to be_falsey
|
||||
# end
|
||||
|
||||
scenario 'delete attribut of type de piece_justificative is turn to true' do
|
||||
expect(page.find_by_id('type_de_piece_justificative_2', visible: false).find('input[class="destroy"]', visible: false).value).to eq('true')
|
||||
expect(page.find_by_id('type_de_piece_justificative_3', visible: false).find('input[class="destroy"]', visible: false).value).to eq('true')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
# scenario 'delete attribut of type de piece_justificative is turn to true' do
|
||||
# expect(page.find_by_id('type_de_piece_justificative_2', visible: false).find('input[class="destroy"]', visible: false).value).to eq('true')
|
||||
# expect(page.find_by_id('type_de_piece_justificative_3', visible: false).find('input[class="destroy"]', visible: false).value).to eq('true')
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
|
|
|
@ -1,79 +1,79 @@
|
|||
require 'spec_helper'
|
||||
|
||||
feature 'move down button type de champs', js: true do
|
||||
let(:administrateur) { create(:administrateur) }
|
||||
# feature 'move down button type de champs', js: true do
|
||||
# let(:administrateur) { create(:administrateur) }
|
||||
|
||||
before do
|
||||
login_as administrateur, scope: :administrateur
|
||||
end
|
||||
# before do
|
||||
# login_as administrateur, scope: :administrateur
|
||||
# end
|
||||
|
||||
context 'when click on move down type de champs button' do
|
||||
let!(:procedure) { create(:procedure, :with_type_de_champ) }
|
||||
let!(:type_de_champ) { create(:type_de_champ, procedure: procedure, order_place: 2) }
|
||||
# context 'when click on move down type de champs button' do
|
||||
# let!(:procedure) { create(:procedure, :with_type_de_champ) }
|
||||
# let!(:type_de_champ) { create(:type_de_champ, procedure: procedure, order_place: 2) }
|
||||
|
||||
before do
|
||||
visit admin_procedure_path id: procedure.id
|
||||
end
|
||||
# before do
|
||||
# visit admin_procedure_path id: procedure.id
|
||||
# end
|
||||
|
||||
context 'when procedure have two type de champs' do
|
||||
before do
|
||||
page.click_on 'order_type_de_champ_1_down_procedure'
|
||||
end
|
||||
# context 'when procedure have two type de champs' do
|
||||
# before do
|
||||
# page.click_on 'order_type_de_champ_1_down_procedure'
|
||||
# end
|
||||
|
||||
scenario 'it inverse the twice type de champs' do
|
||||
expect(page.find_by_id('type_de_champ_1').find('input[class="order_place"]', visible: false).value).to eq('2');
|
||||
expect(page.find_by_id('type_de_champ_2').find('input[class="order_place"]', visible: false).value).to eq('1');
|
||||
end
|
||||
end
|
||||
# scenario 'it inverse the twice type de champs' do
|
||||
# expect(page.find_by_id('type_de_champ_1').find('input[class="order_place"]', visible: false).value).to eq('2');
|
||||
# expect(page.find_by_id('type_de_champ_2').find('input[class="order_place"]', visible: false).value).to eq('1');
|
||||
# end
|
||||
# end
|
||||
|
||||
context 'when procedure have two type de champs in database and 3 type de champs add on the page' do
|
||||
before do
|
||||
page.click_on 'add_type_de_champ_procedure'
|
||||
page.click_on 'add_type_de_champ_procedure'
|
||||
page.click_on 'add_type_de_champ_procedure'
|
||||
end
|
||||
# context 'when procedure have two type de champs in database and 3 type de champs add on the page' do
|
||||
# before do
|
||||
# page.click_on 'add_type_de_champ_procedure'
|
||||
# page.click_on 'add_type_de_champ_procedure'
|
||||
# page.click_on 'add_type_de_champ_procedure'
|
||||
# end
|
||||
|
||||
context 'when to click on down_button type_de_champ_2' do
|
||||
before do
|
||||
page.click_on 'order_type_de_champ_2_down_procedure'
|
||||
end
|
||||
# context 'when to click on down_button type_de_champ_2' do
|
||||
# before do
|
||||
# page.click_on 'order_type_de_champ_2_down_procedure'
|
||||
# end
|
||||
|
||||
scenario 'type_de_champ_2 and type_de_champ_3 is reversed' do
|
||||
expect(page.find_by_id('type_de_champ_1').find('input[class="order_place"]', visible: false).value).to eq('1');
|
||||
expect(page.find_by_id('type_de_champ_3').find('input[class="order_place"]', visible: false).value).to eq('2');
|
||||
expect(page.find_by_id('type_de_champ_2').find('input[class="order_place"]', visible: false).value).to eq('3');
|
||||
expect(page.find_by_id('type_de_champ_4').find('input[class="order_place"]', visible: false).value).to eq('4');
|
||||
expect(page.find_by_id('type_de_champ_5').find('input[class="order_place"]', visible: false).value).to eq('5');
|
||||
end
|
||||
# scenario 'type_de_champ_2 and type_de_champ_3 is reversed' do
|
||||
# expect(page.find_by_id('type_de_champ_1').find('input[class="order_place"]', visible: false).value).to eq('1');
|
||||
# expect(page.find_by_id('type_de_champ_3').find('input[class="order_place"]', visible: false).value).to eq('2');
|
||||
# expect(page.find_by_id('type_de_champ_2').find('input[class="order_place"]', visible: false).value).to eq('3');
|
||||
# expect(page.find_by_id('type_de_champ_4').find('input[class="order_place"]', visible: false).value).to eq('4');
|
||||
# expect(page.find_by_id('type_de_champ_5').find('input[class="order_place"]', visible: false).value).to eq('5');
|
||||
# end
|
||||
|
||||
context 'when to click on up_button type_de_champ_4' do
|
||||
before do
|
||||
page.click_on 'order_type_de_champ_4_down_procedure'
|
||||
end
|
||||
# context 'when to click on up_button type_de_champ_4' do
|
||||
# before do
|
||||
# page.click_on 'order_type_de_champ_4_down_procedure'
|
||||
# end
|
||||
|
||||
scenario 'type_de_champ_4 and type_de_champ_5 is reversed' do
|
||||
expect(page.find_by_id('type_de_champ_1').find('input[class="order_place"]', visible: false).value).to eq('1');
|
||||
expect(page.find_by_id('type_de_champ_3').find('input[class="order_place"]', visible: false).value).to eq('2');
|
||||
expect(page.find_by_id('type_de_champ_2').find('input[class="order_place"]', visible: false).value).to eq('3');
|
||||
expect(page.find_by_id('type_de_champ_5').find('input[class="order_place"]', visible: false).value).to eq('4');
|
||||
expect(page.find_by_id('type_de_champ_4').find('input[class="order_place"]', visible: false).value).to eq('5');
|
||||
end
|
||||
# scenario 'type_de_champ_4 and type_de_champ_5 is reversed' do
|
||||
# expect(page.find_by_id('type_de_champ_1').find('input[class="order_place"]', visible: false).value).to eq('1');
|
||||
# expect(page.find_by_id('type_de_champ_3').find('input[class="order_place"]', visible: false).value).to eq('2');
|
||||
# expect(page.find_by_id('type_de_champ_2').find('input[class="order_place"]', visible: false).value).to eq('3');
|
||||
# expect(page.find_by_id('type_de_champ_5').find('input[class="order_place"]', visible: false).value).to eq('4');
|
||||
# expect(page.find_by_id('type_de_champ_4').find('input[class="order_place"]', visible: false).value).to eq('5');
|
||||
# end
|
||||
|
||||
context 'when to click on up_button type_de_champ_1' do
|
||||
before do
|
||||
page.click_on 'order_type_de_champ_1_down_procedure'
|
||||
end
|
||||
# context 'when to click on up_button type_de_champ_1' do
|
||||
# before do
|
||||
# page.click_on 'order_type_de_champ_1_down_procedure'
|
||||
# end
|
||||
|
||||
scenario 'type_de_champ_1 and type_de_champ_3 is reversed' do
|
||||
expect(page.find_by_id('type_de_champ_3').find('input[class="order_place"]', visible: false).value).to eq('1');
|
||||
expect(page.find_by_id('type_de_champ_1').find('input[class="order_place"]', visible: false).value).to eq('2');
|
||||
expect(page.find_by_id('type_de_champ_2').find('input[class="order_place"]', visible: false).value).to eq('3');
|
||||
expect(page.find_by_id('type_de_champ_5').find('input[class="order_place"]', visible: false).value).to eq('4');
|
||||
expect(page.find_by_id('type_de_champ_4').find('input[class="order_place"]', visible: false).value).to eq('5');
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
# scenario 'type_de_champ_1 and type_de_champ_3 is reversed' do
|
||||
# expect(page.find_by_id('type_de_champ_3').find('input[class="order_place"]', visible: false).value).to eq('1');
|
||||
# expect(page.find_by_id('type_de_champ_1').find('input[class="order_place"]', visible: false).value).to eq('2');
|
||||
# expect(page.find_by_id('type_de_champ_2').find('input[class="order_place"]', visible: false).value).to eq('3');
|
||||
# expect(page.find_by_id('type_de_champ_5').find('input[class="order_place"]', visible: false).value).to eq('4');
|
||||
# expect(page.find_by_id('type_de_champ_4').find('input[class="order_place"]', visible: false).value).to eq('5');
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
|
|
|
@ -1,72 +1,72 @@
|
|||
require 'spec_helper'
|
||||
|
||||
feature 'move up and down button type de champs', js: true do
|
||||
let(:administrateur) { create(:administrateur) }
|
||||
# feature 'move up and down button type de champs', js: true do
|
||||
# let(:administrateur) { create(:administrateur) }
|
||||
|
||||
before do
|
||||
login_as administrateur, scope: :administrateur
|
||||
end
|
||||
# before do
|
||||
# login_as administrateur, scope: :administrateur
|
||||
# end
|
||||
|
||||
context 'when click on move up and down type de champs button' do
|
||||
let!(:procedure) { create(:procedure, :with_type_de_champ) }
|
||||
let!(:type_de_champ) { create(:type_de_champ, procedure: procedure, order_place: 2) }
|
||||
# context 'when click on move up and down type de champs button' do
|
||||
# let!(:procedure) { create(:procedure, :with_type_de_champ) }
|
||||
# let!(:type_de_champ) { create(:type_de_champ, procedure: procedure, order_place: 2) }
|
||||
|
||||
before do
|
||||
visit admin_procedure_path id: procedure.id
|
||||
end
|
||||
# before do
|
||||
# visit admin_procedure_path id: procedure.id
|
||||
# end
|
||||
|
||||
context 'when procedure have two type de champs in database and 3 type de champs add on the page' do
|
||||
before do
|
||||
page.click_on 'add_type_de_champ_procedure'
|
||||
page.click_on 'add_type_de_champ_procedure'
|
||||
page.click_on 'add_type_de_champ_procedure'
|
||||
end
|
||||
#
|
||||
context 'when to click on up_button type_de_champ_2 and down_button type_de_champ_1' do
|
||||
before do
|
||||
page.click_on 'order_type_de_champ_2_up_procedure'
|
||||
page.click_on 'order_type_de_champ_1_down_procedure'
|
||||
end
|
||||
# context 'when procedure have two type de champs in database and 3 type de champs add on the page' do
|
||||
# before do
|
||||
# page.click_on 'add_type_de_champ_procedure'
|
||||
# page.click_on 'add_type_de_champ_procedure'
|
||||
# page.click_on 'add_type_de_champ_procedure'
|
||||
# end
|
||||
# #
|
||||
# context 'when to click on up_button type_de_champ_2 and down_button type_de_champ_1' do
|
||||
# before do
|
||||
# page.click_on 'order_type_de_champ_2_up_procedure'
|
||||
# page.click_on 'order_type_de_champ_1_down_procedure'
|
||||
# end
|
||||
|
||||
scenario 'type_de_champ_1 is at order place 3 and type_de_champ_2 is at order place 1 ' do
|
||||
expect(page.find_by_id('type_de_champ_2').find('input[class="order_place"]', visible: false).value).to eq('1');
|
||||
expect(page.find_by_id('type_de_champ_3').find('input[class="order_place"]', visible: false).value).to eq('2');
|
||||
expect(page.find_by_id('type_de_champ_1').find('input[class="order_place"]', visible: false).value).to eq('3');
|
||||
expect(page.find_by_id('type_de_champ_4').find('input[class="order_place"]', visible: false).value).to eq('4');
|
||||
expect(page.find_by_id('type_de_champ_5').find('input[class="order_place"]', visible: false).value).to eq('5');
|
||||
end
|
||||
# scenario 'type_de_champ_1 is at order place 3 and type_de_champ_2 is at order place 1 ' do
|
||||
# expect(page.find_by_id('type_de_champ_2').find('input[class="order_place"]', visible: false).value).to eq('1');
|
||||
# expect(page.find_by_id('type_de_champ_3').find('input[class="order_place"]', visible: false).value).to eq('2');
|
||||
# expect(page.find_by_id('type_de_champ_1').find('input[class="order_place"]', visible: false).value).to eq('3');
|
||||
# expect(page.find_by_id('type_de_champ_4').find('input[class="order_place"]', visible: false).value).to eq('4');
|
||||
# expect(page.find_by_id('type_de_champ_5').find('input[class="order_place"]', visible: false).value).to eq('5');
|
||||
# end
|
||||
|
||||
context 'when to click on down_button type_de_champ_4 and up_button type_de_champ_5' do
|
||||
before do
|
||||
page.click_on 'order_type_de_champ_4_down_procedure'
|
||||
page.click_on 'order_type_de_champ_5_up_procedure'
|
||||
end
|
||||
# context 'when to click on down_button type_de_champ_4 and up_button type_de_champ_5' do
|
||||
# before do
|
||||
# page.click_on 'order_type_de_champ_4_down_procedure'
|
||||
# page.click_on 'order_type_de_champ_5_up_procedure'
|
||||
# end
|
||||
|
||||
scenario 'type_de_champ_2 and type_de_champ_3 is reversed' do
|
||||
expect(page.find_by_id('type_de_champ_2').find('input[class="order_place"]', visible: false).value).to eq('1');
|
||||
expect(page.find_by_id('type_de_champ_3').find('input[class="order_place"]', visible: false).value).to eq('2');
|
||||
expect(page.find_by_id('type_de_champ_5').find('input[class="order_place"]', visible: false).value).to eq('3');
|
||||
expect(page.find_by_id('type_de_champ_1').find('input[class="order_place"]', visible: false).value).to eq('4');
|
||||
expect(page.find_by_id('type_de_champ_4').find('input[class="order_place"]', visible: false).value).to eq('5');
|
||||
end
|
||||
# scenario 'type_de_champ_2 and type_de_champ_3 is reversed' do
|
||||
# expect(page.find_by_id('type_de_champ_2').find('input[class="order_place"]', visible: false).value).to eq('1');
|
||||
# expect(page.find_by_id('type_de_champ_3').find('input[class="order_place"]', visible: false).value).to eq('2');
|
||||
# expect(page.find_by_id('type_de_champ_5').find('input[class="order_place"]', visible: false).value).to eq('3');
|
||||
# expect(page.find_by_id('type_de_champ_1').find('input[class="order_place"]', visible: false).value).to eq('4');
|
||||
# expect(page.find_by_id('type_de_champ_4').find('input[class="order_place"]', visible: false).value).to eq('5');
|
||||
# end
|
||||
|
||||
context 'when to click on up_button type_de_champ_3 and down_button type_de_champ_1 and up_button type_de_champ_5' do
|
||||
before do
|
||||
page.click_on 'order_type_de_champ_3_up_procedure'
|
||||
page.click_on 'order_type_de_champ_1_down_procedure'
|
||||
page.click_on 'order_type_de_champ_5_up_procedure'
|
||||
end
|
||||
# context 'when to click on up_button type_de_champ_3 and down_button type_de_champ_1 and up_button type_de_champ_5' do
|
||||
# before do
|
||||
# page.click_on 'order_type_de_champ_3_up_procedure'
|
||||
# page.click_on 'order_type_de_champ_1_down_procedure'
|
||||
# page.click_on 'order_type_de_champ_5_up_procedure'
|
||||
# end
|
||||
|
||||
scenario 'type_de_champ_2 and type_de_champ_4 is reversed' do
|
||||
expect(page.find_by_id('type_de_champ_3').find('input[class="order_place"]', visible: false).value).to eq('1');
|
||||
expect(page.find_by_id('type_de_champ_5').find('input[class="order_place"]', visible: false).value).to eq('2');
|
||||
expect(page.find_by_id('type_de_champ_2').find('input[class="order_place"]', visible: false).value).to eq('3');
|
||||
expect(page.find_by_id('type_de_champ_4').find('input[class="order_place"]', visible: false).value).to eq('4');
|
||||
expect(page.find_by_id('type_de_champ_1').find('input[class="order_place"]', visible: false).value).to eq('5');
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
# scenario 'type_de_champ_2 and type_de_champ_4 is reversed' do
|
||||
# expect(page.find_by_id('type_de_champ_3').find('input[class="order_place"]', visible: false).value).to eq('1');
|
||||
# expect(page.find_by_id('type_de_champ_5').find('input[class="order_place"]', visible: false).value).to eq('2');
|
||||
# expect(page.find_by_id('type_de_champ_2').find('input[class="order_place"]', visible: false).value).to eq('3');
|
||||
# expect(page.find_by_id('type_de_champ_4').find('input[class="order_place"]', visible: false).value).to eq('4');
|
||||
# expect(page.find_by_id('type_de_champ_1').find('input[class="order_place"]', visible: false).value).to eq('5');
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
|
|
|
@ -1,80 +1,80 @@
|
|||
require 'spec_helper'
|
||||
|
||||
feature 'move up button type de champs', js: true do
|
||||
# feature 'move up button type de champs', js: true do
|
||||
|
||||
let(:administrateur) { create(:administrateur) }
|
||||
# let(:administrateur) { create(:administrateur) }
|
||||
|
||||
before do
|
||||
login_as administrateur, scope: :administrateur
|
||||
end
|
||||
# before do
|
||||
# login_as administrateur, scope: :administrateur
|
||||
# end
|
||||
|
||||
context 'when click on move up type de champs button' do
|
||||
let!(:procedure) { create(:procedure, :with_type_de_champ) }
|
||||
let!(:type_de_champ) { create(:type_de_champ, procedure: procedure, order_place: 2) }
|
||||
# context 'when click on move up type de champs button' do
|
||||
# let!(:procedure) { create(:procedure, :with_type_de_champ) }
|
||||
# let!(:type_de_champ) { create(:type_de_champ, procedure: procedure, order_place: 2) }
|
||||
|
||||
before do
|
||||
visit admin_procedure_path id: procedure.id
|
||||
end
|
||||
# before do
|
||||
# visit admin_procedure_path id: procedure.id
|
||||
# end
|
||||
|
||||
context 'when procedure have two type de champs' do
|
||||
before do
|
||||
page.click_on 'order_type_de_champ_2_up_procedure'
|
||||
end
|
||||
# context 'when procedure have two type de champs' do
|
||||
# before do
|
||||
# page.click_on 'order_type_de_champ_2_up_procedure'
|
||||
# end
|
||||
|
||||
scenario 'it inverse the twice type de champs' do
|
||||
expect(page.find_by_id('type_de_champ_1').find('input[class="order_place"]', visible: false).value).to eq('2');
|
||||
expect(page.find_by_id('type_de_champ_2').find('input[class="order_place"]', visible: false).value).to eq('1');
|
||||
end
|
||||
end
|
||||
# scenario 'it inverse the twice type de champs' do
|
||||
# expect(page.find_by_id('type_de_champ_1').find('input[class="order_place"]', visible: false).value).to eq('2');
|
||||
# expect(page.find_by_id('type_de_champ_2').find('input[class="order_place"]', visible: false).value).to eq('1');
|
||||
# end
|
||||
# end
|
||||
|
||||
context 'when procedure have two type de champs in database and 3 type de champs add on the page' do
|
||||
before do
|
||||
page.click_on 'add_type_de_champ_procedure'
|
||||
page.click_on 'add_type_de_champ_procedure'
|
||||
page.click_on 'add_type_de_champ_procedure'
|
||||
end
|
||||
# context 'when procedure have two type de champs in database and 3 type de champs add on the page' do
|
||||
# before do
|
||||
# page.click_on 'add_type_de_champ_procedure'
|
||||
# page.click_on 'add_type_de_champ_procedure'
|
||||
# page.click_on 'add_type_de_champ_procedure'
|
||||
# end
|
||||
|
||||
context 'when to click on up_button type_de_champ_2' do
|
||||
before do
|
||||
page.click_on 'order_type_de_champ_2_up_procedure'
|
||||
end
|
||||
# context 'when to click on up_button type_de_champ_2' do
|
||||
# before do
|
||||
# page.click_on 'order_type_de_champ_2_up_procedure'
|
||||
# end
|
||||
|
||||
scenario 'type_de_champ_1 and type_de_champ_2 is reversed' do
|
||||
expect(page.find_by_id('type_de_champ_2').find('input[class="order_place"]', visible: false).value).to eq('1');
|
||||
expect(page.find_by_id('type_de_champ_1').find('input[class="order_place"]', visible: false).value).to eq('2');
|
||||
expect(page.find_by_id('type_de_champ_3').find('input[class="order_place"]', visible: false).value).to eq('3');
|
||||
expect(page.find_by_id('type_de_champ_4').find('input[class="order_place"]', visible: false).value).to eq('4');
|
||||
expect(page.find_by_id('type_de_champ_5').find('input[class="order_place"]', visible: false).value).to eq('5');
|
||||
end
|
||||
# scenario 'type_de_champ_1 and type_de_champ_2 is reversed' do
|
||||
# expect(page.find_by_id('type_de_champ_2').find('input[class="order_place"]', visible: false).value).to eq('1');
|
||||
# expect(page.find_by_id('type_de_champ_1').find('input[class="order_place"]', visible: false).value).to eq('2');
|
||||
# expect(page.find_by_id('type_de_champ_3').find('input[class="order_place"]', visible: false).value).to eq('3');
|
||||
# expect(page.find_by_id('type_de_champ_4').find('input[class="order_place"]', visible: false).value).to eq('4');
|
||||
# expect(page.find_by_id('type_de_champ_5').find('input[class="order_place"]', visible: false).value).to eq('5');
|
||||
# end
|
||||
|
||||
context 'when to click on up_button type_de_champ_4' do
|
||||
before do
|
||||
page.click_on 'order_type_de_champ_4_up_procedure'
|
||||
end
|
||||
# context 'when to click on up_button type_de_champ_4' do
|
||||
# before do
|
||||
# page.click_on 'order_type_de_champ_4_up_procedure'
|
||||
# end
|
||||
|
||||
scenario 'type_de_champ_3 and type_de_champ_4 is reversed' do
|
||||
expect(page.find_by_id('type_de_champ_2').find('input[class="order_place"]', visible: false).value).to eq('1');
|
||||
expect(page.find_by_id('type_de_champ_1').find('input[class="order_place"]', visible: false).value).to eq('2');
|
||||
expect(page.find_by_id('type_de_champ_4').find('input[class="order_place"]', visible: false).value).to eq('3');
|
||||
expect(page.find_by_id('type_de_champ_3').find('input[class="order_place"]', visible: false).value).to eq('4');
|
||||
expect(page.find_by_id('type_de_champ_5').find('input[class="order_place"]', visible: false).value).to eq('5');
|
||||
end
|
||||
# scenario 'type_de_champ_3 and type_de_champ_4 is reversed' do
|
||||
# expect(page.find_by_id('type_de_champ_2').find('input[class="order_place"]', visible: false).value).to eq('1');
|
||||
# expect(page.find_by_id('type_de_champ_1').find('input[class="order_place"]', visible: false).value).to eq('2');
|
||||
# expect(page.find_by_id('type_de_champ_4').find('input[class="order_place"]', visible: false).value).to eq('3');
|
||||
# expect(page.find_by_id('type_de_champ_3').find('input[class="order_place"]', visible: false).value).to eq('4');
|
||||
# expect(page.find_by_id('type_de_champ_5').find('input[class="order_place"]', visible: false).value).to eq('5');
|
||||
# end
|
||||
|
||||
context 'when to click on up_button type_de_champ_5' do
|
||||
before do
|
||||
page.click_on 'order_type_de_champ_5_up_procedure'
|
||||
end
|
||||
# context 'when to click on up_button type_de_champ_5' do
|
||||
# before do
|
||||
# page.click_on 'order_type_de_champ_5_up_procedure'
|
||||
# end
|
||||
|
||||
scenario 'type_de_champ_3 and type_de_champ_5 is reversed' do
|
||||
expect(page.find_by_id('type_de_champ_2').find('input[class="order_place"]', visible: false).value).to eq('1');
|
||||
expect(page.find_by_id('type_de_champ_1').find('input[class="order_place"]', visible: false).value).to eq('2');
|
||||
expect(page.find_by_id('type_de_champ_4').find('input[class="order_place"]', visible: false).value).to eq('3');
|
||||
expect(page.find_by_id('type_de_champ_5').find('input[class="order_place"]', visible: false).value).to eq('4');
|
||||
expect(page.find_by_id('type_de_champ_3').find('input[class="order_place"]', visible: false).value).to eq('5');
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
# scenario 'type_de_champ_3 and type_de_champ_5 is reversed' do
|
||||
# expect(page.find_by_id('type_de_champ_2').find('input[class="order_place"]', visible: false).value).to eq('1');
|
||||
# expect(page.find_by_id('type_de_champ_1').find('input[class="order_place"]', visible: false).value).to eq('2');
|
||||
# expect(page.find_by_id('type_de_champ_4').find('input[class="order_place"]', visible: false).value).to eq('3');
|
||||
# expect(page.find_by_id('type_de_champ_5').find('input[class="order_place"]', visible: false).value).to eq('4');
|
||||
# expect(page.find_by_id('type_de_champ_3').find('input[class="order_place"]', visible: false).value).to eq('5');
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
|
|
|
@ -31,8 +31,8 @@ describe TypeDeChamp do
|
|||
end
|
||||
|
||||
context 'order_place' do
|
||||
it { is_expected.not_to allow_value(nil).for(:order_place) }
|
||||
it { is_expected.not_to allow_value('').for(:order_place) }
|
||||
# it { is_expected.not_to allow_value(nil).for(:order_place) }
|
||||
# it { is_expected.not_to allow_value('').for(:order_place) }
|
||||
it { is_expected.to allow_value(1).for(:order_place) }
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue