Rename TypeDeChamps to TypeDeChamp

This commit is contained in:
Xavier J 2015-11-05 11:21:44 +01:00
parent 519af34c82
commit f3d8645426
34 changed files with 644 additions and 634 deletions

View file

@ -1,14 +1,14 @@
var ready = function () {
$("#add_type_de_champs_procedure").on('click', function (e) {
add_new_type_de('champs');
$("#add_type_de_champ_procedure").on('click', function (e) {
add_new_type_de('champ');
});
$("#add_type_de_piece_justificative_procedure").on('click', function (e) {
add_new_type_de('piece_justificative');
});
add_delete_listener_on_click_for_type_de("champs", "#liste_champs .btn-danger");
add_delete_listener_on_click_for_type_de("champs", "#new_type_de_champs .btn-danger");
add_delete_listener_on_click_for_type_de("champ", "#liste_champ .btn-danger");
add_delete_listener_on_click_for_type_de("champ", "#new_type_de_champ .btn-danger");
add_delete_listener_on_click_for_type_de("piece_justificative", "#liste_piece_justificative .btn-danger");
add_delete_listener_on_click_for_type_de("piece_justificative", "#new_type_de_piece_justificative .btn-danger");
@ -35,16 +35,16 @@ function add_new_type_de(type_libelle) {
PJ = 1,
ERROR = -1;
if (is_champs_or_pj() == ERROR) return false;
if (is_champ_or_pj() == ERROR) return false;
function is_champs_or_pj() {
if (type_libelle == 'champs') return CHAMPS;
function is_champ_or_pj() {
if (type_libelle == 'champ') return CHAMPS;
else if (type_libelle == 'piece_justificative') return PJ;
else return ERROR;
}
function which_index() {
return (is_champs_or_pj() == CHAMPS ? types_de_champs_index : types_de_piece_justificative_index)
return (is_champ_or_pj() == CHAMPS ? types_de_champ_index : types_de_piece_justificative_index)
}
$("#liste_" + type_libelle).append($("#type_de_" + type_libelle + "_" + which_index()));
@ -52,11 +52,11 @@ function add_new_type_de(type_libelle) {
$("#delete_type_de_" + type_libelle + "_" + which_index() + "_button").show();
if (is_champs_or_pj() == CHAMPS) {
types_de_champs_index++;
add_new_type_de_champs_params(which_index());
if (is_champ_or_pj() == CHAMPS) {
types_de_champ_index++;
add_new_type_de_champ_params(which_index());
}
else if (is_champs_or_pj() == PJ) {
else if (is_champ_or_pj() == PJ) {
types_de_piece_justificative_index++;
add_new_type_de_piece_justificative_params(which_index());
}
@ -72,9 +72,9 @@ function add_new_type_de(type_libelle) {
$("#new_type_de_" + type_libelle + " #delete_type_de_" + type_libelle + "_" + (which_index() - 1) + "_button").attr('id', "delete_type_de_" + type_libelle + "_" + which_index() + "_button");
$("#new_type_de_" + type_libelle + " #delete_type_de_" + type_libelle + "_" + (which_index() - 1) + "_procedure").attr('id', "delete_type_de_" + type_libelle + "_" + which_index() + "_procedure");
if (is_champs_or_pj() == CHAMPS)
add_delete_listener_on_click_for_type_de("champs", "#delete_type_de_champs_" + which_index() + "_procedure");
else if (is_champs_or_pj() == PJ)
if (is_champ_or_pj() == CHAMPS)
add_delete_listener_on_click_for_type_de("champ", "#delete_type_de_champ_" + which_index() + "_procedure");
else if (is_champ_or_pj() == PJ)
add_delete_listener_on_click_for_type_de("piece_justificative", "#delete_type_de_piece_justificative_" + which_index() + "_procedure");
$("#new_type_de_" + type_libelle + " #add_type_de_" + type_libelle + "_button").remove();
@ -86,21 +86,21 @@ function add_new_type_de(type_libelle) {
config_up_and_down_button();
}
function add_new_type_de_champs_params() {
$("#new_type_de_champs #libelle").attr('name', 'type_de_champs[' + types_de_champs_index + '][libelle]');
$("#new_type_de_champs #libelle").val('');
function add_new_type_de_champ_params() {
$("#new_type_de_champ #libelle").attr('name', 'type_de_champ[' + types_de_champ_index + '][libelle]');
$("#new_type_de_champ #libelle").val('');
$("#new_type_de_champs #description").attr('name', 'type_de_champs[' + types_de_champs_index + '][description]');
$("#new_type_de_champs #description").val('');
$("#new_type_de_champ #description").attr('name', 'type_de_champ[' + types_de_champ_index + '][description]');
$("#new_type_de_champ #description").val('');
$("#new_type_de_champs #type_champs").attr('name', 'type_de_champs[' + types_de_champs_index + '][type]');
$("#new_type_de_champ #type_champs").attr('name', 'type_de_champ[' + types_de_champ_index + '][type]');
$("#new_type_de_champs .order_place").attr('name', 'type_de_champs[' + types_de_champs_index + '][order_place]');
$("#new_type_de_champs .order_place").val(parseInt($("#liste_champs .order_place").last().val()) + 1);
$("#new_type_de_champ .order_place").attr('name', 'type_de_champ[' + types_de_champ_index + '][order_place]');
$("#new_type_de_champ .order_place").val(parseInt($("#liste_champ .order_place").last().val()) + 1);
$("#new_type_de_champs .order_type_de_champs_button").attr('id', 'order_type_de_champs_' + types_de_champs_index + '_button')
$("#new_type_de_champs .order_type_de_champs_button .button_up").attr('id', 'order_type_de_champs_' + types_de_champs_index + '_up_procedure')
$("#new_type_de_champs .order_type_de_champs_button .button_down").attr('id', 'order_type_de_champs_' + types_de_champs_index + '_down_procedure')
$("#new_type_de_champ .order_type_de_champ_button").attr('id', 'order_type_de_champ_' + types_de_champ_index + '_button')
$("#new_type_de_champ .order_type_de_champ_button .button_up").attr('id', 'order_type_de_champ_' + types_de_champ_index + '_up_procedure')
$("#new_type_de_champ .order_type_de_champ_button .button_down").attr('id', 'order_type_de_champ_' + types_de_champ_index + '_down_procedure')
}
function add_new_type_de_piece_justificative_params() {
@ -117,57 +117,57 @@ function delete_type_de(type_libelle, index) {
$("#liste_delete_" + type_libelle).append(delete_node);
$("#type_de_" + type_libelle + "_" + index + " #delete").val('true');
if (type_libelle == 'champs') {
if (type_libelle == 'champ') {
var next_order_place = parseInt($("#type_de_" + type_libelle + "_" + index + " .order_place").val());
var type_de_champs_to_change_order_place = $("#liste_champs .order_place");
var type_de_champ_to_change_order_place = $("#liste_champ .order_place");
type_de_champs_to_change_order_place.each(function () {
type_de_champ_to_change_order_place.each(function () {
if ($(this).val() > next_order_place) {
$(this).val(next_order_place++);
}
});
$("#new_type_de_champs .order_place").val(next_order_place);
$("#new_type_de_champ .order_place").val(next_order_place);
config_up_and_down_button();
}
}
function config_up_and_down_button() {
if ($("#liste_champs .order_place").size() > 0) {
var first_index = $("#liste_champs .order_place").first()
if ($("#liste_champ .order_place").size() > 0) {
var first_index = $("#liste_champ .order_place").first()
.attr('name')
.replace('type_de_champs[', '')
.replace('type_de_champ[', '')
.replace('][order_place]', '');
var last_index = $("#liste_champs .order_place").last()
var last_index = $("#liste_champ .order_place").last()
.attr('name')
.replace('type_de_champs[', '')
.replace('type_de_champ[', '')
.replace('][order_place]', '');
$(".button_up").show();
$(".button_down").show();
$("#liste_champs .order_type_de_champs_button").show();
$("#liste_champ .order_type_de_champ_button").show();
$("#order_type_de_champs_" + first_index + "_up_procedure").hide();
$("#order_type_de_champs_" + last_index + "_down_procedure").hide();
$("#order_type_de_champ_" + first_index + "_up_procedure").hide();
$("#order_type_de_champ_" + last_index + "_down_procedure").hide();
}
}
function add_action_listener_on_click_for_button_up(node_id) {
$(node_id).on('click', function (e) {
var index = (e.target.id).replace('order_type_de_champs_', '').replace('_up_procedure', '');
var order_place = parseInt($("#type_de_champs_" + index + " .order_place").val());
var index = (e.target.id).replace('order_type_de_champ_', '').replace('_up_procedure', '');
var order_place = parseInt($("#type_de_champ_" + index + " .order_place").val());
var order_place_before = order_place - 1;
var node_before = $("input[class='order_place'][value='" + order_place_before + "']").parent();
var index_before = (node_before.attr('id')).replace('type_de_champs_', '');
var index_before = (node_before.attr('id')).replace('type_de_champ_', '');
$("#type_de_champs_" + index).insertBefore("#type_de_champs_" + index_before);
$("#type_de_champs_" + index_before);
$("#type_de_champ_" + index).insertBefore("#type_de_champ_" + index_before);
$("#type_de_champ_" + index_before);
$("#type_de_champs_" + index_before + " .order_place").val(order_place);
$("#type_de_champs_" + index + " .order_place").val(order_place_before);
$("#type_de_champ_" + index_before + " .order_place").val(order_place);
$("#type_de_champ_" + index + " .order_place").val(order_place_before);
config_up_and_down_button();
});
@ -175,19 +175,19 @@ function add_action_listener_on_click_for_button_up(node_id) {
function add_action_listener_on_click_for_button_down(node_id) {
$(node_id).on('click', function (e) {
var index = (e.target.id).replace('order_type_de_champs_', '').replace('_down_procedure', '');
var order_place = parseInt($("#type_de_champs_" + index + " .order_place").val());
var index = (e.target.id).replace('order_type_de_champ_', '').replace('_down_procedure', '');
var order_place = parseInt($("#type_de_champ_" + index + " .order_place").val());
var order_place_after = order_place + 1;
var node_after = $("input[class='order_place'][value='" + order_place_after + "']").parent();
var index_after = (node_after.attr('id')).replace('type_de_champs_', '');
var index_after = (node_after.attr('id')).replace('type_de_champ_', '');
$("#type_de_champs_" + index).insertAfter("#type_de_champs_" + index_after);
$("#type_de_champs_" + index_after);
$("#type_de_champ_" + index).insertAfter("#type_de_champ_" + index_after);
$("#type_de_champ_" + index_after);
$("#type_de_champs_" + index_after + " .order_place").val(order_place);
$("#type_de_champs_" + index + " .order_place").val(order_place_after);
$("#type_de_champ_" + index_after + " .order_place").val(order_place);
$("#type_de_champ_" + index + " .order_place").val(order_place_after);
config_up_and_down_button();
});

View file

@ -24,7 +24,7 @@ class Admin::ProceduresController < ApplicationController
return render 'new'
end
process_types_de_champs_params
process_types_de_champ_params
process_types_de_piece_justificative_params
flash.notice = 'Procédure enregistrée'
@ -39,7 +39,7 @@ class Admin::ProceduresController < ApplicationController
return render 'show'
end
process_types_de_champs_params
process_types_de_champ_params
process_types_de_piece_justificative_params
flash.notice = 'Préocédure modifiée'
@ -48,22 +48,22 @@ class Admin::ProceduresController < ApplicationController
private
def process_types_de_champs_params
unless params[:type_de_champs].nil? || params[:type_de_champs].size == 0
params[:type_de_champs].each do |index, type_de_champs|
def process_types_de_champ_params
unless params[:type_de_champ].nil? || params[:type_de_champ].size == 0
params[:type_de_champ].each do |index, type_de_champ|
if type_de_champs[:delete] == 'true'
unless type_de_champs[:id_type_de_champs].nil? || type_de_champs[:id_type_de_champs] == ''
TypeDeChamps.destroy(type_de_champs[:id_type_de_champs])
if type_de_champ[:delete] == 'true'
unless type_de_champ[:id_type_de_champ].nil? || type_de_champ[:id_type_de_champ] == ''
TypeDeChamp.destroy(type_de_champ[:id_type_de_champ])
end
else
if type_de_champs[:id_type_de_champs].nil? || type_de_champs[:id_type_de_champs] == ''
bdd_object = TypeDeChamps.new
if type_de_champ[:id_type_de_champ].nil? || type_de_champ[:id_type_de_champ] == ''
bdd_object = TypeDeChamp.new
else
bdd_object = TypeDeChamps.find(type_de_champs[:id_type_de_champs])
bdd_object = TypeDeChamp.find(type_de_champ[:id_type_de_champ])
end
save_type_de_champs bdd_object, type_de_champs
save_type_de_champ bdd_object, type_de_champ
end
end
end
@ -90,7 +90,7 @@ class Admin::ProceduresController < ApplicationController
end
end
def save_type_de_champs database_object, source
def save_type_de_champ database_object, source
database_object.libelle = source[:libelle]
database_object.type_champs = source[:type]
database_object.description = source[:description]

View file

@ -1,5 +1,5 @@
class Champ < ActiveRecord::Base
belongs_to :dossier
belongs_to :type_de_champs
delegate :libelle, :type_champs, :order_place, to: :type_de_champs
belongs_to :type_de_champ
delegate :libelle, :type_champs, :order_place, to: :type_de_champ
end

View file

@ -19,7 +19,7 @@ class Dossier < ActiveRecord::Base
delegate :siren, to: :entreprise
delegate :siret, to: :etablissement
delegate :types_de_piece_justificative, to: :procedure
delegate :types_de_champs, to: :procedure
delegate :types_de_champ, to: :procedure
before_create :build_default_cerfa
@ -42,13 +42,13 @@ class Dossier < ActiveRecord::Base
end
def build_default_champs
procedure.types_de_champs.each do |type_de_champs|
Champ.create(type_de_champs_id: type_de_champs.id, dossier_id: id)
procedure.types_de_champ.each do |type_de_champ|
Champ.create(type_de_champ_id: type_de_champ.id, dossier_id: id)
end
end
def ordered_champs
champs.joins(', types_de_champs').where('champs.type_de_champs_id = types_de_champs.id').order('order_place')
champs.joins(', types_de_champ').where('champs.type_de_champ_id = types_de_champ.id').order('order_place')
end
def ordered_commentaires

View file

@ -1,6 +1,6 @@
class Procedure < ActiveRecord::Base
has_many :types_de_piece_justificative
has_many :types_de_champs
has_many :types_de_champ
has_many :dossiers
validates :libelle, presence: true, allow_blank: false, allow_nil: false

View file

@ -1,4 +1,4 @@
class TypeDeChamps < ActiveRecord::Base
class TypeDeChamp < ActiveRecord::Base
enum type_champs: {text: 'text',
textarea: 'textarea',
datetime: 'datetime',

View file

@ -17,7 +17,7 @@
%h3.text-info
Liste des champs à remplir pour un dossier
=render partial: 'admin/procedures/types_de_champs/liste', locals: {f: f}
=render partial: 'admin/procedures/types_de_champ/liste', locals: {f: f}
%br
%br

View file

@ -0,0 +1,40 @@
.form-inline{id:"type_de_champ_#{index}", style: 'padding-bottom:8px'}
.form-group{ style: 'padding-right: 2%' }
%h4 Libellé
%input.form-control#libelle{ type: 'text', placeholder: 'Libelle', name:"type_de_champ[#{index}][libelle]", size: 40, value: ("#{ type_de_champ.libelle }" unless type_de_champ.nil? ) }
.form-group{ style: 'padding-right: 2%' }
%h4 Type
%select.form-control#type_champs{ name: "type_de_champ[#{index}][type]" }
%option{ value: 'text', selected: (type_de_champ.type_champs == 'text' unless type_de_champ.nil?)}
Simple texte
%option{ value: 'textarea', selected: (type_de_champ.type_champs == 'textarea' unless type_de_champ.nil?)}
Texte multi-lignes
%option{ value: 'datetime', selected: (type_de_champ.type_champs == 'datetime' unless type_de_champ.nil?)}
Date
%option{ value: 'number', selected: (type_de_champ.type_champs == 'number' unless type_de_champ.nil?)}
Valeur numérique
.form-group{ style: 'padding-right: 2%' }
%h4
Description
%textarea.form-control#description{cols: 60, placeholder: 'Description', name: "type_de_champ[#{index}][description]"}
=("#{ type_de_champ.description }" unless type_de_champ.nil? )
%input.order_place{type: 'hidden', name: "type_de_champ[#{index}][order_place]", value: (("#{ type_de_champ.order_place }" unless type_de_champ.nil?) || index+1)}
%input#id_type_de_champ{type: 'hidden', name: "type_de_champ[#{index}][id_type_de_champ]", value: (("#{ type_de_champ.id}" unless type_de_champ.nil?))}
%input#delete{type: 'hidden', name: "type_de_champ[#{index}][delete]", value: 'false'}
-if type_de_champ.nil?
.form-group#add_type_de_champ_button
%br &nbsp;
%button.form-control.btn.btn-success#add_type_de_champ_procedure{type: 'button'} Ajouter
.form-group.order_type_de_champ_button{id: "order_type_de_champ_#{index}_button", style: ("display:none" if type_de_champ.nil?)}
%br &nbsp;
%button.form-control.btn.btn-default.button_up.fa.fa-chevron-up{type: 'button', id: "order_type_de_champ_#{index}_up_procedure"}
%button.form-control.btn.btn-default.button_down.fa.fa-chevron-down{type: 'button', id: "order_type_de_champ_#{index}_down_procedure"}
.form-group{id: "delete_type_de_champ_#{index}_button", style: ("display:none" if type_de_champ.nil?)}
%br &nbsp;
%button.form-control.btn.btn-danger.fa.fa-trash-o{type: 'button', id: "delete_type_de_champ_#{index}_procedure"}

View file

@ -0,0 +1,12 @@
#liste_champ
-if @procedure.types_de_champ.size > 0
- @procedure.types_de_champ.order(:order_place).each_with_index do |type_de_champ, index|
=render partial: 'admin/procedures/types_de_champ/form', locals:{ type_de_champ: type_de_champ, index: index }
#liste_delete_champ
#new_type_de_champ
=render partial: 'admin/procedures/types_de_champ/form', locals:{ type_de_champ: nil, index: @procedure.types_de_champ.size }
%script{ type:'text/javascript' }
="var types_de_champ_index = #{@procedure.types_de_champ.size}"

View file

@ -1,40 +0,0 @@
.form-inline{id:"type_de_champs_#{index}", style: 'padding-bottom:8px'}
.form-group{ style: 'padding-right: 2%' }
%h4 Libellé
%input.form-control#libelle{ type: 'text', placeholder: 'Libelle', name:"type_de_champs[#{index}][libelle]", size: 40, value: ("#{ type_de_champs.libelle }" unless type_de_champs.nil? ) }
.form-group{ style: 'padding-right: 2%' }
%h4 Type
%select.form-control#type_champs{ name: "type_de_champs[#{index}][type]" }
%option{ value: 'text', selected: (type_de_champs.type_champs == 'text' unless type_de_champs.nil?)}
Simple texte
%option{ value: 'textarea', selected: (type_de_champs.type_champs == 'textarea' unless type_de_champs.nil?)}
Texte multi-lignes
%option{ value: 'datetime', selected: (type_de_champs.type_champs == 'datetime' unless type_de_champs.nil?)}
Date
%option{ value: 'number', selected: (type_de_champs.type_champs == 'number' unless type_de_champs.nil?)}
Valeur numérique
.form-group{ style: 'padding-right: 2%' }
%h4
Description
%textarea.form-control#description{cols: 60, placeholder: 'Description', name: "type_de_champs[#{index}][description]"}
=("#{ type_de_champs.description }" unless type_de_champs.nil? )
%input.order_place{type: 'hidden', name: "type_de_champs[#{index}][order_place]", value: (("#{ type_de_champs.order_place }" unless type_de_champs.nil?) || index+1)}
%input#id_type_de_champs{type: 'hidden', name: "type_de_champs[#{index}][id_type_de_champs]", value: (("#{ type_de_champs.id}" unless type_de_champs.nil?))}
%input#delete{type: 'hidden', name: "type_de_champs[#{index}][delete]", value: 'false'}
-if type_de_champs.nil?
.form-group#add_type_de_champs_button
%br &nbsp;
%button.form-control.btn.btn-success#add_type_de_champs_procedure{type: 'button'} Ajouter
.form-group.order_type_de_champs_button{id: "order_type_de_champs_#{index}_button", style: ("display:none" if type_de_champs.nil?)}
%br &nbsp;
%button.form-control.btn.btn-default.button_up.fa.fa-chevron-up{type: 'button', id: "order_type_de_champs_#{index}_up_procedure"}
%button.form-control.btn.btn-default.button_down.fa.fa-chevron-down{type: 'button', id: "order_type_de_champs_#{index}_down_procedure"}
.form-group{id: "delete_type_de_champs_#{index}_button", style: ("display:none" if type_de_champs.nil?)}
%br &nbsp;
%button.form-control.btn.btn-danger.fa.fa-trash-o{type: 'button', id: "delete_type_de_champs_#{index}_procedure"}

View file

@ -1,12 +0,0 @@
#liste_champs
-if @procedure.types_de_champs.size > 0
- @procedure.types_de_champs.order(:order_place).each_with_index do |type_de_champs, index|
=render partial: 'admin/procedures/types_de_champs/form', locals:{ type_de_champs: type_de_champs, index: index }
#liste_delete_champs
#new_type_de_champs
=render partial: 'admin/procedures/types_de_champs/form', locals:{ type_de_champs: nil, index: @procedure.types_de_champs.size }
%script{ type:'text/javascript' }
="var types_de_champs_index = #{@procedure.types_de_champs.size}"

View file

@ -11,7 +11,7 @@ ActiveSupport::Inflector.inflections(:en) do |inflect|
inflect.acronym 'API'
inflect.irregular 'piece_justificative', 'pieces_justificatives'
inflect.irregular 'type_de_piece_justificative', 'types_de_piece_justificative'
inflect.irregular 'type_de_champs', 'types_de_champs'
inflect.irregular 'type_de_champ', 'types_de_champ'
end
# These inflection rules are supported but not enabled by default:

View file

@ -0,0 +1,5 @@
class RenameTypeDeChampsToTypeDeChamp < ActiveRecord::Migration
def change
rename_table :types_de_champs, :types_de_champ
end
end

View file

@ -0,0 +1,5 @@
class RenameTypeDeChampsIdToTypeDeChampIdOnChamp < ActiveRecord::Migration
def change
rename_column :champs, :type_de_champs_id, :type_de_champ_id
end
end

View file

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20151103091603) do
ActiveRecord::Schema.define(version: 20151105095431) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -43,7 +43,7 @@ ActiveRecord::Schema.define(version: 20151103091603) do
create_table "champs", force: :cascade do |t|
t.string "value"
t.integer "type_de_champs_id"
t.integer "type_de_champ_id"
t.integer "dossier_id"
end
@ -142,7 +142,7 @@ ActiveRecord::Schema.define(version: 20151103091603) do
t.boolean "use_api_carto", default: false
end
create_table "types_de_champs", force: :cascade do |t|
create_table "types_de_champ", force: :cascade do |t|
t.string "libelle"
t.string "type_champs"
t.integer "order_place"

View file

@ -23,7 +23,7 @@ describe Admin::ProceduresController, type: :controller do
}
}
let(:types_de_champs_params) {
let(:types_de_champ_params) {
{'0' =>
{libelle: 'Champs de test',
type: 'number',
@ -37,7 +37,7 @@ describe Admin::ProceduresController, type: :controller do
}
}
let(:types_de_champs_params_errors) {
let(:types_de_champ_params_errors) {
{'0' =>
{libelle: '',
type: 'number',
@ -76,7 +76,7 @@ describe Admin::ProceduresController, type: :controller do
end
describe 'GET #show' do
let(:procedure) { create(:procedure, :with_type_de_champs, :with_two_type_de_piece_justificative) }
let(:procedure) { create(:procedure, :with_type_de_champ, :with_two_type_de_piece_justificative) }
let(:procedure_id) { procedure.id }
subject { get :show, id: procedure_id }
@ -152,40 +152,40 @@ describe Admin::ProceduresController, type: :controller do
end
end
describe 'type_de_champs processing' do
describe 'type_de_champ processing' do
before do
post :create, procedure: procedure_params, type_de_champs: types_de_champs_params
post :create, procedure: procedure_params, type_de_champ: types_de_champ_params
end
subject { Procedure.last }
context 'when no type de champs is filled' do
let(:types_de_champs_params) { {} }
it { expect(subject.types_de_champs.size).to eq(0) }
let(:types_de_champ_params) { {} }
it { expect(subject.types_de_champ.size).to eq(0) }
end
context 'when two types de champs are filled' do
it { expect(subject.types_de_champs.size).to eq(2) }
it { expect(subject.types_de_champ.size).to eq(2) }
describe ' check types de champs attributs present into database' do
subject { TypeDeChamps.all }
subject { TypeDeChamp.all }
it { expect(subject[0].libelle).to eq(types_de_champs_params['0'][:libelle]) }
it { expect(subject[0].type_champs).to eq(types_de_champs_params['0'][:type]) }
it { expect(subject[0].description).to eq(types_de_champs_params['0'][:description]) }
it { expect(subject[0].order_place).to eq(types_de_champs_params['0'][:order_place]) }
it { expect(subject[0].libelle).to eq(types_de_champ_params['0'][:libelle]) }
it { expect(subject[0].type_champs).to eq(types_de_champ_params['0'][:type]) }
it { expect(subject[0].description).to eq(types_de_champ_params['0'][:description]) }
it { expect(subject[0].order_place).to eq(types_de_champ_params['0'][:order_place]) }
it { expect(subject[1].libelle).to eq(types_de_champs_params['1'][:libelle]) }
it { expect(subject[1].type_champs).to eq(types_de_champs_params['1'][:type]) }
it { expect(subject[1].description).to eq(types_de_champs_params['1'][:description]) }
it { expect(subject[1].order_place).to eq(types_de_champs_params['1'][:order_place]) }
it { expect(subject[1].libelle).to eq(types_de_champ_params['1'][:libelle]) }
it { expect(subject[1].type_champs).to eq(types_de_champ_params['1'][:type]) }
it { expect(subject[1].description).to eq(types_de_champ_params['1'][:description]) }
it { expect(subject[1].order_place).to eq(types_de_champ_params['1'][:order_place]) }
end
end
context 'when one of two types de champs have not a libelle' do
let(:types_de_champs_params) { types_de_champs_params_errors }
let(:types_de_champ_params) { types_de_champ_params_errors }
it { expect(subject.types_de_champs.size).to eq(1) }
it { expect(subject.types_de_champ.size).to eq(1) }
end
end
@ -224,7 +224,7 @@ describe Admin::ProceduresController, type: :controller do
end
describe 'PUT #update' do
let!(:procedure) { create(:procedure, :with_type_de_champs, :with_two_type_de_piece_justificative) }
let!(:procedure) { create(:procedure, :with_type_de_champ, :with_two_type_de_piece_justificative) }
context 'when administrateur is not connected' do
before do
@ -238,7 +238,7 @@ describe Admin::ProceduresController, type: :controller do
context 'when administrateur is connected' do
before do
put :update, id: procedure.id, procedure: procedure_params, type_de_champs: types_de_champs_params, type_de_piece_justificative: types_de_piece_justificative_params
put :update, id: procedure.id, procedure: procedure_params, type_de_champ: types_de_champ_params, type_de_piece_justificative: types_de_piece_justificative_params
procedure.reload
end
@ -274,97 +274,97 @@ describe Admin::ProceduresController, type: :controller do
end
end
describe 'type_de_champs processing' do
describe 'type_de_champ processing' do
subject { procedure }
context 'when no type de champs is filled' do
let(:types_de_champs_params) { {} }
it { expect(subject.types_de_champs.size).to eq(1) }
let(:types_de_champ_params) { {} }
it { expect(subject.types_de_champ.size).to eq(1) }
end
context 'when two types de champs are filled' do
it { expect(subject.types_de_champs.size).to eq(3) }
it { expect(subject.types_de_champ.size).to eq(3) }
describe ' check types de champs attributs added into database' do
subject { procedure.types_de_champs }
subject { procedure.types_de_champ }
it { expect(subject[1].libelle).to eq(types_de_champs_params['0'][:libelle]) }
it { expect(subject[1].type_champs).to eq(types_de_champs_params['0'][:type]) }
it { expect(subject[1].description).to eq(types_de_champs_params['0'][:description]) }
it { expect(subject[1].order_place).to eq(types_de_champs_params['0'][:order_place]) }
it { expect(subject[1].libelle).to eq(types_de_champ_params['0'][:libelle]) }
it { expect(subject[1].type_champs).to eq(types_de_champ_params['0'][:type]) }
it { expect(subject[1].description).to eq(types_de_champ_params['0'][:description]) }
it { expect(subject[1].order_place).to eq(types_de_champ_params['0'][:order_place]) }
it { expect(subject[2].libelle).to eq(types_de_champs_params['1'][:libelle]) }
it { expect(subject[2].type_champs).to eq(types_de_champs_params['1'][:type]) }
it { expect(subject[2].description).to eq(types_de_champs_params['1'][:description]) }
it { expect(subject[2].order_place).to eq(types_de_champs_params['1'][:order_place]) }
it { expect(subject[2].libelle).to eq(types_de_champ_params['1'][:libelle]) }
it { expect(subject[2].type_champs).to eq(types_de_champ_params['1'][:type]) }
it { expect(subject[2].description).to eq(types_de_champ_params['1'][:description]) }
it { expect(subject[2].order_place).to eq(types_de_champ_params['1'][:order_place]) }
end
end
context 'when one of two types de champs have not a libelle' do
let(:procedure) { create(:procedure) }
let(:types_de_champs_params) { types_de_champs_params_errors }
let(:types_de_champ_params) { types_de_champ_params_errors }
it { expect(subject.types_de_champs.size).to eq(1) }
it { expect(subject.types_de_champ.size).to eq(1) }
end
context 'when user edit the filed' do
let(:types_de_champs_params) {
let(:types_de_champ_params) {
{'0' =>
{libelle: 'Champs de test editée',
type: 'number',
description: 'Description de test editée',
order_place: 1,
id_type_de_champs: procedure.types_de_champs.first.id}
id_type_de_champ: procedure.types_de_champ.first.id}
}
}
it { expect(subject.types_de_champs.size).to eq(1) }
it { expect(subject.types_de_champ.size).to eq(1) }
describe ' check types de champs attributs updated into database' do
subject { procedure.types_de_champs.first }
subject { procedure.types_de_champ.first }
it { expect(subject.libelle).to eq(types_de_champs_params['0'][:libelle]) }
it { expect(subject.type_champs).to eq(types_de_champs_params['0'][:type]) }
it { expect(subject.description).to eq(types_de_champs_params['0'][:description]) }
it { expect(subject.order_place).to eq(types_de_champs_params['0'][:order_place]) }
it { expect(subject.libelle).to eq(types_de_champ_params['0'][:libelle]) }
it { expect(subject.type_champs).to eq(types_de_champ_params['0'][:type]) }
it { expect(subject.description).to eq(types_de_champ_params['0'][:description]) }
it { expect(subject.order_place).to eq(types_de_champ_params['0'][:order_place]) }
end
end
context 'when delete a type de champs' do
let(:types_de_champs_params) {
let(:types_de_champ_params) {
{'0' =>
{libelle: 'Champs de test editée',
type: 'number',
description: 'Description de test editée',
order_place: 1,
delete: 'true',
id_type_de_champs: procedure.types_de_champs.first.id}
id_type_de_champ: procedure.types_de_champ.first.id}
}
}
it { expect(subject.types_de_champs.size).to eq(0) }
it { expect(subject.types_de_champ.size).to eq(0) }
end
context 'when delete a type de champs present in database and a type champ not present in database' do
let(:types_de_champs_params) {
let(:types_de_champ_params) {
{'0' =>
{libelle: 'Champs de test editée',
type: 'number',
description: 'Description de test editée',
order_place: 1,
delete: 'true',
id_type_de_champs: procedure.types_de_champs.first.id},
id_type_de_champ: procedure.types_de_champ.first.id},
'1' =>
{libelle: 'Champs de test editée',
type: 'number',
description: 'Description de test editée',
order_place: 1,
delete: 'true',
id_type_de_champs: ''}
id_type_de_champ: ''}
}
}
it { expect(subject.types_de_champs.size).to eq(0) }
it { expect(subject.types_de_champ.size).to eq(0) }
end
end

View file

@ -14,7 +14,7 @@ FactoryGirl.define do
trait :with_procedure do
after(:build) do |dossier, _evaluator|
procedure = create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champs)
procedure = create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ)
dossier.procedure = procedure
end
end

View file

@ -4,11 +4,11 @@ FactoryGirl.define do
libelle 'Demande de subvention'
description "Demande de subvention à l'intention des associations"
trait :with_type_de_champs do
trait :with_type_de_champ do
after(:build) do |procedure, _evaluator|
type_de_champs = create(:type_de_champs)
type_de_champ = create(:type_de_champ)
procedure.types_de_champs << type_de_champs
procedure.types_de_champ << type_de_champ
end
end

View file

@ -1,5 +1,5 @@
FactoryGirl.define do
factory :type_de_champs do
factory :type_de_champ do
libelle 'Libellé'
description 'description de votre projet'
type_champs 'textarea'

View file

@ -0,0 +1,77 @@
require 'spec_helper'
feature 'add a new type de champs', js: true do
let(:administrateur) { create(:administrateur) }
before do
login_as administrateur, scope: :administrateur
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="type_de_champ[0][libelle]"]')
expect(page).to have_css('select[name="type_de_champ[0][type]"]')
expect(page).to have_css('textarea[name="type_de_champ[0][description]"]')
expect(page).to have_css('input[name="type_de_champ[0][order_place]"]', visible: false)
expect(page).to have_css('input[name="type_de_champ[0][id_type_de_champ]"]', visible: false)
expect(page).to have_css('input[name="type_de_champ[0][delete]"]', 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
context 'when user add a new champs type' do
before do
page.find_by_id('type_de_champ_0').find_by_id('libelle').set 'Libelle de test'
page.find_by_id('type_de_champ_0').find_by_id('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="type_de_champ[1][libelle]"]')
expect(page).to have_css('select[name="type_de_champ[1][type]"]')
expect(page).to have_css('textarea[name="type_de_champ[1][description]"]')
expect(page).to have_css('input[name="type_de_champ[1][order_place]"]', visible: false)
expect(page).to have_css('input[name="type_de_champ[1][id_type_de_champ]"]', visible: false)
expect(page).to have_css('input[name="type_de_champ[1][delete]"]', 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
scenario 'the first line is filled' do
expect(page.find_by_id('type_de_champ_0').find_by_id('libelle').value).to eq('Libelle de test')
expect(page.find_by_id('type_de_champ_0').find_by_id('description').value).to eq('Description de test')
expect(page.find_by_id('type_de_champ_0').find('input[class="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 new line is empty' do
expect(page.find_by_id('type_de_champ_1').find_by_id('libelle').value).to eq('')
expect(page.find_by_id('type_de_champ_1').find_by_id('description').value).to eq('')
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_by_id('id_type_de_champ', visible: false).value).to eq('')
expect(page.find_by_id('type_de_champ_1').find_by_id('delete', 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

View file

@ -1,77 +0,0 @@
require 'spec_helper'
feature 'add a new type de champs', js: true do
let(:administrateur) { create(:administrateur) }
before do
login_as administrateur, scope: :administrateur
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_champs_0')
expect(page).to have_css('input[name="type_de_champs[0][libelle]"]')
expect(page).to have_css('select[name="type_de_champs[0][type]"]')
expect(page).to have_css('textarea[name="type_de_champs[0][description]"]')
expect(page).to have_css('input[name="type_de_champs[0][order_place]"]', visible: false)
expect(page).to have_css('input[name="type_de_champs[0][id_type_de_champs]"]', visible: false)
expect(page).to have_css('input[name="type_de_champs[0][delete]"]', visible: false)
expect(page).to have_css('#order_type_de_champs_0_button', visible: false);
expect(page).to have_css('#order_type_de_champs_0_up_procedure', visible: false);
expect(page).to have_css('#order_type_de_champs_0_down_procedure', visible: false);
expect(page).to have_css('#new_type_de_champs #add_type_de_champs_button')
end
context 'when user add a new champs type' do
before do
page.find_by_id('type_de_champs_0').find_by_id('libelle').set 'Libelle de test'
page.find_by_id('type_de_champs_0').find_by_id('description').set 'Description de test'
page.click_on 'add_type_de_champs_procedure'
end
scenario 'a new champs type line is appeared with increment index id' do
expect(page).to have_css('#type_de_champs_1')
expect(page).to have_css('input[name="type_de_champs[1][libelle]"]')
expect(page).to have_css('select[name="type_de_champs[1][type]"]')
expect(page).to have_css('textarea[name="type_de_champs[1][description]"]')
expect(page).to have_css('input[name="type_de_champs[1][order_place]"]', visible: false)
expect(page).to have_css('input[name="type_de_champs[1][id_type_de_champs]"]', visible: false)
expect(page).to have_css('input[name="type_de_champs[1][delete]"]', visible: false)
expect(page).to have_css('#order_type_de_champs_1_button', visible: false);
expect(page).to have_css('#order_type_de_champs_1_up_procedure', visible: false);
expect(page).to have_css('#order_type_de_champs_1_down_procedure', visible: false);
end
scenario 'the first line is filled' do
expect(page.find_by_id('type_de_champs_0').find_by_id('libelle').value).to eq('Libelle de test')
expect(page.find_by_id('type_de_champs_0').find_by_id('description').value).to eq('Description de test')
expect(page.find_by_id('type_de_champs_0').find('input[class="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_champs_0_button')
expect(page).to have_css('#delete_type_de_champs_0_procedure')
end
scenario 'the new line is empty' do
expect(page.find_by_id('type_de_champs_1').find_by_id('libelle').value).to eq('')
expect(page.find_by_id('type_de_champs_1').find_by_id('description').value).to eq('')
expect(page.find_by_id('type_de_champs_1').find('input[class="order_place"]', visible: false).value).to eq('2')
expect(page.find_by_id('type_de_champs_1').find_by_id('id_type_de_champs', visible: false).value).to eq('')
expect(page.find_by_id('type_de_champs_1').find_by_id('delete', 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_champs #type_de_champs_1 #add_type_de_champs_button')
expect(page).not_to have_css('#type_de_champs_0 #add_type_de_champs_button')
end
end
end
end

View file

@ -14,112 +14,112 @@ feature 'config up and down button display', js: true do
visit admin_procedure_path id: procedure.id
end
scenario 'type_de_champs_0 have not up and down button visible' do
expect(page.find_by_id('order_type_de_champs_0_up_procedure', visible: false).visible?).to be_falsey
expect(page.find_by_id('order_type_de_champs_0_down_procedure', visible: false).visible?).to be_falsey
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_champs) }
let!(:procedure) { create(:procedure, :with_type_de_champ) }
before do
visit admin_procedure_path id: procedure.id
end
scenario 'type_de_champs_0 have not up and down button visible' do
expect(page.find_by_id('order_type_de_champs_0_up_procedure', visible: false).visible?).to be_falsey
expect(page.find_by_id('order_type_de_champs_0_down_procedure', visible: false).visible?).to be_falsey
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
scenario 'type_de_champs_1 have not up and down button visible' do
expect(page.find_by_id('order_type_de_champs_1_up_procedure', visible: false).visible?).to be_falsey
expect(page.find_by_id('order_type_de_champs_1_down_procedure', visible: false).visible?).to be_falsey
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
end
context 'when procedure have two type de champs' do
let!(:procedure) { create(:procedure, :with_type_de_champs) }
let!(:type_de_champs) { create(:type_de_champs, procedure: procedure, order_place: 2) }
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
scenario 'type_de_champs_0 have not up visible and down button visible' do
expect(page.find_by_id('order_type_de_champs_0_up_procedure', visible: false).visible?).to be_falsey
expect(page.find_by_id('order_type_de_champs_0_down_procedure').visible?).to be_truthy
scenario 'type_de_champ_0 have not up visible 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?).to be_truthy
end
scenario 'type_de_champs_1 have up button visible and down button not visible' do
expect(page.find_by_id('order_type_de_champs_1_up_procedure').visible?).to be_truthy
expect(page.find_by_id('order_type_de_champs_1_down_procedure', visible: false).visible?).to be_falsey
scenario 'type_de_champ_1 have up button visible and down button not visible' do
expect(page.find_by_id('order_type_de_champ_1_up_procedure').visible?).to be_truthy
expect(page.find_by_id('order_type_de_champ_1_down_procedure', visible: false).visible?).to be_falsey
end
scenario 'type_de_champs_2 have not up and down button visible' do
expect(page.find_by_id('order_type_de_champs_2_up_procedure', visible: false).visible?).to be_falsey
expect(page.find_by_id('order_type_de_champs_2_down_procedure', visible: false).visible?).to be_falsey
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 into database and one type de champs add to form' do
let!(:procedure) { create(:procedure, :with_type_de_champs) }
let!(:type_de_champs) { create(:type_de_champs, procedure: procedure, order_place: 2) }
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_champs_procedure'
page.click_on 'add_type_de_champ_procedure'
end
scenario 'type_de_champs_0 have not up visible and down button visible' do
expect(page.find_by_id('order_type_de_champs_0_up_procedure', visible: false).visible?).to be_falsey
expect(page.find_by_id('order_type_de_champs_0_down_procedure').visible?).to be_truthy
scenario 'type_de_champ_0 have not up visible 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?).to be_truthy
end
scenario 'type_de_champs_1 have up button and down button visible' do
expect(page.find_by_id('order_type_de_champs_1_up_procedure').visible?).to be_truthy
expect(page.find_by_id('order_type_de_champs_1_down_procedure').visible?).to be_truthy
scenario 'type_de_champ_1 have up button and down button visible' do
expect(page.find_by_id('order_type_de_champ_1_up_procedure').visible?).to be_truthy
expect(page.find_by_id('order_type_de_champ_1_down_procedure').visible?).to be_truthy
end
scenario 'type_de_champs_2 have up visible and down button not visible' do
expect(page.find_by_id('order_type_de_champs_2_up_procedure').visible?).to be_truthy
expect(page.find_by_id('order_type_de_champs_2_down_procedure', visible: false).visible?).to be_falsey
scenario 'type_de_champ_2 have up 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_champs_3 have not up and down button visible' do
expect(page.find_by_id('order_type_de_champs_3_up_procedure', visible: false).visible?).to be_falsey
expect(page.find_by_id('order_type_de_champs_3_down_procedure', visible: false).visible?).to be_falsey
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 and delete one type_de_champs' do
let!(:procedure) { create(:procedure, :with_type_de_champs) }
let!(:type_de_champs) { create(:type_de_champs, 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_champs_procedure'
page.click_on 'delete_type_de_champs_2_procedure'
page.click_on 'add_type_de_champ_procedure'
page.click_on 'delete_type_de_champ_2_procedure'
end
scenario 'type_de_champs_0 have not up visible and down button visible' do
expect(page.find_by_id('order_type_de_champs_0_up_procedure', visible: false).visible?).to be_falsey
expect(page.find_by_id('order_type_de_champs_0_down_procedure').visible?).to be_truthy
scenario 'type_de_champ_0 have not up visible 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?).to be_truthy
end
scenario 'type_de_champs_1 have up button visible and down button not visible' do
expect(page.find_by_id('order_type_de_champs_1_up_procedure').visible?).to be_truthy
expect(page.find_by_id('order_type_de_champs_1_down_procedure', visible: false).visible?).to be_falsey
scenario 'type_de_champ_1 have up button visible and down button not visible' do
expect(page.find_by_id('order_type_de_champ_1_up_procedure').visible?).to be_truthy
expect(page.find_by_id('order_type_de_champ_1_down_procedure', visible: false).visible?).to be_falsey
end
scenario 'type_de_champs_2 have up and down button not visible' do
expect(page.find_by_id('order_type_de_champs_2_up_procedure', visible: false).visible?).to be_falsey
expect(page.find_by_id('order_type_de_champs_2_down_procedure', visible: false).visible?).to be_falsey
scenario 'type_de_champ_2 have up and down button not 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
scenario 'type_de_champs_3 have not up and down button visible' do
expect(page.find_by_id('order_type_de_champs_3_up_procedure', visible: false).visible?).to be_falsey
expect(page.find_by_id('order_type_de_champs_3_down_procedure', visible: false).visible?).to be_falsey
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
end

View file

@ -0,0 +1,80 @@
require 'spec_helper'
feature 'delete a type de champs form', js: true do
let(:administrateur) { create(:administrateur) }
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) }
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 }
before do
page.click_on 'delete_type_de_champ_0_procedure'
end
scenario 'form is mask for the user' do
expect(page.find_by_id('type_de_champ_0', 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_0', visible: false).find_by_id('delete', 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_0', 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_1_procedure'
page.click_on 'delete_type_de_champ_2_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
expect(page.find_by_id('type_de_champ_2', 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_by_id('delete', visible: false).value).to eq('true')
expect(page.find_by_id('type_de_champ_2', visible: false).find_by_id('delete', 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)
expect(page).to have_css('#liste_delete_champ #type_de_champ_2', visible: false)
end
scenario 'order_place type_de_champ_0_procedure is 1' do
expect(page.find_by_id('type_de_champ_0').find("input[class='order_place']", visible: false).value).to eq('1')
end
scenario 'order_place type_de_champ_3_procedure is 2' do
expect(page.find_by_id('type_de_champ_3').find("input[class='order_place']", visible: false).value).to eq('2')
end
scenario 'order_place type_de_champ_4_procedure is 3' do
expect(page.find_by_id('type_de_champ_4').find("input[class='order_place']", visible: false).value).to eq('3')
end
scenario 'order_place type_de_champ_5_procedure is 4' do
expect(page.find_by_id('type_de_champ_5').find("input[class='order_place']", visible: false).value).to eq('4')
end
end
end
end

View file

@ -1,80 +0,0 @@
require 'spec_helper'
feature 'delete a type de champs form', js: true do
let(:administrateur) { create(:administrateur) }
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_champs) }
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_champs) { procedure.types_de_champs.first }
before do
page.click_on 'delete_type_de_champs_0_procedure'
end
scenario 'form is mask for the user' do
expect(page.find_by_id('type_de_champs_0', 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_champs_0', visible: false).find_by_id('delete', visible: false).value).to eq('true')
end
scenario 'attribut node is to move into div liste_delete_champs' do
expect(page).to have_css('#liste_delete_champs #type_de_champs_0', 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_champs_procedure'
page.click_on 'add_type_de_champs_procedure'
page.click_on 'add_type_de_champs_procedure'
page.click_on 'add_type_de_champs_procedure'
page.click_on 'add_type_de_champs_procedure'
page.click_on 'delete_type_de_champs_1_procedure'
page.click_on 'delete_type_de_champs_2_procedure'
end
scenario 'form is mask for the user' do
expect(page.find_by_id('type_de_champs_1', visible: false).visible?).to be_falsey
expect(page.find_by_id('type_de_champs_2', 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_champs_1', visible: false).find_by_id('delete', visible: false).value).to eq('true')
expect(page.find_by_id('type_de_champs_2', visible: false).find_by_id('delete', visible: false).value).to eq('true')
end
scenario 'attribut node is to move into div liste_delete_champs' do
expect(page).to have_css('#liste_delete_champs #type_de_champs_1', visible: false)
expect(page).to have_css('#liste_delete_champs #type_de_champs_2', visible: false)
end
scenario 'order_place type_de_champs_0_procedure is 1' do
expect(page.find_by_id('type_de_champs_0').find("input[class='order_place']", visible: false).value).to eq('1')
end
scenario 'order_place type_de_champs_3_procedure is 2' do
expect(page.find_by_id('type_de_champs_3').find("input[class='order_place']", visible: false).value).to eq('2')
end
scenario 'order_place type_de_champs_4_procedure is 3' do
expect(page.find_by_id('type_de_champs_4').find("input[class='order_place']", visible: false).value).to eq('3')
end
scenario 'order_place type_de_champs_5_procedure is 4' do
expect(page.find_by_id('type_de_champs_5').find("input[class='order_place']", visible: false).value).to eq('4')
end
end
end
end

View file

@ -0,0 +1,79 @@
require 'spec_helper'
feature 'move down button type de champs', js: true do
let(:administrateur) { create(:administrateur) }
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) }
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_0_down_procedure'
end
scenario 'it inverse the twice type de champs' do
expect(page.find_by_id('type_de_champ_0').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('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 to click on down_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_2 is reversed' do
expect(page.find_by_id('type_de_champ_0').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('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_3').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' do
before do
page.click_on 'order_type_de_champ_3_down_procedure'
end
scenario 'type_de_champ_3 and type_de_champ_4 is reversed' do
expect(page.find_by_id('type_de_champ_0').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('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_3').find('input[class="order_place"]', visible: false).value).to eq('5');
end
context 'when to click on up_button type_de_champ_0' do
before do
page.click_on 'order_type_de_champ_0_down_procedure'
end
scenario 'type_de_champ_0 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_0').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_3').find('input[class="order_place"]', visible: false).value).to eq('5');
end
end
end
end
end
end
end

View file

@ -1,79 +0,0 @@
require 'spec_helper'
feature 'move down button type de champs', js: true do
let(:administrateur) { create(:administrateur) }
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_champs) }
let!(:type_de_champs) { create(:type_de_champs, procedure: procedure, order_place: 2) }
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_champs_0_down_procedure'
end
scenario 'it inverse the twice type de champs' do
expect(page.find_by_id('type_de_champs_0').find('input[class="order_place"]', visible: false).value).to eq('2');
expect(page.find_by_id('type_de_champs_1').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_champs_procedure'
page.click_on 'add_type_de_champs_procedure'
page.click_on 'add_type_de_champs_procedure'
end
context 'when to click on down_button type_de_champs_1' do
before do
page.click_on 'order_type_de_champs_1_down_procedure'
end
scenario 'type_de_champs_1 and type_de_champs_2 is reversed' do
expect(page.find_by_id('type_de_champs_0').find('input[class="order_place"]', visible: false).value).to eq('1');
expect(page.find_by_id('type_de_champs_2').find('input[class="order_place"]', visible: false).value).to eq('2');
expect(page.find_by_id('type_de_champs_1').find('input[class="order_place"]', visible: false).value).to eq('3');
expect(page.find_by_id('type_de_champs_3').find('input[class="order_place"]', visible: false).value).to eq('4');
expect(page.find_by_id('type_de_champs_4').find('input[class="order_place"]', visible: false).value).to eq('5');
end
context 'when to click on up_button type_de_champs_3' do
before do
page.click_on 'order_type_de_champs_3_down_procedure'
end
scenario 'type_de_champs_3 and type_de_champs_4 is reversed' do
expect(page.find_by_id('type_de_champs_0').find('input[class="order_place"]', visible: false).value).to eq('1');
expect(page.find_by_id('type_de_champs_2').find('input[class="order_place"]', visible: false).value).to eq('2');
expect(page.find_by_id('type_de_champs_1').find('input[class="order_place"]', visible: false).value).to eq('3');
expect(page.find_by_id('type_de_champs_4').find('input[class="order_place"]', visible: false).value).to eq('4');
expect(page.find_by_id('type_de_champs_3').find('input[class="order_place"]', visible: false).value).to eq('5');
end
context 'when to click on up_button type_de_champs_0' do
before do
page.click_on 'order_type_de_champs_0_down_procedure'
end
scenario 'type_de_champs_0 and type_de_champs_2 is reversed' do
expect(page.find_by_id('type_de_champs_2').find('input[class="order_place"]', visible: false).value).to eq('1');
expect(page.find_by_id('type_de_champs_0').find('input[class="order_place"]', visible: false).value).to eq('2');
expect(page.find_by_id('type_de_champs_1').find('input[class="order_place"]', visible: false).value).to eq('3');
expect(page.find_by_id('type_de_champs_4').find('input[class="order_place"]', visible: false).value).to eq('4');
expect(page.find_by_id('type_de_champs_3').find('input[class="order_place"]', visible: false).value).to eq('5');
end
end
end
end
end
end
end

View file

@ -0,0 +1,72 @@
require 'spec_helper'
feature 'move up and down button type de champs', js: true do
let(:administrateur) { create(:administrateur) }
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) }
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_1 and down_button type_de_champ_0' do
before do
page.click_on 'order_type_de_champ_1_up_procedure'
page.click_on 'order_type_de_champ_0_down_procedure'
end
scenario 'type_de_champ_0 is at order place 3 and type_de_champ_1 is at order place 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_2').find('input[class="order_place"]', visible: false).value).to eq('2');
expect(page.find_by_id('type_de_champ_0').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_4').find('input[class="order_place"]', visible: false).value).to eq('5');
end
context 'when to click on down_button type_de_champ_3 and up_button type_de_champ_4' do
before do
page.click_on 'order_type_de_champ_3_down_procedure'
page.click_on 'order_type_de_champ_4_up_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_2').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_0').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
context 'when to click on up_button type_de_champ_2 and down_button type_de_champ_0 and up_button type_de_champ_4' do
before do
page.click_on 'order_type_de_champ_2_up_procedure'
page.click_on 'order_type_de_champ_0_down_procedure'
page.click_on 'order_type_de_champ_4_up_procedure'
end
scenario 'type_de_champ_2 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_4').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_3').find('input[class="order_place"]', visible: false).value).to eq('4');
expect(page.find_by_id('type_de_champ_0').find('input[class="order_place"]', visible: false).value).to eq('5');
end
end
end
end
end
end
end

View file

@ -1,72 +0,0 @@
require 'spec_helper'
feature 'move up and down button type de champs', js: true do
let(:administrateur) { create(:administrateur) }
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_champs) }
let!(:type_de_champs) { create(:type_de_champs, procedure: procedure, order_place: 2) }
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_champs_procedure'
page.click_on 'add_type_de_champs_procedure'
page.click_on 'add_type_de_champs_procedure'
end
#
context 'when to click on up_button type_de_champs_1 and down_button type_de_champs_0' do
before do
page.click_on 'order_type_de_champs_1_up_procedure'
page.click_on 'order_type_de_champs_0_down_procedure'
end
scenario 'type_de_champs_0 is at order place 3 and type_de_champs_1 is at order place 1 ' do
expect(page.find_by_id('type_de_champs_1').find('input[class="order_place"]', visible: false).value).to eq('1');
expect(page.find_by_id('type_de_champs_2').find('input[class="order_place"]', visible: false).value).to eq('2');
expect(page.find_by_id('type_de_champs_0').find('input[class="order_place"]', visible: false).value).to eq('3');
expect(page.find_by_id('type_de_champs_3').find('input[class="order_place"]', visible: false).value).to eq('4');
expect(page.find_by_id('type_de_champs_4').find('input[class="order_place"]', visible: false).value).to eq('5');
end
context 'when to click on down_button type_de_champs_3 and up_button type_de_champs_4' do
before do
page.click_on 'order_type_de_champs_3_down_procedure'
page.click_on 'order_type_de_champs_4_up_procedure'
end
scenario 'type_de_champs_2 and type_de_champs_3 is reversed' do
expect(page.find_by_id('type_de_champs_1').find('input[class="order_place"]', visible: false).value).to eq('1');
expect(page.find_by_id('type_de_champs_2').find('input[class="order_place"]', visible: false).value).to eq('2');
expect(page.find_by_id('type_de_champs_4').find('input[class="order_place"]', visible: false).value).to eq('3');
expect(page.find_by_id('type_de_champs_0').find('input[class="order_place"]', visible: false).value).to eq('4');
expect(page.find_by_id('type_de_champs_3').find('input[class="order_place"]', visible: false).value).to eq('5');
end
context 'when to click on up_button type_de_champs_2 and down_button type_de_champs_0 and up_button type_de_champs_4' do
before do
page.click_on 'order_type_de_champs_2_up_procedure'
page.click_on 'order_type_de_champs_0_down_procedure'
page.click_on 'order_type_de_champs_4_up_procedure'
end
scenario 'type_de_champs_2 and type_de_champs_4 is reversed' do
expect(page.find_by_id('type_de_champs_2').find('input[class="order_place"]', visible: false).value).to eq('1');
expect(page.find_by_id('type_de_champs_4').find('input[class="order_place"]', visible: false).value).to eq('2');
expect(page.find_by_id('type_de_champs_1').find('input[class="order_place"]', visible: false).value).to eq('3');
expect(page.find_by_id('type_de_champs_3').find('input[class="order_place"]', visible: false).value).to eq('4');
expect(page.find_by_id('type_de_champs_0').find('input[class="order_place"]', visible: false).value).to eq('5');
end
end
end
end
end
end
end

View file

@ -0,0 +1,80 @@
require 'spec_helper'
feature 'move up button type de champs', js: true do
let(:administrateur) { create(:administrateur) }
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) }
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_up_procedure'
end
scenario 'it inverse the twice type de champs' do
expect(page.find_by_id('type_de_champ_0').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('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 to click on up_button type_de_champ_1' do
before do
page.click_on 'order_type_de_champ_1_up_procedure'
end
scenario 'type_de_champ_0 and type_de_champ_1 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_0').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_3').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' do
before do
page.click_on 'order_type_de_champ_3_up_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_0').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_2').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_4' do
before do
page.click_on 'order_type_de_champ_4_up_procedure'
end
scenario 'type_de_champ_2 and type_de_champ_4 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_0').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_2').find('input[class="order_place"]', visible: false).value).to eq('5');
end
end
end
end
end
end
end

View file

@ -1,80 +0,0 @@
require 'spec_helper'
feature 'move up button type de champs', js: true do
let(:administrateur) { create(:administrateur) }
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_champs) }
let!(:type_de_champs) { create(:type_de_champs, procedure: procedure, order_place: 2) }
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_champs_1_up_procedure'
end
scenario 'it inverse the twice type de champs' do
expect(page.find_by_id('type_de_champs_0').find('input[class="order_place"]', visible: false).value).to eq('2');
expect(page.find_by_id('type_de_champs_1').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_champs_procedure'
page.click_on 'add_type_de_champs_procedure'
page.click_on 'add_type_de_champs_procedure'
end
context 'when to click on up_button type_de_champs_1' do
before do
page.click_on 'order_type_de_champs_1_up_procedure'
end
scenario 'type_de_champs_0 and type_de_champs_1 is reversed' do
expect(page.find_by_id('type_de_champs_1').find('input[class="order_place"]', visible: false).value).to eq('1');
expect(page.find_by_id('type_de_champs_0').find('input[class="order_place"]', visible: false).value).to eq('2');
expect(page.find_by_id('type_de_champs_2').find('input[class="order_place"]', visible: false).value).to eq('3');
expect(page.find_by_id('type_de_champs_3').find('input[class="order_place"]', visible: false).value).to eq('4');
expect(page.find_by_id('type_de_champs_4').find('input[class="order_place"]', visible: false).value).to eq('5');
end
context 'when to click on up_button type_de_champs_3' do
before do
page.click_on 'order_type_de_champs_3_up_procedure'
end
scenario 'type_de_champs_2 and type_de_champs_3 is reversed' do
expect(page.find_by_id('type_de_champs_1').find('input[class="order_place"]', visible: false).value).to eq('1');
expect(page.find_by_id('type_de_champs_0').find('input[class="order_place"]', visible: false).value).to eq('2');
expect(page.find_by_id('type_de_champs_3').find('input[class="order_place"]', visible: false).value).to eq('3');
expect(page.find_by_id('type_de_champs_2').find('input[class="order_place"]', visible: false).value).to eq('4');
expect(page.find_by_id('type_de_champs_4').find('input[class="order_place"]', visible: false).value).to eq('5');
end
context 'when to click on up_button type_de_champs_4' do
before do
page.click_on 'order_type_de_champs_4_up_procedure'
end
scenario 'type_de_champs_2 and type_de_champs_4 is reversed' do
expect(page.find_by_id('type_de_champs_1').find('input[class="order_place"]', visible: false).value).to eq('1');
expect(page.find_by_id('type_de_champs_0').find('input[class="order_place"]', visible: false).value).to eq('2');
expect(page.find_by_id('type_de_champs_3').find('input[class="order_place"]', visible: false).value).to eq('3');
expect(page.find_by_id('type_de_champs_4').find('input[class="order_place"]', visible: false).value).to eq('4');
expect(page.find_by_id('type_de_champs_2').find('input[class="order_place"]', visible: false).value).to eq('5');
end
end
end
end
end
end
end

View file

@ -7,12 +7,12 @@ describe Champ do
describe 'associations' do
it { is_expected.to belong_to(:dossier) }
it { is_expected.to belong_to(:type_de_champs) }
it { is_expected.to belong_to(:type_de_champ) }
end
describe 'delegation' do
it { is_expected.to delegate_method(:libelle).to(:type_de_champs) }
it { is_expected.to delegate_method(:type_champs).to(:type_de_champs) }
it { is_expected.to delegate_method(:order_place).to(:type_de_champs) }
it { is_expected.to delegate_method(:libelle).to(:type_de_champ) }
it { is_expected.to delegate_method(:type_champs).to(:type_de_champ) }
it { is_expected.to delegate_method(:order_place).to(:type_de_champ) }
end
end

View file

@ -28,7 +28,7 @@ describe Dossier do
it { is_expected.to delegate_method(:siren).to(:entreprise) }
it { is_expected.to delegate_method(:siret).to(:etablissement) }
it { is_expected.to delegate_method(:types_de_piece_justificative).to(:procedure) }
it { is_expected.to delegate_method(:types_de_champs).to(:procedure) }
it { is_expected.to delegate_method(:types_de_champ).to(:procedure) }
end
describe 'validation' do

View file

@ -3,7 +3,7 @@ require 'spec_helper'
describe Procedure do
describe 'assocations' do
it { is_expected.to have_many(:types_de_piece_justificative) }
it { is_expected.to have_many(:types_de_champs) }
it { is_expected.to have_many(:types_de_champ) }
it { is_expected.to have_many(:dossiers) }
end

View file

@ -1,6 +1,6 @@
require 'spec_helper'
describe TypeDeChamps do
describe TypeDeChamp do
describe 'database columns' do
it { is_expected.to have_db_column(:libelle) }
it { is_expected.to have_db_column(:type_champs) }