Merge branch 'develop' into staging

This commit is contained in:
Mathieu Magnin 2017-03-20 15:56:55 +01:00
commit 05bab5c402
34 changed files with 237 additions and 144 deletions

View file

@ -102,6 +102,8 @@ gem 'simple_form'
gem 'newrelic_rpm'
gem 'select2-rails'
group :test do
gem 'capybara'
gem 'launchy'

View file

@ -543,6 +543,8 @@ GEM
json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0)
securecompare (1.0.0)
select2-rails (4.0.3)
thor (~> 0.14)
selenium-webdriver (3.0.3)
childprocess (~> 0.5)
rubyzip (~> 1.0)
@ -709,6 +711,7 @@ DEPENDENCIES
sass-rails (~> 5.0)
scenic
sdoc (~> 0.4.0)
select2-rails
selenium-webdriver
sentry-raven
shoulda-matchers

View file

@ -23,22 +23,25 @@ function destroy_action(){
}
function on_change_type_de_champ_select (){
$("select.form-control.type_champ").on('change', function(e){
parent = $(this).parent().parent();
parent.removeClass('header_section');
parent.children(".drop_down_list").removeClass('show_inline');
$('.mandatory', parent).show();
switch(this.value){
case 'header_section':
parent.addClass('header_section');
break;
case 'drop_down_list':
case 'multiple_drop_down_list':
parent.children(".drop_down_list").addClass('show_inline');
break;
case 'explication':
$('.mandatory', parent).hide();
break;
}
})
});
}

View file

@ -31,6 +31,7 @@
//= require bootstrap-wysihtml5/locales/fr-FR
//= require handlebars
//= require typeahead.bundle
//= require select2
$(document).on('page:load', application_init);
$(document).ready(application_init);

View file

@ -0,0 +1,6 @@
$(document).on('page:load', activeSelect2);
$(document).ready(activeSelect2);
function activeSelect2() {
$('select.select2').select2({ theme: "bootstrap", width: '100%' });
}

View file

@ -23,6 +23,10 @@
}
#liste_champ{
.form-inline {
margin-bottom: 30px;
}
.show_inline {
display: inline-block !important;
}
@ -30,4 +34,16 @@
.form-group.drop_down_list{
display: none;
}
.form-group {
vertical-align: top;
margin-right: 15px;
}
.description {
padding: 0;
textarea {
padding: 6px 12px;
}
}
}

View file

@ -19,6 +19,8 @@
*= require font-awesome
*= require franceconnect
*= require bootstrap-wysihtml5
*= require select2
*= require select2-bootstrap
*/
@import "variables";
@import "bootstrap-sprockets";

View file

@ -2,9 +2,8 @@ class ChampDecorator < Draper::Decorator
delegate_all
def value
if type_champ == 'checkbox'
return object.value == 'on' ? 'Oui' : 'Non'
end
return object.value == 'on' ? 'Oui' : 'Non' if type_champ == 'checkbox'
return JSON.parse(object.value).join(', ') if type_champ == 'multiple_drop_down_list' && object.value.present?
object.value
end

View file

@ -3,11 +3,19 @@ class TypeDeChampDecorator < Draper::Decorator
delegate_all
def button_up params
h.link_to '', params[:url], class: up_classes, id: "btn_up_#{params[:index]}", remote: true, method: :post if display_up_button?(params[:index], params[:private])
h.link_to '', params[:url], class: up_classes,
id: "btn_up_#{params[:index]}",
remote: true,
method: :post,
style: display_up_button?(params[:index], params[:private]) ? '' : 'visibility: hidden;'
end
def button_down params
h.link_to '', params[:url], class: down_classes, id: "btn_down_#{params[:index]}", remote: true, method: :post if display_down_button?(params[:index], params[:private])
h.link_to '', params[:url], class: down_classes,
id: "btn_down_#{params[:index]}",
remote: true,
method: :post,
style: display_down_button?(params[:index], params[:private]) ? '' : 'visibility: hidden;'
end
private

View file

