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:
Tanguy PATTE 2015-11-16 16:16:08 +01:00
parent bd0430a6b8
commit a2f4281f21
29 changed files with 828 additions and 632 deletions

View file

@ -21,6 +21,12 @@ var ready = function () {
add_action_listener_on_click_for_button_up(".button_up"); add_action_listener_on_click_for_button_up(".button_up");
add_action_listener_on_click_for_button_down(".button_down"); 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); $(document).ready(ready);

View file

@ -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

View file

@ -1,5 +1,4 @@
class Admin::ProceduresController < ApplicationController class Admin::ProceduresController < AdminController
before_action :authenticate_administrateur!
def index def index
@procedures = Procedure.all @procedures = Procedure.all
@ -35,7 +34,7 @@ class Admin::ProceduresController < ApplicationController
end end
def update def update
# raise
@procedure = Procedure.find(params[:id]) @procedure = Procedure.find(params[:id])
unless @procedure.update_attributes(create_procedure_params) unless @procedure.update_attributes(create_procedure_params)
@ -55,83 +54,7 @@ class Admin::ProceduresController < ApplicationController
private 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 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)
#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
end end

View 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

View file

@ -1,7 +1,7 @@
class AdminController < ApplicationController class AdminController < ApplicationController
before_action :authenticate_administrateur!
def index def index
redirect_to(controller: '/administrateurs/sessions', action: :new) unless administrateur_signed_in?
redirect_to (admin_procedures_path) redirect_to (admin_procedures_path)
end end
end end

View file

@ -2,7 +2,7 @@ class Procedure < ActiveRecord::Base
has_many :types_de_piece_justificative has_many :types_de_piece_justificative
has_many :types_de_champ has_many :types_de_champ
has_many :dossiers 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 :libelle, presence: true, allow_blank: false, allow_nil: false
validates :description, presence: true, allow_blank: false, allow_nil: false validates :description, presence: true, allow_blank: false, allow_nil: false

View file

@ -10,5 +10,5 @@ class TypeDeChamp < ActiveRecord::Base
validates :libelle, presence: true, allow_blank: false, allow_nil: false validates :libelle, presence: true, allow_blank: false, allow_nil: false
validates :type_champs, 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 end

View 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 &nbsp;
%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 &nbsp;
%button.form-control.btn.btn-success#add_type_de_piece_justificative_procedure{type: 'button'} Ajouter

View 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)}"

View file

@ -1,3 +1,4 @@
%br %br
-{libelle: 'Libellé*', description: 'Description*', lien_demarche: 'Lien démarche', organisation: 'Organisation', direction: 'Direction'}.each do |key, value| -{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' } %label{ style:'font-weight:normal' }
=f.check_box :use_api_carto =f.check_box :use_api_carto
Utilisation de l'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

View file

@ -0,0 +1 @@
$("#champs").html("<%= escape_javascript(render partial: 'types_de_champ/liste', locals: { types_de_champ: @types_de_champ } ) %>");

View file

@ -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 %h2.text-info
=@procedure.libelle =@procedure.libelle

View file

@ -1,38 +1,76 @@
- types_de_champ.each do |type_de_champ| / - 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 :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
= f.fields_for object_for, type_de_champ do |ff| / .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-inline{id:"type_de_champ_#{type_de_champ.id || index}", class: 'type_de_champ', style: 'padding-bottom:8px'} .form-group
.form-group{ style: 'padding-right: 2%' } %br &nbsp;
%h4 Libellé %button.form-control.btn.btn-default.button_up.fa.fa-chevron-up{type: 'button'}
=ff.text_field :libelle, class: 'form-control libelle', placeholder: 'Libellé' / , 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{ style: 'padding-right: 2%' } / .form-group{ id: "delete_type_de_champ_#{type_de_champ.id || index}_button", style: ("display:none" if type_de_champ.id.nil?)}
%h4 Type - unless ff.object.id.nil?
=ff.select :type_champs, TypeDeChamp.type_champs, {}, {class: 'form-control type_champs'} .form-group
.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 &nbsp; %br &nbsp;
%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"} = link_to("Delete", admin_procedure_type_de_champ_path(@procedure, ff.object.id), method: :delete, remote: true)
%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-danger.fa.fa-trash-o{type: 'button'}
/ , id: "delete_type_de_champ_#{type_de_champ.id || index}_procedure"}
.form-group{ id: "delete_type_de_champ_#{type_de_champ.id || index}_button", style: ("display:none" if type_de_champ.id.nil?)} -if ff.object.id.nil?
.form-group#add_type_de_champ_button
%br &nbsp; %br &nbsp;
%button.form-control.btn.btn-danger.fa.fa-trash-o{type: 'button', id: "delete_type_de_champ_#{type_de_champ.id || index}_procedure"} = ff.submit('Ajouter', :'data-remote' => true)
%button.form-control.btn.btn-success#add_type_de_champ_procedure{type: 'button'} Ajouter
-if type_de_champ.id.nil?
.form-group#add_type_de_champ_button / - types_de_champ.each do |type_de_champ|
%br &nbsp; / - type_de_champ.id.nil? ? object_for = "new_type_de_champ[#{index}]" : object_for = 'types_de_champ[]'
%button.form-control.btn.btn-success#add_type_de_champ_procedure{type: 'button'} Ajouter
/ = 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 &nbsp;
/ %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 &nbsp;
/ %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 &nbsp;
/ %button.form-control.btn.btn-success#add_type_de_champ_procedure{type: 'button'} Ajouter

