Adding feature tests for Accompagnateur, continue on page features, then on dossier show

This commit is contained in:
JC 2016-12-20 17:26:46 +01:00
parent 90804c8a33
commit 646fc37daf
6 changed files with 114 additions and 35 deletions

View file

@ -96,22 +96,26 @@ class PreferenceListDossier < ActiveRecord::Base
def self.columns_champs_procedure procedure_id
table = 'champs'
Procedure.find(procedure_id).types_de_champ.inject({}) do |acc, type_de_champ|
acc = acc.merge({
"type_de_champ_#{type_de_champ.id}" => create_column(type_de_champ.libelle, table, type_de_champ.id, 'value', 2)
}) if type_de_champ.field_for_list?
acc
if procedure = Procedure.find_by(id: procedure_id)
procedure.types_de_champ.inject({}) do |acc, type_de_champ|
acc = acc.merge({
"type_de_champ_#{type_de_champ.id}" => create_column(type_de_champ.libelle, table, type_de_champ.id, 'value', 2)
}) if type_de_champ.field_for_list?
acc
end
end
end
def self.columns_champs_private_procedure procedure_id
table = 'champs_private'
Procedure.find(procedure_id).types_de_champ_private.inject({}) do |acc, type_de_champ|
acc = acc.merge({
"type_de_champ_private_#{type_de_champ.id}" => create_column(type_de_champ.libelle, table, type_de_champ.id, 'value', 2)
}) if type_de_champ.field_for_list?
acc
if procedure = Procedure.find_by(id: procedure_id)
procedure.types_de_champ_private.inject({}) do |acc, type_de_champ|
acc = acc.merge({
"type_de_champ_private_#{type_de_champ.id}" => create_column(type_de_champ.libelle, table, type_de_champ.id, 'value', 2)
}) if type_de_champ.field_for_list?
acc
end
end
end
@ -126,4 +130,4 @@ class PreferenceListDossier < ActiveRecord::Base
filter: nil
}
end
end
end

View file

@ -89,20 +89,22 @@ class DossiersListGestionnaireService
def change_page! new_page
pref = current_preference_smart_listing_page
unless pref.liste == @liste && pref.procedure == @procedure
pref.liste = @liste
pref.procedure = @procedure
if pref
unless pref.liste == @liste && pref.procedure == @procedure
pref.liste = @liste
pref.procedure = @procedure
if new_page.nil?
pref.page = 1
if new_page.nil?
pref.page = 1
pref.save
end
end
unless new_page.nil?
pref.page = new_page
pref.save
end
end
unless new_page.nil?
pref.page = new_page
pref.save
end
end
def change_sort! new_sort

View file

@ -30,17 +30,18 @@
%td.col-sm-5.col-md-5.col-lg-5{style: 'vertical-align: top', colspan: (tables.first == :champs ? 2 : 1)}
%h5= tables.first.to_s.gsub('_', ' ').capitalize
%ul
- tables.second.each do |columns|
%li
= form_tag backoffice_preference_list_dossier_add_path, method: :post, remote: true do
= hidden_field_tag :libelle, columns.second[:libelle]
= hidden_field_tag :table, columns.second[:table]
= hidden_field_tag :attr, columns.second[:attr]
= hidden_field_tag :attr_decorate, columns.second[:attr_decorate]
= hidden_field_tag :bootstrap_lg, columns.second[:bootstrap_lg]
= hidden_field_tag :procedure_id, @facade_data_view.procedure_id
- if tables.second
- tables.second.each do |columns|
%li
= form_tag backoffice_preference_list_dossier_add_path, method: :post, remote: true do
= hidden_field_tag :libelle, columns.second[:libelle]
= hidden_field_tag :table, columns.second[:table]
= hidden_field_tag :attr, columns.second[:attr]
= hidden_field_tag :attr_decorate, columns.second[:attr_decorate]
= hidden_field_tag :bootstrap_lg, columns.second[:bootstrap_lg]
= hidden_field_tag :procedure_id, @facade_data_view.procedure_id
= columns.second[:libelle]
%button.btn.btn-default.btn-xs{type: :submit, id: "add_pref_list_#{columns.second[:table]}_#{columns.second[:attr]}"}
%i.fa.fa-plus
= columns.second[:libelle]
%button.btn.btn-default.btn-xs{type: :submit, id: "add_pref_list_#{columns.second[:table]}_#{columns.second[:attr]}"}
%i.fa.fa-plus

View file

@ -0,0 +1,68 @@
require 'spec_helper'
feature 'As an Accompagnateur I can navigate and use each functionnality around procedures and their dossiers', js: true do
let(:user) { create(:user) }
let(:gestionnaire) { create(:gestionnaire) }
let(:procedure_1) { create(:procedure, :with_type_de_champ, libelle: 'procedure 1') }
let(:procedure_2) { create(:procedure, :with_type_de_champ, libelle: 'procedure 2') }
before 'Assign procedures to Accompagnateur and generating dossiers for each' do
create :assign_to, gestionnaire: gestionnaire, procedure: procedure_1
create :assign_to, gestionnaire: gestionnaire, procedure: procedure_2
20.times do
Dossier.create(procedure_id: procedure_1.id.to_s, user: user, state: 'validated')
end
15.times do
Dossier.create(procedure_id: procedure_2.id.to_s, user: user, state: 'validated')
end
login_as gestionnaire, scope: :gestionnaire
visit backoffice_path
end
context 'On index' do
if false
scenario 'Switching between procedures' do
page.all('#procedure_list a').first.click
expect(page).to have_current_path(backoffice_dossiers_procedure_path(id: procedure_1.id.to_s), only_path: true)
expect(page.find('#all_dossiers .count').text).to eq('20 dossiers')
page.all('#procedure_list a').last.click
expect(page).to have_current_path(backoffice_dossiers_procedure_path(id: procedure_2.id.to_s), only_path: true)
expect(page.find('#all_dossiers .count').text).to eq('15 dossiers')
#save_and_open_page
end
scenario 'Searching with search bar' do
page.find_by_id('search_area').trigger('click')
fill_in 'q', with: '15'
page.find_by_id('search_button').click
page.find_by_id('tr_dossier_15').click
expect(page).to have_current_path("/backoffice/dossiers/15")
end
scenario 'Following dossier' do
page.all('#procedure_list a').first.click
expect(page.all('#follow_dossiers .smart-listing')[0]['data-item-count']).to eq ("0")
page.find_by_id('all_dossiers').click
expect(page.all('#dossiers_list a').first.text).to eq('Suivre')
page.all('#dossiers_list a').first.click
expect(page.all('#follow_dossiers .smart-listing')[0]['data-item-count']).to eq ("1")
end
end
scenario 'Using sort' do
end
if false
scenario 'Using pagination' do
end
scenario 'Using filter' do
end
scenario 'Have an export button' do
end
end
end
end

View file

@ -48,4 +48,4 @@ feature 'on backoffice page' do
end
end
end
end
end

View file

@ -41,8 +41,12 @@ feature 'As a User I want to sort and paginate dossiers', js: true do
page.find('.next_page a').click
wait_for_ajax
expect(page.all(:css, '#dossiers_list tr')[1].text.split(" ").first).to eq('15')
page.find('.prev a').click
wait_for_ajax
page.find('.prev a').click
wait_for_ajax
expect(page.all(:css, '#dossiers_list tr')[1].text.split(" ").first).to eq('1')
end
end
end