@ -2,6 +2,19 @@ class DropDownList < ActiveRecord::Base
belongs_to :type_de_champ
def options
value.split(/[\r\n]|[\r]|[\n]|[\n\r]/).reject(&:empty?)
result = value.split(/[\r\n]|[\r]|[\n]|[\n\r]/).reject(&:empty?)
result.blank? ? [] : [''] + result
end
def disabled_options
options.select{ |v| !(v =~ /^--.*--$/).nil? }
end
def selected_options(champ)
champ.object.value.blank? ? [] : multiple ? JSON.parse(champ.object.value) : [champ.object.value]
end
def multiple
type_de_champ.type_champ == 'multiple_drop_down_list'
end
end

View file

@ -12,11 +12,13 @@ class TypeDeChamp < ActiveRecord::Base
address: 'address',
yes_no: 'yes_no',
drop_down_list: 'drop_down_list',
multiple_drop_down_list: 'multiple_drop_down_list',
pays: 'pays',
regions: 'regions',
departements: 'departements',
engagement: 'engagement',
header_section: 'header_section'
header_section: 'header_section',
explication: 'explication'
}
belongs_to :procedure
@ -29,7 +31,7 @@ class TypeDeChamp < ActiveRecord::Base
validates :libelle, presence: true, allow_blank: false, allow_nil: false
validates :type_champ, presence: true, allow_blank: false, allow_nil: false
before_validation :change_header_section_mandatory
before_validation :check_mandatory
def self.type_de_champs_list_fr
type_champs.map { |champ| [I18n.t("activerecord.attributes.type_de_champ.type_champs.#{champ.last}"), champ.first] }
@ -39,8 +41,8 @@ class TypeDeChamp < ActiveRecord::Base
!(type_champ == 'textarea' || type_champ == 'header_section')
end
def change_header_section_mandatory
self.mandatory = false if self.type_champ == 'header_section'
def check_mandatory
self.mandatory = false if %w(header_section explication).include?(self.type_champ)
true
end
end

View file

@ -12,8 +12,18 @@ class TypesDeChampService
if param_second[:libelle].empty?
parameters[attributes].delete(param_first.to_s)
end
if param_second['drop_down_list_attributes'] && param_second['drop_down_list_attributes']['value']
param_second['drop_down_list_attributes']['value'] = self.clean_value (param_second['drop_down_list_attributes']['value'])
end
end
parameters
end
private
def self.clean_value value
value.split("\r\n").map{ |v| v.strip }.join("\r\n")
end
end

View file

@ -82,7 +82,7 @@
.pieces_justificatives.col-xs-6.col-md-3
%h4.text-info
Pièces justificatives
Pièces jointes
.badge.progress-bar-info
= @facade.procedure.types_de_piece_justificative.size
- @facade.procedure.types_de_piece_justificative.each do |piece_justificative|

View file

@ -1,5 +1,5 @@
#profile_page
%h2 Profile
%h2 Profil
%hr
%p
API TOKEN :

View file