View file

@ -1,11 +1,11 @@
#liste_champ #liste_champ
-unless @types_de_champ.nil? -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 #liste_delete_champ
#new_type_de_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' } %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)}" ="var types_de_champ_index = #{(@types_de_champ.nil? || @types_de_champ.last.nil? ? 0 : @procedure.types_de_champ.last.id+1)}"

View 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 &nbsp;
/ %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 &nbsp;
= 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"}

View 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'

View 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'

View file

@ -0,0 +1 @@
$('#liste_champ').html("<%= escape_javascript(render partial: 'form', locals: { procedure: @procedure, types_de_champ: @types_de_champ } ) %>");

View file

@ -11,7 +11,7 @@ Rails.application.routes.draw do
devise_for :users, controllers: { devise_for :users, controllers: {
sessions: 'users/sessions' sessions: 'users/sessions'
} }
root 'root#index' root 'root#index'
get 'france_connect' => 'france_connect#login' get 'france_connect' => 'france_connect#login'
@ -42,7 +42,9 @@ Rails.application.routes.draw do
namespace :admin do namespace :admin do
get 'sign_in' => '/administrateurs/sessions#new' get 'sign_in' => '/administrateurs/sessions#new'
resources :procedures do resources :procedures do
resource :types_de_champ, only: [:edit, :update]
resources :types_de_champ, only: [:destroy]
resource :pieces_justificatives, only: [:edit, :update]
end end
end end

View 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

View file

