Features tests about user: index of dossiers, sorting and using pagination

This commit is contained in:
JC 2016-12-20 11:58:17 +01:00
parent d67d32e3c2
commit 39a023b3e2
3 changed files with 65 additions and 17 deletions

View file

@ -1,16 +1,16 @@
- unless smart_listing.empty?
%table#dossiers_list.table
%thead
%th.col-md-1.col-lg-1= smart_listing.sortable 'Numéro', 'id'
%th.col-md-5.col-lg-5= smart_listing.sortable 'Procédure', 'procedure.libelle'
%th.col-md-2.col-lg-2= smart_listing.sortable 'État', 'state'
%th.col-md-2.col-lg-2= smart_listing.sortable 'Date de mise à jour', 'updated_at'
%th#sort-id.col-md-1.col-lg-1= smart_listing.sortable 'Numéro', 'id'
%th#sort-libelle.col-md-5.col-lg-5= smart_listing.sortable 'Procédure', 'procedure.libelle'
%th#sort-state.col-md-2.col-lg-2= smart_listing.sortable 'État', 'state'
%th#sort-updated.col-md-2.col-lg-2= smart_listing.sortable 'Date de mise à jour', 'updated_at'
- if @liste == "brouillon"
%th.col-md-2.col-lg-2= 'Action'
- @dossiers.each do |dossier|
- if dossier.kind_of? Invite
-invite = dossier
-dossier = invite.dossier.decorate
- invite = dossier
- dossier = invite.dossier.decorate
- else
- dossier = dossier.decorate

View file

@ -2,20 +2,20 @@ require 'spec_helper'
feature 'As a User I want to edit a dossier I own', js: true do
let(:user) { create(:user) }
let(:user) { create(:user) }
let(:procedure_for_individual) { create(:procedure, :published, :for_individual, :with_api_carto, :with_type_de_champ, :with_two_type_de_piece_justificative) }
before "Create dossier" do
login_as user, scope: :user
visit commencer_path(procedure_path: procedure_for_individual.path)
fill_in 'dossier_individual_attributes_nom', with: 'Nom'
fill_in 'dossier_individual_attributes_prenom', with: 'Prenom'
fill_in 'dossier_individual_attributes_birthdate', with: '14/10/1987'
find(:css, "#dossier_autorisation_donnees[value='1']").set(true)
page.find_by_id('etape_suivante').click
page.find_by_id('etape_suivante').click
page.find_by_id('suivant').click
visit root_path
login_as user, scope: :user
visit commencer_path(procedure_path: procedure_for_individual.path)
fill_in 'dossier_individual_attributes_nom', with: 'Nom'
fill_in 'dossier_individual_attributes_prenom', with: 'Prenom'
fill_in 'dossier_individual_attributes_birthdate', with: '14/10/1987'
find(:css, "#dossier_autorisation_donnees[value='1']").set(true)
page.find_by_id('etape_suivante').click
page.find_by_id('etape_suivante').click
page.find_by_id('suivant').click
visit root_path
end
context 'After sign_in, I can navigate through dossiers indexes and edit a dossier' do

View file

@ -0,0 +1,48 @@
require 'spec_helper'
feature 'As a User I want to sort and paginate dossiers', js: true do
let(:user) { create(:user) }
let(:procedure_for_individual) { create(:procedure, :published, :for_individual) }
before "Create dossier" do
login_as user, scope: :user
visit commencer_path(procedure_path: procedure_for_individual.path)
fill_in 'dossier_individual_attributes_nom', with: 'Nom'
fill_in 'dossier_individual_attributes_prenom', with: 'Prenom'
fill_in 'dossier_individual_attributes_birthdate', with: '14/10/1987'
find(:css, "#dossier_autorisation_donnees[value='1']").set(true)
page.find_by_id('etape_suivante').click
page.find_by_id('suivant').click
50.times do
Dossier.create(procedure_id: 1, user_id: 1, state: "initiated")
end
visit root_path
end
context 'After sign_in, I can see my 51 dossiers on the index' do
scenario 'Using sort' do
expect(page.all(:css, '#dossiers_list tr')[1].text.split(" ").first).to eq('1')
expect(page.all(:css, '#dossiers_list tr')[2].text.split(" ").first).to eq('2')
visit "/users/dossiers?dossiers_smart_listing[sort][id]=desc"
expect(page.all(:css, '#dossiers_list tr')[1].text.split(" ").first).to eq('51')
expect(page.all(:css, '#dossiers_list tr')[2].text.split(" ").first).to eq('50')
visit "/users/dossiers?dossiers_smart_listing[sort][id]=asc"
expect(page.all(:css, '#dossiers_list tr')[1].text.split(" ").first).to eq('1')
expect(page.all(:css, '#dossiers_list tr')[2].text.split(" ").first).to eq('2')
end
scenario 'Using pagination' do
expect(page.all(:css, '#dossiers_list tr')[1].text.split(" ").first).to eq('1')
page.find('.next_page a').click
wait_for_ajax
expect(page.all(:css, '#dossiers_list tr')[1].text.split(" ").first).to eq('8')
page.find('.next_page a').click
wait_for_ajax
expect(page.all(:css, '#dossiers_list tr')[1].text.split(" ").first).to eq('15')
end
end
end