@ -1,5 +1,7 @@
= f.fields_for @types_de_champ_facade.fields_for_var, types_de_champ, remote: true do |ff|
.form-inline{class:"#{ff.object.object.type_champ == 'header_section' ? 'header_section' : ''}"}
- type_champ = ff.object.object.type_champ
.form-inline{ class: (type_champ == 'header_section' ? 'header_section' : nil) }
.form-group.libelle
%h4 Libellé
= ff.text_field :libelle, class: 'form-control libelle', placeholder: 'Libellé'
@ -10,15 +12,17 @@
.form-group.description
%h4 Description
= ff.text_area :description, class: 'form-control description', placeholder: 'Description', rows: 2
= ff.text_area :description, class: 'form-control description', placeholder: 'Description', rows: 3
.form-group.drop_down_list{class:"#{ff.object.object.type_champ == 'drop_down_list' ? 'show_inline' : ''}",style:'margin-right: 5px'}
.form-group.drop_down_list{ class: (%w(drop_down_list multiple_drop_down_list).include?(type_champ) ? 'show_inline' : nil), style: 'margin-right: 5px' }
%h4 Liste déroulante
= ff.fields_for :drop_down_list_attributes, ff.object.object.drop_down_list do |fff|
= fff.text_area :value, class: 'form-control drop_down_list', placeholder: "Ecrire une valeur par ligne.\nEcrire --valeur-- pour un séparateur.", rows: 3, cols: 30
~ fff.text_area :value, class: 'form-control drop_down_list', placeholder: "Ecrire une valeur par ligne et --valeur-- pour un séparateur.", rows: 3, cols: 30
= fff.hidden_field :id
- unless ff.object.object.class == TypeDeChampPrivate
.form-group.mandatory
- hide_mandatory = (ff.object.object.class == TypeDeChampPrivate || type_champ == 'explication')
.form-group.mandatory{ style: hide_mandatory ? 'visibility: hidden;' : nil }
%h4 Obligatoire ?
.center
= ff.check_box :mandatory, placeholder: 'Obligatoire ?'
@ -41,4 +45,6 @@
- else
= link_to("", @types_de_champ_facade.delete_url(ff), method: :delete, remote: true, id: "delete_type_de_champ_#{ff.object.id}", class: %w(form-control btn btn-danger fa fa-trash-o) )
%div{ style: 'background-color: rgb(204, 204, 204); height: 1px; margin: 30px auto;' }

View file

@ -1,5 +1,5 @@
%div.row
.col-lg-12.col-md-12.col-sm-12.col-xs-12
.col-xs-12
- if @facade.procedure.for_individual?
.row.title-row
%div.col-xs-4.split-hr
@ -7,24 +7,25 @@
%div.col-xs-4.split-hr
.row
%div.col-xs-6.depositaire-label Civilité
%div.col-md-1.col-lg-1.col-sm-1.col-xs-1.comments-off= "-"
%div.col-xs-1.comments-off= "-"
%div.col-xs-5.depositaire-info= @facade.individual.gender
.row
%div.col-xs-6.depositaire-label Nom
%div.col-md-1.col-lg-1.col-sm-1.col-xs-1.comments-off= "-"
%div.col-xs-1.comments-off= "-"
%div.col-xs-5.depositaire-info= @facade.individual.nom
.row
%div.col-xs-6.depositaire-label Prénom
%div.col-md-1.col-lg-1.col-sm-1.col-xs-1.comments-off= "-"
%div.col-xs-1.comments-off= "-"
%div.col-xs-5.despositaire-info= @facade.individual.prenom
.row
%div.col-xs-6.depositaire-label Date de naissance
%div.col-md-1.col-lg-1.col-sm-1.col-xs-1.comments-off= "-"
%div.col-xs-1.comments-off= "-"
%div.col-xs-5.depositaire-info= @facade.individual.birthdate
.row.margin-top-20
- unless @facade.champs.nil?
- @facade.champs.each do |champ|
- next if champ.type_champ == 'explication'
- if champ.type_champ == 'header_section'
.row.title-row.margin-top-40
%div.col-xs-3.split-hr
@ -48,19 +49,19 @@
=")"
%div.row
- if @facade.procedure.cerfa_flag? || @facade.dossier.types_de_piece_justificative.count > 0
.col-lg-12.col-md-12.col-sm-12.col-xs-12
.col-xs-12
.row.title-row
%div.col-xs-4.split-hr
%div.col-xs-4.dossier-title= t('utils.pieces').upcase
%div.col-xs-4.split-hr
.col-lg-12.col-md-12.col-sm-12.col-xs-12#pieces_justificatives.margin-bot-40
.col-xs-12#pieces_justificatives.margin-bot-40
.row
- if @facade.procedure.cerfa_flag?
.col-xs-12#piece_justificative_0
.row.piece-row
.col-xs-6.depositaire-label= 'Formulaire'
.col-md-1.col-lg-1.col-sm-1.col-xs-1.comments-off= "-"
.col-xs-1.comments-off= "-"
.col-xs-5.despositaire-info
- if @facade.dossier.cerfa_available?
%a{ href: "#{@facade.dossier.cerfa.last.content_url}", target: '_blank' } Consulter
@ -77,7 +78,7 @@
.col-xs-12{ id: "piece_justificative_#{type_de_piece_justificative.id}" }
.row
%div.col-xs-6.depositaire-label= type_de_piece_justificative.libelle
%div.col-md-1.col-lg-1.col-sm-1.col-xs-1.comments-off= "-"
%div.col-xs-1.comments-off= "-"
%div.col-xs-5.despositaire-info
- if type_de_piece_justificative.api_entreprise
%span.text-success Nous l'avons récupéré pour vous.
@ -95,13 +96,13 @@
- if user_signed_in? && (@facade.dossier.owner?(current_user.email) || @facade.dossier.invite_by_user?(current_user.email))
- if @facade.procedure.cerfa_flag? || @facade.dossier.types_de_piece_justificative.size > 0
.row
.col-lg-4.col-md-4.col-sm-4.col-xs-4
.col-xs-4
%a#maj_pj.action{"data-target" => "#UploadPJmodal", "data-toggle" => "modal", :type => "button"}
.col-lg-4.col-md-4.col-sm-4.col-xs-4.action
.col-xs-4.action
Modifier les documents
%br
= render partial: 'users/recapitulatif/modal_upload_pj'
.col-lg-4.col-md-4.col-sm-4.col-xs-4
.col-xs-4
- if gestionnaire_signed_in?
#PJmodal.modal.fade{"aria-labelledby" => "myModalLabel", :role => "dialog", :tabindex => "-1"}