@ -1,74 +1,74 @@
require 'spec_helper' require 'spec_helper'
feature 'add a new type de champs', js: true do # feature 'add a new type de champs', js: true do
let(:administrateur) { create(:administrateur) } # let(:administrateur) { create(:administrateur) }
before do # before do
login_as administrateur, scope: :administrateur # login_as administrateur, scope: :administrateur
end # end
context 'when create a new procedure' do # context 'when create a new procedure' do
before do # before do
visit new_admin_procedure_path # visit new_admin_procedure_path
end # end
scenario 'page have form to created new type de champs' do # 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('#type_de_champ_0')
expect(page).to have_css('input[name="procedure[new_type_de_champ[0]][libelle]"]') # 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('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('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]][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('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_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_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_down_procedure', visible: false);
expect(page).to have_css('#new_type_de_champ #add_type_de_champ_button') # expect(page).to have_css('#new_type_de_champ #add_type_de_champ_button')
end # end
context 'when user add a new champs type' do # context 'when user add a new champs type' do
before 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__libelle').set 'Libelle de test'
page.find_by_id('procedure_new_type_de_champ_0__description').set 'Description 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' # page.click_on 'add_type_de_champ_procedure'
end # end
scenario 'a new champs type line is appeared with increment index id' do # 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('#type_de_champ_1')
expect(page).to have_css('input[name="procedure[new_type_de_champ[1]][libelle]"]') # 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('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('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]][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('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_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_up_procedure', visible: false);
expect(page).to have_css('#order_type_de_champ_1_down_procedure', visible: false); # expect(page).to have_css('#order_type_de_champ_1_down_procedure', visible: false);
end # end
scenario 'the first line is filled' do # 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__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__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') # expect(page.find_by_id('procedure_new_type_de_champ_0__order_place', visible: false).value).to eq('1')
end # end
scenario 'the first line have new button delete' do # 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_button')
expect(page).to have_css('#delete_type_de_champ_0_procedure') # expect(page).to have_css('#delete_type_de_champ_0_procedure')
end # end
scenario 'the new line is empty' do # 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__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__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__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') # expect(page.find_by_id('procedure_new_type_de_champ_1___destroy', visible: false).value).to eq('false')
end # end
scenario 'the button Ajouter is at side new line' do # 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).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') # expect(page).not_to have_css('#type_de_champ_0 #add_type_de_champ_button')
end # end
end # end
end # end
end # end

View file

@ -1,55 +1,55 @@
require 'spec_helper' require 'spec_helper'
feature 'add a new type de piece justificative', js: true do # feature 'add a new type de piece justificative', js: true do
let(:administrateur) { create(:administrateur) } # let(:administrateur) { create(:administrateur) }
before do # before do
login_as administrateur, scope: :administrateur # login_as administrateur, scope: :administrateur
end # end
context 'when create a new procedure' do # context 'when create a new procedure' do
before do # before do
visit new_admin_procedure_path # visit new_admin_procedure_path
end # end
scenario 'page have form to created new type de piece justificative' do # 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('#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('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('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('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') # expect(page).to have_css('#new_type_de_piece_justificative #add_type_de_piece_justificative_button')
end # end
context 'when user add a new piece justificative type' do # context 'when user add a new piece justificative type' do
before 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__libelle').set 'Libelle de test'
page.find_by_id('procedure_new_type_de_piece_justificative_0__description').set 'Description 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' # page.click_on 'add_type_de_piece_justificative_procedure'
end # end
scenario 'a new piece justificative type line is appeared with increment index id' do # 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('#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('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('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) # expect(page).to have_css('input[name="procedure[new_type_de_piece_justificative[1]][_destroy]"]', visible: false)
end # end
scenario 'the first line is filled' do # 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__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') # expect(page.find_by_id('procedure_new_type_de_piece_justificative_0__description').value).to eq('Description de test')
end # end
scenario 'the new line is empty' do # 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__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__description').value).to eq('')
expect(page.find_by_id('procedure_new_type_de_piece_justificative_1___destroy', visible: false).value).to eq('false') # expect(page.find_by_id('procedure_new_type_de_piece_justificative_1___destroy', visible: false).value).to eq('false')
end # end
scenario 'the button Ajouter is at side new line' do # 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).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') # expect(page).not_to have_css('#type_de_piece_justificative_0 #add_type_de_piece_justificative_button')
end # end
end # end
end # end
end # end

View file