View file

@ -31,7 +31,7 @@
- unless @procedure.locked?
%a{:href => "#{url_for admin_procedure_pieces_justificatives_path(@procedure)}", id: 'onglet-pieces'}
%div.procedure_list_element{class: ('active' if active == 'Pieces')}
Pièces justificatives
Pièces jointes
- unless @procedure.locked?
%a{:href => "#{url_for admin_procedure_types_de_champ_private_path(@procedure)}", id: 'onglet-private-champs'}

View file

@ -54,9 +54,9 @@
.type= "Un attribut à été changé: #{notification.liste.last}"
- elsif ['piece_justificative'].include?(notification.type_notif)
- if notification.liste.size > 1
.type= "Plusieurs pièces justificatives ont été changés, dont: #{notification.liste.join(" ")}"
.type= "Plusieurs pièces jointes ont été changés, dont: #{notification.liste.join(" ")}"
- else
.type= "Une pièce justificative à été changée: #{notification.liste.last}"
.type= "Une pièce jointe à été changée: #{notification.liste.last}"
- else
.type= notification.liste.last
.split-hr

View file

@ -23,4 +23,4 @@
%li
= link_to(admin_profile_path, id: :profile) do
%i.fa.fa-user
&nbsp;Profile
&nbsp;Profil

View file

@ -4,7 +4,7 @@
.panel.panel-info{style:'margin-bottom:0'}
.panel-body.center
.row
.col-md-1.col-lg-1.col-sm-1.col-xs-1
.col-xs-1
.fa.fa-info-circle.text-info{style:'font-size: 2em; margin-top: 20%'}
.col-xs-10{style:'padding-right: 0px'}
%b
@ -22,7 +22,7 @@
-if !@procedure.lien_demarche.blank? || @procedure.cerfa_flag || @dossier.types_de_piece_justificative.size > 0
%br
%h3 Documents administratifs
%h3 Pièces jointes
//TODO a refactorer
@ -30,17 +30,6 @@
.col-lg-8
= render partial: 'users/description/pieces_justificatives', locals: { dossier: @dossier }
#state_description.row{style:'width: 50%; margin-left:20px'}
.panel.panel-info
.panel-body.center
.row
.col-md-1.col-lg-1.col-sm-1.col-xs-1
.fa.fa-info-circle.text-info{style:'font-size: 2em; margin-top: 20%'}
.col-xs-11
Les documents administratifs ne sont pas indispensables afin d'initier votre dossier.
Vous pourrez dans tous les cas les compléter plus tard si vous ne les possédez pas de suite.
-route = Rails.application.routes.recognize_path(request.referrer) # WTF ?
- unless route[:controller].match('admin')
%div{style: 'text-align:right'}

View file

@ -1,2 +1,2 @@
- unless champ.drop_down_list.nil?
= render partial: 'users/description/champs/drop_down_template', locals: {values: champ.drop_down_list.options, champ: champ}
= render partial: 'users/description/champs/drop_down_template', locals: { drop_down_list: champ.drop_down_list, champ: champ }

View file

@ -1,18 +1,6 @@
%select{ name:"champs['#{champ.id}']",
id: "champs_#{champ.id}" }
- unless values.blank?
%option
= ''
- values.each do |option|
- if (option=~ /^--.*--$/).nil?
- if champ.value == option
%option{selected:''}
= option
- else
%option
= option
-else
%option{disabled:''}
= option
- unless drop_down_list.options.blank?
= select_tag("champs['#{champ.id}']",
options_for_select(drop_down_list.options, selected: drop_down_list.selected_options(champ),
disabled: drop_down_list.disabled_options),
multiple: drop_down_list.multiple,
class: drop_down_list.multiple ? 'select2' : nil)

View file

@ -1,9 +1,9 @@
.default_data_block.default_visible
%div.row.show-block.infos
%div.header
%div.col-lg-12.col-md-12.col-sm-12.col-xs-12.title
%div.carret-right
%div.carret-down
.row.show-block.infos
.header
.col-xs-12.title
.carret-right
.carret-down
=libelle
%div.body
.body
= render partial: 'users/description/champs/render_list_champs', locals: {champs: champs, order_place: order_place}

View file