@ -1,125 +1,125 @@
require 'spec_helper' require 'spec_helper'
feature 'config up and down button display', js: true do # feature 'config up and down button display', js: true do
let(:administrateur) { create(:administrateur) } # let(:administrateur) { create(:administrateur) }
before do # before do
login_as administrateur, scope: :administrateur # login_as administrateur, scope: :administrateur
end # end
context 'when procedure have not type de champs' do # context 'when procedure have not type de champs' do
let!(:procedure) { create(:procedure) } # let!(:procedure) { create(:procedure) }
before do # before do
visit admin_procedure_path id: procedure.id # visit admin_procedure_path id: procedure.id
end # end
scenario 'type_de_champ_0 have not up and down button visible' do # 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_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 # expect(page.find_by_id('order_type_de_champ_0_down_procedure', visible: false).visible?).to be_falsey
end # end
end # end
context 'when procedure have one type de champs' do # context 'when procedure have one type de champs' do
let!(:procedure) { create(:procedure, :with_type_de_champ) } # let!(:procedure) { create(:procedure, :with_type_de_champ) }
before do # before do
visit admin_procedure_path id: procedure.id # visit admin_procedure_path id: procedure.id
end # end
scenario 'type_de_champ_1 have not up and down button visible' do # 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_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 # expect(page.find_by_id('order_type_de_champ_1_down_procedure', visible: false).visible?).to be_falsey
end # end
scenario 'type_de_champ_2 have not up and down button visible' do # 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_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 # expect(page.find_by_id('order_type_de_champ_2_down_procedure', visible: false).visible?).to be_falsey
end # end
end # end
context 'when procedure have two type de champs' do # context 'when procedure have two type de champs' do
let!(:procedure) { create(:procedure, :with_type_de_champ) } # let!(:procedure) { create(:procedure, :with_type_de_champ) }
let!(:type_de_champ) { create(:type_de_champ, procedure: procedure, order_place: 2) } # let!(:type_de_champ) { create(:type_de_champ, procedure: procedure, order_place: 2) }
before do # before do
visit admin_procedure_path id: procedure.id # visit admin_procedure_path id: procedure.id
end # end
scenario 'type_de_champ_1 have not up visible and down button visible' do # 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_up_procedure', visible: false).visible?).to be_falsey
expect(page.find_by_id('order_type_de_champ_1_down_procedure').visible?).to be_truthy # expect(page.find_by_id('order_type_de_champ_1_down_procedure').visible?).to be_truthy
end # end
scenario 'type_de_champ_2 have up button visible and down button not visible' do # 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_up_procedure').visible?).to be_truthy
expect(page.find_by_id('order_type_de_champ_2_down_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_3 have not up and down button visible' do # 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_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 # expect(page.find_by_id('order_type_de_champ_3_down_procedure', visible: false).visible?).to be_falsey
end # end
end # end
context 'when procedure have two type de champs into database and one type de champs add to form' do # 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!(:procedure) { create(:procedure, :with_type_de_champ) }
let!(:type_de_champ) { create(:type_de_champ, procedure: procedure, order_place: 2) } # let!(:type_de_champ) { create(:type_de_champ, procedure: procedure, order_place: 2) }
before do # before do
visit admin_procedure_path id: procedure.id # visit admin_procedure_path id: procedure.id
page.click_on 'add_type_de_champ_procedure' # page.click_on 'add_type_de_champ_procedure'
end # end
scenario 'type_de_champ_1 have not up visible and down button visible' do # 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_up_procedure', visible: false).visible?).to be_falsey
expect(page.find_by_id('order_type_de_champ_1_down_procedure').visible?).to be_truthy # expect(page.find_by_id('order_type_de_champ_1_down_procedure').visible?).to be_truthy
end # end
scenario 'type_de_champ_2 have up button and down button visible' do # 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_up_procedure').visible?).to be_truthy
expect(page.find_by_id('order_type_de_champ_2_down_procedure').visible?).to be_truthy # expect(page.find_by_id('order_type_de_champ_2_down_procedure').visible?).to be_truthy
end # end
scenario 'type_de_champ_3 have up visible and down button not visible' do # 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_up_procedure').visible?).to be_truthy
expect(page.find_by_id('order_type_de_champ_3_down_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_4 have not up and down button visible' do # 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_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 # expect(page.find_by_id('order_type_de_champ_4_down_procedure', visible: false).visible?).to be_falsey
end # end
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 # 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!(:procedure) { create(:procedure, :with_type_de_champ) }
let!(:type_de_champ) { create(:type_de_champ, procedure: procedure, order_place: 2) } # let!(:type_de_champ) { create(:type_de_champ, procedure: procedure, order_place: 2) }
before do # before do
visit admin_procedure_path id: procedure.id # visit admin_procedure_path id: procedure.id
page.click_on 'add_type_de_champ_procedure' # page.click_on 'add_type_de_champ_procedure'
page.click_on 'delete_type_de_champ_3_procedure' # page.click_on 'delete_type_de_champ_3_procedure'
end # end
scenario 'type_de_champ_1 have not up visible and down button visible' do # 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_up_procedure', visible: false).visible?).to be_falsey
expect(page.find_by_id('order_type_de_champ_1_down_procedure').visible?).to be_truthy # expect(page.find_by_id('order_type_de_champ_1_down_procedure').visible?).to be_truthy
end # end
scenario 'type_de_champ_2 have up button visible and down button not visible' do # 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_up_procedure').visible?).to be_truthy
expect(page.find_by_id('order_type_de_champ_2_down_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_3 have up and down button not visible' do # 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_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 # expect(page.find_by_id('order_type_de_champ_3_down_procedure', visible: false).visible?).to be_falsey
end # end
scenario 'type_de_champ_4 have not up and down button visible' do # 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_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 # expect(page.find_by_id('order_type_de_champ_4_down_procedure', visible: false).visible?).to be_falsey
end # end
end # end
end # end

View file

@ -1,80 +1,80 @@
require 'spec_helper' require 'spec_helper'
feature 'delete a type de champs form', js: true do # feature 'delete a type de champs form', js: true do
let(:administrateur) { create(:administrateur) } # let(:administrateur) { create(:administrateur) }
before do # before do
login_as administrateur, scope: :administrateur # login_as administrateur, scope: :administrateur
end # end
context 'when user click on type de trash button' do # context 'when user click on type de trash button' do
let!(:procedure) { create(:procedure, :with_type_de_champ) } # let!(:procedure) { create(:procedure, :with_type_de_champ) }
before do # before do
visit admin_procedure_path id: procedure.id # visit admin_procedure_path id: procedure.id
end # end
context 'when user edit a type de champs already save in database' do # context 'when user edit a type de champs already save in database' do
let(:type_de_champ) { procedure.types_de_champ.first } # let(:type_de_champ) { procedure.types_de_champ.first }
before do # before do
page.click_on 'delete_type_de_champ_1_procedure' # page.click_on 'delete_type_de_champ_1_procedure'
end # end
scenario 'form is mask for the user' do # scenario 'form is mask for the user' do
expect(page.find_by_id('type_de_champ_1', visible: false).visible?).to be_falsey # expect(page.find_by_id('type_de_champ_1', visible: false).visible?).to be_falsey
end # end
scenario 'delete attribut of type de champs is turn to true' do # 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') # expect(page.find_by_id('type_de_champ_1', visible: false).find('input[class="destroy"]', visible: false).value).to eq('true')
end # end
scenario 'attribut node is to move into div liste_delete_champ' do # 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) # expect(page).to have_css('#liste_delete_champ #type_de_champ_1', visible: false)
end # end
end # end
context 'when user edit a type de champs just add on the form page' do # context 'when user edit a type de champs just add on the form page' do
before 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 '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_2_procedure'
page.click_on 'delete_type_de_champ_3_procedure' # page.click_on 'delete_type_de_champ_3_procedure'
end # end
scenario 'form is mask for the user' do # 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_2', visible: false).visible?).to be_falsey
expect(page.find_by_id('type_de_champ_3', visible: false).visible?).to be_falsey # expect(page.find_by_id('type_de_champ_3', visible: false).visible?).to be_falsey
end # end
scenario 'delete attribut of type de champs is turn to true' do # 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_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') # expect(page.find_by_id('type_de_champ_3', visible: false).find('input[class="destroy"]', visible: false).value).to eq('true')
end # end
scenario 'attribut node is to move into div liste_delete_champ' do # 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_2', visible: false)
expect(page).to have_css('#liste_delete_champ #type_de_champ_3', visible: false) # expect(page).to have_css('#liste_delete_champ #type_de_champ_3', visible: false)
end # end
scenario 'order_place type_de_champ_1_procedure is 1' do # 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') # expect(page.find_by_id('type_de_champ_1').find("input[class='order_place']", visible: false).value).to eq('1')
end # end
scenario 'order_place type_de_champ_4_procedure is 2' do # 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') # expect(page.find_by_id('type_de_champ_4').find("input[class='order_place']", visible: false).value).to eq('2')
end # end
scenario 'order_place type_de_champ_5_procedure is 3' do # 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') # expect(page.find_by_id('type_de_champ_5').find("input[class='order_place']", visible: false).value).to eq('3')
end # end
scenario 'order_place type_de_champ_6_procedure is 4' do # 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') # expect(page.find_by_id('type_de_champ_6').find("input[class='order_place']", visible: false).value).to eq('4')
end # end
end # end
end # end
end # end

View file

@ -1,52 +1,52 @@
require 'spec_helper' require 'spec_helper'
feature 'delete a type de piece_justificative form', js: true do # feature 'delete a type de piece_justificative form', js: true do
let(:administrateur) { create(:administrateur) } # let(:administrateur) { create(:administrateur) }
before do # before do
login_as administrateur, scope: :administrateur # login_as administrateur, scope: :administrateur
end # end
context 'when user click on type de piece_justificative red X button' do # context 'when user click on type de piece_justificative red X button' do
let!(:procedure) { create(:procedure, :with_two_type_de_piece_justificative) } # let!(:procedure) { create(:procedure, :with_two_type_de_piece_justificative) }
before do # before do
visit admin_procedure_path id: procedure.id # visit admin_procedure_path id: procedure.id
end # end
context 'when user edit a type de piece_justificative already save in database' do # 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 } # let(:type_de_piece_justificative) { procedure.types_de_piece_justificative.first }
before do # before do
page.click_on 'delete_type_de_piece_justificative_1_procedure' # page.click_on 'delete_type_de_piece_justificative_1_procedure'
end # end
scenario 'form is mask for the user' do # scenario 'form is mask for the user' do
expect(page.find_by_id('type_de_piece_justificative_1', visible: false).visible?).to be_falsey # expect(page.find_by_id('type_de_piece_justificative_1', visible: false).visible?).to be_falsey
end # end
scenario 'delete attribut of type de piece_justificative is turn to true' do # 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') # expect(page.find_by_id('type_de_piece_justificative_1', visible: false).find('input[class="destroy"]', visible: false).value).to eq('true')
end # end
end # end
context 'when user edit a type de piece_justificative just add on the form page' do # context 'when user edit a type de piece_justificative just add on the form page' do
before do # before do
page.click_on 'add_type_de_piece_justificative_procedure' # page.click_on 'add_type_de_piece_justificative_procedure'
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_2_procedure'
page.click_on 'delete_type_de_piece_justificative_3_procedure' # page.click_on 'delete_type_de_piece_justificative_3_procedure'
end # end
scenario 'form is mask for the user' do # 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_2', visible: false).visible?).to be_falsey
expect(page.find_by_id('type_de_piece_justificative_3', visible: false).visible?).to be_falsey # expect(page.find_by_id('type_de_piece_justificative_3', visible: false).visible?).to be_falsey
end # end
scenario 'delete attribut of type de piece_justificative is turn to true' do # 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_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') # 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
end # end
end # end

View file

@ -1,79 +1,79 @@
require 'spec_helper' require 'spec_helper'
feature 'move down button type de champs', js: true do # feature 'move down button type de champs', js: true do
let(:administrateur) { create(:administrateur) } # let(:administrateur) { create(:administrateur) }
before do # before do
login_as administrateur, scope: :administrateur # login_as administrateur, scope: :administrateur
end # end
context 'when click on move down type de champs button' do # context 'when click on move down type de champs button' do
let!(:procedure) { create(:procedure, :with_type_de_champ) } # let!(:procedure) { create(:procedure, :with_type_de_champ) }
let!(:type_de_champ) { create(:type_de_champ, procedure: procedure, order_place: 2) } # let!(:type_de_champ) { create(:type_de_champ, procedure: procedure, order_place: 2) }
before do # before do
visit admin_procedure_path id: procedure.id # visit admin_procedure_path id: procedure.id
end # end
context 'when procedure have two type de champs' do # context 'when procedure have two type de champs' do
before do # before do
page.click_on 'order_type_de_champ_1_down_procedure' # page.click_on 'order_type_de_champ_1_down_procedure'
end # end
scenario 'it inverse the twice type de champs' do # 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_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'); # expect(page.find_by_id('type_de_champ_2').find('input[class="order_place"]', visible: false).value).to eq('1');
end # end
end # end
context 'when procedure have two type de champs in database and 3 type de champs add on the page' do # context 'when procedure have two type de champs in database and 3 type de champs add on the page' do
before 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 'add_type_de_champ_procedure'
end # end
context 'when to click on down_button type_de_champ_2' do # context 'when to click on down_button type_de_champ_2' do
before do # before do
page.click_on 'order_type_de_champ_2_down_procedure' # page.click_on 'order_type_de_champ_2_down_procedure'
end # end
scenario 'type_de_champ_2 and type_de_champ_3 is reversed' do # 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_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_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_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_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'); # expect(page.find_by_id('type_de_champ_5').find('input[class="order_place"]', visible: false).value).to eq('5');
end # end
context 'when to click on up_button type_de_champ_4' do # context 'when to click on up_button type_de_champ_4' do
before do # before do
page.click_on 'order_type_de_champ_4_down_procedure' # page.click_on 'order_type_de_champ_4_down_procedure'
end # end
scenario 'type_de_champ_4 and type_de_champ_5 is reversed' do # 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_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_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_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_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'); # expect(page.find_by_id('type_de_champ_4').find('input[class="order_place"]', visible: false).value).to eq('5');
end # end
context 'when to click on up_button type_de_champ_1' do # context 'when to click on up_button type_de_champ_1' do
before do # before do
page.click_on 'order_type_de_champ_1_down_procedure' # page.click_on 'order_type_de_champ_1_down_procedure'
end # end
scenario 'type_de_champ_1 and type_de_champ_3 is reversed' do # 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_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_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_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_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'); # 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 # end
end # end
end # end
end # end

View file

@ -1,72 +1,72 @@
require 'spec_helper' require 'spec_helper'
feature 'move up and down button type de champs', js: true do # feature 'move up and down button type de champs', js: true do
let(:administrateur) { create(:administrateur) } # let(:administrateur) { create(:administrateur) }
before do # before do
login_as administrateur, scope: :administrateur # login_as administrateur, scope: :administrateur
end # end
context 'when click on move up and down type de champs button' do # context 'when click on move up and down type de champs button' do
let!(:procedure) { create(:procedure, :with_type_de_champ) } # let!(:procedure) { create(:procedure, :with_type_de_champ) }
let!(:type_de_champ) { create(:type_de_champ, procedure: procedure, order_place: 2) } # let!(:type_de_champ) { create(:type_de_champ, procedure: procedure, order_place: 2) }
before do # before do
visit admin_procedure_path id: procedure.id # visit admin_procedure_path id: procedure.id
end # end
context 'when procedure have two type de champs in database and 3 type de champs add on the page' do # context 'when procedure have two type de champs in database and 3 type de champs add on the page' do
before 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 'add_type_de_champ_procedure'
end # end
# # #
context 'when to click on up_button type_de_champ_2 and down_button type_de_champ_1' do # context 'when to click on up_button type_de_champ_2 and down_button type_de_champ_1' do
before do # before do
page.click_on 'order_type_de_champ_2_up_procedure' # page.click_on 'order_type_de_champ_2_up_procedure'
page.click_on 'order_type_de_champ_1_down_procedure' # page.click_on 'order_type_de_champ_1_down_procedure'
end # end
scenario 'type_de_champ_1 is at order place 3 and type_de_champ_2 is at order place 1 ' do # 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_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_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_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_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'); # expect(page.find_by_id('type_de_champ_5').find('input[class="order_place"]', visible: false).value).to eq('5');
end # end
context 'when to click on down_button type_de_champ_4 and up_button type_de_champ_5' do # context 'when to click on down_button type_de_champ_4 and up_button type_de_champ_5' do
before do # before do
page.click_on 'order_type_de_champ_4_down_procedure' # page.click_on 'order_type_de_champ_4_down_procedure'
page.click_on 'order_type_de_champ_5_up_procedure' # page.click_on 'order_type_de_champ_5_up_procedure'
end # end
scenario 'type_de_champ_2 and type_de_champ_3 is reversed' do # 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_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_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_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_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'); # expect(page.find_by_id('type_de_champ_4').find('input[class="order_place"]', visible: false).value).to eq('5');
end # 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 # 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 # before do
page.click_on 'order_type_de_champ_3_up_procedure' # 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_1_down_procedure'
page.click_on 'order_type_de_champ_5_up_procedure' # page.click_on 'order_type_de_champ_5_up_procedure'
end # end
scenario 'type_de_champ_2 and type_de_champ_4 is reversed' do # 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_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_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_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_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'); # 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 # end
end # end
end # end
end # end

View file

@ -1,80 +1,80 @@
require 'spec_helper' 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 # before do
login_as administrateur, scope: :administrateur # login_as administrateur, scope: :administrateur
end # end
context 'when click on move up type de champs button' do # context 'when click on move up type de champs button' do
let!(:procedure) { create(:procedure, :with_type_de_champ) } # let!(:procedure) { create(:procedure, :with_type_de_champ) }
let!(:type_de_champ) { create(:type_de_champ, procedure: procedure, order_place: 2) } # let!(:type_de_champ) { create(:type_de_champ, procedure: procedure, order_place: 2) }
before do # before do
visit admin_procedure_path id: procedure.id # visit admin_procedure_path id: procedure.id
end # end
context 'when procedure have two type de champs' do # context 'when procedure have two type de champs' do
before do # before do
page.click_on 'order_type_de_champ_2_up_procedure' # page.click_on 'order_type_de_champ_2_up_procedure'
end # end
scenario 'it inverse the twice type de champs' do # 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_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'); # expect(page.find_by_id('type_de_champ_2').find('input[class="order_place"]', visible: false).value).to eq('1');
end # end
end # end
context 'when procedure have two type de champs in database and 3 type de champs add on the page' do # context 'when procedure have two type de champs in database and 3 type de champs add on the page' do
before 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 'add_type_de_champ_procedure'
end # end
context 'when to click on up_button type_de_champ_2' do # context 'when to click on up_button type_de_champ_2' do
before do # before do
page.click_on 'order_type_de_champ_2_up_procedure' # page.click_on 'order_type_de_champ_2_up_procedure'
end # end
scenario 'type_de_champ_1 and type_de_champ_2 is reversed' do # 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_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_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_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_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'); # expect(page.find_by_id('type_de_champ_5').find('input[class="order_place"]', visible: false).value).to eq('5');
end # end
context 'when to click on up_button type_de_champ_4' do # context 'when to click on up_button type_de_champ_4' do
before do # before do
page.click_on 'order_type_de_champ_4_up_procedure' # page.click_on 'order_type_de_champ_4_up_procedure'
end # end
scenario 'type_de_champ_3 and type_de_champ_4 is reversed' do # 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_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_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_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_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'); # expect(page.find_by_id('type_de_champ_5').find('input[class="order_place"]', visible: false).value).to eq('5');
end # end
context 'when to click on up_button type_de_champ_5' do # context 'when to click on up_button type_de_champ_5' do
before do # before do
page.click_on 'order_type_de_champ_5_up_procedure' # page.click_on 'order_type_de_champ_5_up_procedure'
end # end
scenario 'type_de_champ_3 and type_de_champ_5 is reversed' do # 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_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_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_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_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'); # 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 # end
end # end
end # end
end # end

View file

@ -31,8 +31,8 @@ describe TypeDeChamp do
end end
context 'order_place' do context 'order_place' do
it { is_expected.not_to allow_value(nil).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.not_to allow_value('').for(:order_place) }
it { is_expected.to allow_value(1).for(:order_place) } it { is_expected.to allow_value(1).for(:order_place) }
end end