@ -26,7 +26,7 @@
- elsif champ.type_champ == 'yes_no'
= render partial: 'users/description/champs/yes_no', locals: { champ: champ }
- elsif champ.type_champ == 'drop_down_list'
- elsif %w(drop_down_list multiple_drop_down_list).include?(champ.type_champ)
= render partial: 'users/description/champs/drop_down_list', locals: { champ: champ }
- elsif champ.type_champ == 'pays'
@ -41,6 +41,8 @@
- elsif champ.type_champ == 'departements'
= render partial: 'users/description/champs/departements', locals: { champ: champ }
- elsif champ.type_champ == 'explication'
- else
%input.form-control{name:"champs['#{ champ.id }']",
placeholder: champ.libelle,

View file

@ -47,7 +47,7 @@
= f.email_field :email, class: 'form-control', placeholder: 'Email', value: params[:user_email]
%br
%h4
= f.label :password
= f.label :password, 'Mot de passe'
.input-group
.input-group-addon
%span.fa.fa-asterisk

View file

@ -22,3 +22,5 @@ fr:
departements: 'Départements'
engagement: 'Engagement'
header_section: 'Titre de section'
explication: 'Explication'
multiple_drop_down_list: 'Menu déroulant à choix multiples'

View file

@ -1,19 +1,18 @@
require 'spec_helper'
describe ChampDecorator do
let(:champ) {create :champ, type_de_champ: (create :type_de_champ_public, type_champ: :checkbox)}
let(:champ) {create :champ, type_de_champ: (create :type_de_champ_public, type_champ: type_champ)}
let(:decorator) { champ.decorate }
describe 'value' do
subject { decorator.value }
context 'when type_champ is checkbox' do
describe 'for a checkbox' do
let(:type_champ) { :checkbox }
context 'when value is on' do
before do
champ.update value: 'on'
end
before { champ.update value: 'on' }
it { is_expected.to eq 'Oui' }
end
@ -21,5 +20,19 @@ describe ChampDecorator do
it { is_expected.to eq 'Non' }
end
end
describe 'for a multiple_drop_down_list' do
let(:type_champ) { :multiple_drop_down_list }
context 'when value is an array' do
before { champ.update value: '["1", "2"]' }
it { is_expected.to eq '1, 2' }
end
context 'when value is empty' do
before { champ.update value: '' }
it { is_expected.to eq '' }
end
end
end
end

View file

@ -16,8 +16,8 @@ describe TypeDeChampDecorator do
subject { type_de_champ_0.decorate }
let(:button_up) { type_de_champ_.decorate }
it 'returns a button up' do
expect(subject.button_up(params)).to be(nil)
it 'hide a button up' do
expect(subject.button_up(params)).to include('visibility: hidden')
end
it 'returns a button down' do
expect(subject.button_down(params)).to match(/fa-chevron-down/)
@ -45,8 +45,9 @@ describe TypeDeChampDecorator do
it 'returns a button up' do
expect(subject.button_up(params)).to match(/fa-chevron-up/)
end
it 'returns a button down' do
expect(subject.button_down(params)).to be(nil)
it 'hide a button down' do
expect(subject.button_down(params)).to include('visibility: hidden')
end
end
end

View file

@ -9,15 +9,16 @@ describe DropDownList do
it { is_expected.to belong_to(:type_de_champ) }
end
let(:dropdownlist) { create :drop_down_list, value: value }
describe '#options' do
let(:value) { "Cohésion sociale
Dév.Eco / Emploi
Cadre de vie / Urb.
Pilotage / Ingénierie
" }
let(:dropdownlist) { create :drop_down_list, value: value }
it { expect(dropdownlist.options).to eq ["Cohésion sociale", "Dév.Eco / Emploi", "Cadre de vie / Urb.", "Pilotage / Ingénierie"] }
it { expect(dropdownlist.options).to eq ['', 'Cohésion sociale', 'Dév.Eco / Emploi', 'Cadre de vie / Urb.', 'Pilotage / Ingénierie'] }
context 'when one value is empty' do
let(:value) { "Cohésion sociale
@ -26,7 +27,36 @@ Cadre de vie / Urb.
Pilotage / Ingénierie
" }
it { expect(dropdownlist.options).to eq ["Cohésion sociale", "Cadre de vie / Urb.", "Pilotage / Ingénierie"] }
it { expect(dropdownlist.options).to eq ['', 'Cohésion sociale', 'Cadre de vie / Urb.', 'Pilotage / Ingénierie'] }
end
end
describe 'disabled_options' do
let(:value) { "tip
--top--
--troupt--
ouaich" }
it { expect(dropdownlist.disabled_options).to match(['--top--', '--troupt--']) }
end
describe 'selected_options' do
let(:dropdownlist) do
create(:drop_down_list, type_de_champ: type_de_champ)
end
context 'when multiple' do
let(:type_de_champ) { TypeDeChamp.new(type_champ: 'multiple_drop_down_list') }
let(:champ) { Champ.new(value: '["1","2"]').decorate }
it { expect(dropdownlist.selected_options(champ)).to match(['1', '2']) }
end
context 'when simple' do
let(:type_de_champ) { TypeDeChamp.new(type_champ: 'drop_down_list') }
let(:champ) { Champ.new(value: '1').decorate }
it { expect(dropdownlist.selected_options(champ)).to match(['1']) }
end
end
end

View file

@ -0,0 +1,30 @@
require 'spec_helper'
describe TypesDeChampService do
let(:params) do
ActionController::Parameters.new({
procedure: {
types_de_champ_attributes: {
"0" => {
libelle: 'top',
drop_down_list_attributes: {
value: "un\r\n deux\r\n -- commentaire --\r\n trois",
id: '5218'
}
}
}
}
})
end
let(:result) { TypesDeChampService.create_update_procedure_params(params) }
describe 'self.create_update_procedure_params' do
describe 'the drop down list attributes' do
subject { result['types_de_champ_attributes']['0']['drop_down_list_attributes'] }
it 'has its value stripped' do
expect(subject['value']).to eq("un\r\ndeux\r\n-- commentaire --\r\ntrois")
end
end
end
end

View file

@ -129,22 +129,5 @@ describe 'admin/previsualisations/show.html.haml', type: :view do
it { expect(rendered).not_to have_content 'Documents administratifs' }
end
context 'when dossier have pj' do
let(:dossier) { create(:dossier) }
it { expect(rendered).to have_content 'Documents administratifs' }
end
context 'when procedure have demarche link' do
let(:procedure) { create :procedure }
it { expect(rendered).to have_content 'Documents administratifs' }
end
context 'when procedure have cerfa flag true' do
let(:procedure) {create(:procedure, cerfa_flag: true)}
it { expect(rendered).to have_content 'Documents administratifs' }
end
end
end

View file

@ -33,8 +33,8 @@ describe 'admin/types_de_champ/show.html.haml', type: :view do
end
context 'when there is only one field in database' do
let!(:type_de_champ_0) { create(:type_de_champ_public, procedure: procedure, order_place: 0) }
it { expect(subject).not_to have_css('#btn_down_0') }
it { expect(subject).not_to have_css('#btn_up_0') }
it { expect(subject).to have_css('#btn_down_0[style*="visibility: hidden"]') }
it { expect(subject).to have_css('#btn_up_0[style*="visibility: hidden"]') }
it { expect(subject).not_to have_css('#btn_up_1') }
it { expect(subject).not_to have_css('#btn_down_1') }
end
@ -42,9 +42,9 @@ describe 'admin/types_de_champ/show.html.haml', type: :view do
let!(:type_de_champ_0) { create(:type_de_champ_public, procedure: procedure, order_place: 0) }
let!(:type_de_champ_1) { create(:type_de_champ_public, procedure: procedure, order_place: 1) }
it { expect(subject).to have_css('#btn_down_0') }
it { expect(subject).not_to have_css('#btn_up_0') }
it { expect(subject).to have_css('#btn_up_0[style*="visibility: hidden"]') }
it { expect(subject).to have_css('#btn_up_1') }
it { expect(subject).not_to have_css('#btn_down_1') }
it { expect(subject).to have_css('#btn_down_1[style*="visibility: hidden"]') }
end
end
end

View file

@ -30,7 +30,7 @@ describe 'admin/types_de_champ/show.html.haml', type: :view do
describe 'mandatory checkbox' do
it 'no mandatory checkbox are present' do
expect(subject).not_to have_css('.form-group.mandatory')
expect(subject).to have_css('.form-group.mandatory[style*="visibility: hidden"]')
end
end
@ -41,8 +41,8 @@ describe 'admin/types_de_champ/show.html.haml', type: :view do
end
context 'when there is only one field in database' do
let!(:type_de_champ_0) { create(:type_de_champ_private, procedure: procedure, order_place: 0) }
it { expect(subject).not_to have_css('#btn_down_0') }
it { expect(subject).not_to have_css('#btn_up_0') }
it { expect(subject).to have_css('#btn_down_0[style*="visibility: hidden"]') }
it { expect(subject).to have_css('#btn_up_0[style*="visibility: hidden"]') }
it { expect(subject).not_to have_css('#btn_up_1') }
it { expect(subject).not_to have_css('#btn_down_1') }
end
@ -50,9 +50,9 @@ describe 'admin/types_de_champ/show.html.haml', type: :view do
let!(:type_de_champ_0) { create(:type_de_champ_private, procedure: procedure, order_place: 0) }
let!(:type_de_champ_1) { create(:type_de_champ_private, procedure: procedure, order_place: 1) }
it { expect(subject).to have_css('#btn_down_0') }
it { expect(subject).not_to have_css('#btn_up_0') }
it { expect(subject).to have_css('#btn_up_0[style*="visibility: hidden"]') }
it { expect(subject).to have_css('#btn_up_1') }
it { expect(subject).not_to have_css('#btn_down_1') }
it { expect(subject).to have_css('#btn_down_1[style*="visibility: hidden"]') }
end
end
end

View file

@ -125,22 +125,5 @@ describe 'users/description/show.html.haml', type: :view do
it { expect(rendered).not_to have_content 'Documents administratifs' }
end
context 'when dossier have pj' do
let(:dossier) { create(:dossier) }
it { expect(rendered).to have_content 'Documents administratifs' }
end
context 'when procedure have demarche link' do
let(:procedure) { create :procedure }
it { expect(rendered).to have_content 'Documents administratifs' }
end
context 'when procedure have cerfa flag true' do
let(:procedure) { create(:procedure, cerfa_flag: true) }
it { expect(rendered).to have_content 'Documents administratifs' }
end
end
end