From d2812a4a542d2bee6eac7469702bd7b94951763e Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 3 Jul 2018 13:55:10 +0200 Subject: [PATCH 01/12] Add a confirm before changing dossier state in manager --- app/views/manager/dossiers/show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/manager/dossiers/show.html.erb b/app/views/manager/dossiers/show.html.erb index 4213b3e0d..5ed7252aa 100644 --- a/app/views/manager/dossiers/show.html.erb +++ b/app/views/manager/dossiers/show.html.erb @@ -26,7 +26,7 @@ as well as a link to its edit page.
<% if dossier.termine? %> - <%= link_to 'repasser en instruction', change_state_to_instruction_manager_dossier_path(dossier), method: :post, class: 'button' %> + <%= link_to 'Repasser en instruction', change_state_to_instruction_manager_dossier_path(dossier), method: :post, class: 'button', data: { confirm: "Repasser en instruction ?" } %> <% end %>
From 56987e5147fbf037708e56c3ff2775808cc61d7d Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Tue, 3 Jul 2018 20:18:06 +0200 Subject: [PATCH 02/12] procedures: add tests for new_from_existing --- .../admin/procedures_controller.rb | 8 +++-- .../admin/procedures_controller_spec.rb | 30 +++++++++++++++++++ spec/factories/procedure.rb | 10 +++++++ 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/app/controllers/admin/procedures_controller.rb b/app/controllers/admin/procedures_controller.rb index ae08d5001..ac5cc6a9a 100644 --- a/app/controllers/admin/procedures_controller.rb +++ b/app/controllers/admin/procedures_controller.rb @@ -174,16 +174,18 @@ class Admin::ProceduresController < AdminController redirect_to admin_procedures_path end + SIGNIFICANT_DOSSIERS_THRESHOLD = 30 + def new_from_existing - procedures_with_more_than_30_dossiers_ids = Procedure + significant_procedure_ids = Procedure .publiees_ou_archivees .joins(:dossiers) .group("procedures.id") - .having("count(dossiers.id) > ?", 30) + .having("count(dossiers.id) >= ?", SIGNIFICANT_DOSSIERS_THRESHOLD) .pluck('procedures.id') @grouped_procedures = Procedure - .where(id: procedures_with_more_than_30_dossiers_ids) + .where(id: significant_procedure_ids) .group_by(&:administrateur) .sort_by { |a, _| a.created_at } end diff --git a/spec/controllers/admin/procedures_controller_spec.rb b/spec/controllers/admin/procedures_controller_spec.rb index 33819ca8a..6fe5ebcf2 100644 --- a/spec/controllers/admin/procedures_controller_spec.rb +++ b/spec/controllers/admin/procedures_controller_spec.rb @@ -525,6 +525,36 @@ describe Admin::ProceduresController, type: :controller do end end + describe 'GET #new_from_existing' do + before do + stub_const("Admin::ProceduresController::SIGNIFICANT_DOSSIERS_THRESHOLD", 2) + end + + subject { get :new_from_existing } + let(:grouped_procedures) { subject; assigns(:grouped_procedures) } + let(:response_procedures) { grouped_procedures.map{ |o, procedures| procedures }.flatten } + + describe 'selecting' do + let!(:large_draft_procedure) { create(:procedure_with_dossiers, dossiers_count: 2) } + let!(:large_published_procedure) { create(:procedure_with_dossiers, :published, dossiers_count: 2) } + let!(:large_archived_procedure) { create(:procedure_with_dossiers, :archived, dossiers_count: 2) } + let!(:small_archived_procedure) { create(:procedure_with_dossiers, :archived, dossiers_count: 1) } + + it 'displays published and archived procedures' do + expect(response_procedures).to include(large_published_procedure) + expect(response_procedures).to include(large_archived_procedure) + end + + it 'doesn’t display procedures without a significant number of dossiers' do + expect(response_procedures).not_to include(small_archived_procedure) + end + + it 'doesn’t display draft procedures' do + expect(response_procedures).not_to include(large_draft_procedure) + end + end + end + describe 'GET #path_list' do let!(:procedure) { create(:procedure, :published, administrateur: admin) } let(:admin2) { create(:administrateur) } diff --git a/spec/factories/procedure.rb b/spec/factories/procedure.rb index 79c0eb9e0..0e5b3c413 100644 --- a/spec/factories/procedure.rb +++ b/spec/factories/procedure.rb @@ -12,6 +12,16 @@ FactoryBot.define do duree_conservation_dossiers_dans_ds 3 duree_conservation_dossiers_hors_ds 6 + factory :procedure_with_dossiers do + transient do + dossiers_count 1 + end + + after(:build) do |procedure, _evaluator| + procedure.dossiers << create_list(:dossier, _evaluator.dossiers_count, procedure: procedure) + end + end + after(:build) do |procedure, _evaluator| if procedure.module_api_carto.nil? module_api_carto = create(:module_api_carto) From b0a9e49549abb9f55112a359fc10b871393297d8 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Tue, 3 Jul 2018 20:18:49 +0200 Subject: [PATCH 03/12] procedures: group new_from_existing list by organization As procedures are not grouped by Service (which are unique to an administrator) but by organization, this allows procedures with the same organization name to be displayed together. --- app/controllers/admin/procedures_controller.rb | 4 ++-- app/models/procedure.rb | 4 ++++ .../admin/procedures/new_from_existing.html.haml | 2 +- .../admin/procedures_controller_spec.rb | 14 ++++++++++++++ spec/models/procedure_spec.rb | 13 +++++++++++++ 5 files changed, 34 insertions(+), 3 deletions(-) diff --git a/app/controllers/admin/procedures_controller.rb b/app/controllers/admin/procedures_controller.rb index ac5cc6a9a..a4431cbd7 100644 --- a/app/controllers/admin/procedures_controller.rb +++ b/app/controllers/admin/procedures_controller.rb @@ -186,8 +186,8 @@ class Admin::ProceduresController < AdminController @grouped_procedures = Procedure .where(id: significant_procedure_ids) - .group_by(&:administrateur) - .sort_by { |a, _| a.created_at } + .group_by(&:organisation_name) + .sort_by { |_, procedures| procedures.first.created_at } end def active_class diff --git a/app/models/procedure.rb b/app/models/procedure.rb index f7d7b8a6f..769742d66 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -152,6 +152,10 @@ class Procedure < ApplicationRecord libelle.parameterize.first(50) end + def organisation_name + service&.nom || organisation + end + def types_de_champ_ordered types_de_champ.order(:order_place) end diff --git a/app/views/admin/procedures/new_from_existing.html.haml b/app/views/admin/procedures/new_from_existing.html.haml index 3935e0722..a7996800a 100644 --- a/app/views/admin/procedures/new_from_existing.html.haml +++ b/app/views/admin/procedures/new_from_existing.html.haml @@ -12,7 +12,7 @@ %br - @grouped_procedures.each do |_, procedures| %b - = procedures.first.organisation + = procedures.first.organisation_name %table{ style: 'margin-bottom: 40px;' } - procedures.sort_by(&:id).each do |procedure| %tr{ style: 'height: 36px;' } diff --git a/spec/controllers/admin/procedures_controller_spec.rb b/spec/controllers/admin/procedures_controller_spec.rb index 6fe5ebcf2..3a1f16831 100644 --- a/spec/controllers/admin/procedures_controller_spec.rb +++ b/spec/controllers/admin/procedures_controller_spec.rb @@ -553,6 +553,20 @@ describe Admin::ProceduresController, type: :controller do expect(response_procedures).not_to include(large_draft_procedure) end end + + describe 'grouping' do + let(:service_1) { create(:service, nom: 'DDT des Vosges') } + let(:service_2) { create(:service, nom: 'DDT du Loiret') } + let!(:procedure_with_service_1) { create(:procedure_with_dossiers, :published, organisation: nil, service: service_1, dossiers_count: 2) } + let!(:procedure_with_service_2) { create(:procedure_with_dossiers, :published, organisation: nil, service: service_2, dossiers_count: 2) } + let!(:procedure_without_service) { create(:procedure_with_dossiers, :published, organisation: 'DDT du Loiret', dossiers_count: 2) } + + it 'groups procedures with services as well as procedures with organisations' do + expect(grouped_procedures.length).to eq 2 + expect(grouped_procedures.find{ |o, p| o == 'DDT des Vosges' }.last).to contain_exactly(procedure_with_service_1) + expect(grouped_procedures.find{ |o, p| o == 'DDT du Loiret' }.last).to contain_exactly(procedure_with_service_2, procedure_without_service) + end + end end describe 'GET #path_list' do diff --git a/spec/models/procedure_spec.rb b/spec/models/procedure_spec.rb index 7ff08b45c..010c57760 100644 --- a/spec/models/procedure_spec.rb +++ b/spec/models/procedure_spec.rb @@ -735,6 +735,19 @@ describe Procedure do it { expect(Champ.count).to eq(0) } end + describe "#organisation_name" do + subject { procedure.organisation_name } + context 'when the procedure has a service (and no organization)' do + let(:procedure) { create(:procedure, :with_service, organisation: nil) } + it { is_expected.to eq procedure.service.nom } + end + + context 'when the procedure has an organization (and no service)' do + let(:procedure) { create(:procedure, organisation: 'DDT des Vosges', service: nil) } + it { is_expected.to eq procedure.organisation } + end + end + describe '#juridique_required' do it 'automatically jumps to true once cadre_juridique or deliberation have been set' do p = create( From 592331e9ace887647803741391db803193aeea63 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Tue, 3 Jul 2018 23:55:55 +0200 Subject: [PATCH 04/12] procedures: fix double N+1 requests in new_from_existing --- app/controllers/admin/procedures_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/admin/procedures_controller.rb b/app/controllers/admin/procedures_controller.rb index a4431cbd7..cca29a761 100644 --- a/app/controllers/admin/procedures_controller.rb +++ b/app/controllers/admin/procedures_controller.rb @@ -185,6 +185,7 @@ class Admin::ProceduresController < AdminController .pluck('procedures.id') @grouped_procedures = Procedure + .includes(:administrateur, :service) .where(id: significant_procedure_ids) .group_by(&:organisation_name) .sort_by { |_, procedures| procedures.first.created_at } From 394019b70c5a08f52a626f5185251f2a27f50a76 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Mon, 2 Jul 2018 12:37:41 +0200 Subject: [PATCH 05/12] specs: save a screenshot of failing integration tests --- Gemfile | 8 ++++++-- Gemfile.lock | 4 ++++ spec/spec_helper.rb | 10 ++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 35094dfd9..2b492bc4e 100644 --- a/Gemfile +++ b/Gemfile @@ -124,19 +124,23 @@ gem "administrate" gem 'rack-mini-profiler' group :test do - gem 'capybara' gem 'launchy' gem 'factory_bot' gem 'database_cleaner' gem 'webmock' gem 'shoulda-matchers', require: false - gem 'capybara-selenium' gem 'timecop' gem 'guard' gem 'guard-rspec', require: false gem 'guard-livereload', require: false gem 'vcr' gem 'rails-controller-testing' + + # Integration testing + gem 'capybara' + gem 'capybara-selenium' + # Save a dump of the page when an integration test fails + gem 'capybara-screenshot' end group :development do diff --git a/Gemfile.lock b/Gemfile.lock index 43089c584..e2eae1d09 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -118,6 +118,9 @@ GEM rack (>= 1.0.0) rack-test (>= 0.5.4) xpath (>= 2.0, < 4.0) + capybara-screenshot (1.0.21) + capybara (>= 1.0, < 4) + launchy capybara-selenium (0.0.6) capybara selenium-webdriver @@ -798,6 +801,7 @@ DEPENDENCIES browser byebug capybara + capybara-screenshot capybara-selenium carrierwave carrierwave-i18n diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index e693207dd..9f51925f3 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -22,6 +22,7 @@ ENV['RAILS_ENV'] ||= 'test' require File.expand_path('../config/environment', __dir__) require 'rspec/rails' require 'capybara/rspec' +require 'capybara-screenshot/rspec' require 'database_cleaner' require 'webmock/rspec' require 'shoulda-matchers' @@ -50,6 +51,15 @@ ActiveSupport::Deprecation.silenced = true Capybara.default_max_wait_time = 1 +# Save a snapshot of the HTML page when an integration test fails +Capybara::Screenshot.autosave_on_failure = true +# Keep only the screenshots generated from the last failing test suite +Capybara::Screenshot.prune_strategy = :keep_last_run +# Tell Capybara::Screenshot how to take screenshots when using the headless_chrome driver +Capybara::Screenshot.register_driver :headless_chrome do |driver, path| + driver.browser.save_screenshot(path) +end + # Requires supporting ruby files with custom matchers and macros, etc, # in spec/support/ and its subdirectories. Dir[Rails.root.join('spec', 'support', '**', '*.rb')].each { |f| require f } From 33c743ab772ffba5273246d336a0b368ccf770f6 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Wed, 4 Jul 2018 09:59:35 +0200 Subject: [PATCH 06/12] helper: simplify DossierHelper.url_for_dossier The argument is never an Invite --- app/helpers/dossier_helper.rb | 4 +--- spec/helpers/dossier_helper_spec.rb | 5 ----- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/app/helpers/dossier_helper.rb b/app/helpers/dossier_helper.rb index 9baaf6d16..f6769e34c 100644 --- a/app/helpers/dossier_helper.rb +++ b/app/helpers/dossier_helper.rb @@ -16,9 +16,7 @@ module DossierHelper end def url_for_dossier(dossier) - if dossier.kind_of? Invite - users_dossiers_invite_path(id: dossier.id) - elsif dossier.brouillon? + if dossier.brouillon? modifier_dossier_path(dossier) else users_dossier_recapitulatif_path(dossier) diff --git a/spec/helpers/dossier_helper_spec.rb b/spec/helpers/dossier_helper_spec.rb index c2aa7d0d4..9d12f985a 100644 --- a/spec/helpers/dossier_helper_spec.rb +++ b/spec/helpers/dossier_helper_spec.rb @@ -29,11 +29,6 @@ RSpec.describe DossierHelper, type: :helper do describe ".url_for_dossier" do subject { url_for_dossier(dossier) } - context "when the dossier is an invitation" do - let(:dossier) { create(:invite) } - it { is_expected.to eq "/users/dossiers/invites/#{dossier.id}" } - end - context "when the dossier is in the brouillon state" do let(:dossier) { create(:dossier, state: 'brouillon') } it { is_expected.to eq "/dossiers/#{dossier.id}/modifier" } From f10205e3f50cd7e373f0f473d54f7bec1fac799b Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Mon, 2 Jul 2018 14:16:16 +0200 Subject: [PATCH 07/12] dossiers: improve empty state wording --- app/views/new_user/dossiers/index.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/new_user/dossiers/index.html.haml b/app/views/new_user/dossiers/index.html.haml index 84576f3e6..f2de5783f 100644 --- a/app/views/new_user/dossiers/index.html.haml +++ b/app/views/new_user/dossiers/index.html.haml @@ -56,5 +56,5 @@ - else .dossiers-table-empty %h2.empty-text Aucun dossier. - %p.empty-text-details Pour l’instant vous n’avez commencé aucune démarche. + %p.empty-text-details Vous n’avez pas encore commencé de démarche. = link_to "Commencer une nouvelle démarche", new_demarche_url, class: "button primary" From 4ab5d300449f689d9313b01a788da36994cb9f7c Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Wed, 4 Jul 2018 11:49:24 +0200 Subject: [PATCH 08/12] dossiers: move the index method to the top of the controller --- .../new_user/dossiers_controller.rb | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/app/controllers/new_user/dossiers_controller.rb b/app/controllers/new_user/dossiers_controller.rb index df860054b..971c471dd 100644 --- a/app/controllers/new_user/dossiers_controller.rb +++ b/app/controllers/new_user/dossiers_controller.rb @@ -7,6 +7,20 @@ module NewUser before_action :ensure_dossier_can_be_updated, only: [:update_identite, :update] before_action :forbid_invite_submission!, only: [:update] + def index + @user_dossiers = current_user.dossiers.includes(:procedure).order_by_updated_at.page(page) + @dossiers_invites = current_user.dossiers_invites.includes(:procedure).order_by_updated_at.page(page) + + @current_tab = current_tab(@user_dossiers.count, @dossiers_invites.count) + + @dossiers = case @current_tab + when 'mes-dossiers' + @user_dossiers + when 'dossiers-invites' + @dossiers_invites + end + end + def attestation send_data(dossier.attestation.pdf.read, filename: 'attestation.pdf', type: 'application/pdf') end @@ -87,20 +101,6 @@ module NewUser @dossier = current_user.dossiers.includes(:procedure).find(params[:id]) end - def index - @user_dossiers = current_user.dossiers.includes(:procedure).order_by_updated_at.page(page) - @dossiers_invites = current_user.dossiers_invites.includes(:procedure).order_by_updated_at.page(page) - - @current_tab = current_tab(@user_dossiers.count, @dossiers_invites.count) - - @dossiers = case @current_tab - when 'mes-dossiers' - @user_dossiers - when 'dossiers-invites' - @dossiers_invites - end - end - def ask_deletion dossier = current_user.dossiers.includes(:user, procedure: :administrateur).find(params[:id]) From 0b474a5b32de53f24412b2e0a87f1cffcefa2961 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Wed, 4 Jul 2018 11:23:09 +0200 Subject: [PATCH 09/12] admin: explain purpose of the /admin/gestionnaires page --- app/views/admin/gestionnaires/index.html.haml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/views/admin/gestionnaires/index.html.haml b/app/views/admin/gestionnaires/index.html.haml index 13efab7f2..ea6ff62b4 100644 --- a/app/views/admin/gestionnaires/index.html.haml +++ b/app/views/admin/gestionnaires/index.html.haml @@ -1,8 +1,17 @@ -%h1 Gestion des accompagnateurs -%br +%h1 Accompagnateurs disponibles + +%p + Cette page vous permet de gérer la liste des accompagnateurs disponibles pour être affectés à une procédure. + +%p{ style: 'font-style: italic' } + N.B. : cette page ne concerne que la liste des personnes disponibles. Si vous souhaitez affecter ou enlever un accompagnateur d'une procédure particulière, + utilisez plutôt la + = link_to "page de la procédure", admin_procedures_path + concernée. .row .col-xs-4 + = smart_listing_render :gestionnaires .col-xs-1   From d7b54abd3720c0cb6d2d672693bfae46926c4f5f Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Mon, 2 Jul 2018 17:34:39 +0200 Subject: [PATCH 10/12] auth: add vertical spacing to the procedure description Fix #2174 --- app/assets/stylesheets/new_design/auth.scss | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/assets/stylesheets/new_design/auth.scss b/app/assets/stylesheets/new_design/auth.scss index 78d1c3e47..0660c050f 100644 --- a/app/assets/stylesheets/new_design/auth.scss +++ b/app/assets/stylesheets/new_design/auth.scss @@ -38,6 +38,10 @@ $auth-breakpoint: $two-columns-breakpoint; .procedure-description { font-size: 14px; + p { + margin-bottom: 2 * $default-spacer; + } + @media (max-width: $auth-breakpoint) { display: none; // TO FIX : make this description available for small devices } From 0aa2c1d9f694ffee47e75b62f9795eca63db4b57 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Tue, 3 Jul 2018 11:35:32 +0000 Subject: [PATCH 11/12] routes: redirect `/users/dossiers` to `/dossiers` --- config/routes.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/config/routes.rb b/config/routes.rb index b6617d7c8..9e0ca185a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -125,7 +125,11 @@ Rails.application.routes.draw do get 'text_summary' => 'dossiers#text_summary' end - resource :dossiers + + resource 'dossiers' + + # Redirection of legacy "/users/dossiers" route to "/dossiers" + get 'dossiers', to: redirect('/dossiers') end namespace :gestionnaire do From f5d3adba5e8452088ac7aa5edc4e8ace48c0a3c2 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Mon, 25 Jun 2018 13:33:57 +0000 Subject: [PATCH 12/12] dossiers: remove unused dossiers list code This code is unused since the user dossiers list uses the new UI. --- app/assets/stylesheets/users.scss | 1 - app/controllers/users/dossiers_controller.rb | 26 ------ app/views/users/dossiers/_list.html.haml | 38 -------- .../dossiers/_state_description.html.haml | 52 ----------- app/views/users/dossiers/index.html.haml | 15 --- app/views/users/dossiers/index.js.erb | 2 - .../users/dossiers_controller_spec.rb | 78 ---------------- spec/features/users/dossier_index_spec.rb | 47 ---------- spec/features/users/onglets_link_spec.rb | 65 ------------- .../users/dossiers/index_html.haml_spec.rb | 93 ------------------- 10 files changed, 417 deletions(-) delete mode 100644 app/views/users/dossiers/_list.html.haml delete mode 100644 app/views/users/dossiers/_state_description.html.haml delete mode 100644 app/views/users/dossiers/index.html.haml delete mode 100644 app/views/users/dossiers/index.js.erb delete mode 100644 spec/features/users/dossier_index_spec.rb delete mode 100644 spec/features/users/onglets_link_spec.rb delete mode 100644 spec/views/users/dossiers/index_html.haml_spec.rb diff --git a/app/assets/stylesheets/users.scss b/app/assets/stylesheets/users.scss index 426928e73..44711bb6f 100644 --- a/app/assets/stylesheets/users.scss +++ b/app/assets/stylesheets/users.scss @@ -1,6 +1,5 @@ @import "constants"; -#users-index, #admins-index { margin-left: 2rem; margin-right: 2rem; diff --git a/app/controllers/users/dossiers_controller.rb b/app/controllers/users/dossiers_controller.rb index 46e1e5b98..2cfe9b93e 100644 --- a/app/controllers/users/dossiers_controller.rb +++ b/app/controllers/users/dossiers_controller.rb @@ -12,32 +12,6 @@ class Users::DossiersController < UsersController authorized_routes? self.class end - def index - @liste ||= params[:liste] || 'a_traiter' - - @user_dossiers = current_user.dossiers - - @dossiers_filtered = case @liste - when 'brouillon' - @user_dossiers.state_brouillon.order_by_updated_at - when 'a_traiter' - @user_dossiers.state_en_construction.order_by_updated_at - when 'en_instruction' - @user_dossiers.state_en_instruction.order_by_updated_at - when 'termine' - @user_dossiers.state_termine.order_by_updated_at - when 'invite' - current_user.invites - else - return redirect_to users_dossiers_path - end - - @dossiers = smart_listing_create :dossiers, - @dossiers_filtered, - partial: "users/dossiers/list", - array: true - end - def commencer_test procedure_path = ProcedurePath.find_by(path: params[:procedure_path]) procedure = procedure_path&.test_procedure diff --git a/app/views/users/dossiers/_list.html.haml b/app/views/users/dossiers/_list.html.haml deleted file mode 100644 index 32eeb0b42..000000000 --- a/app/views/users/dossiers/_list.html.haml +++ /dev/null @@ -1,38 +0,0 @@ -- if smart_listing.present? - %table#dossiers-list.table - %thead - %th#sort-id.col-md-1.col-lg-1.col-sm-1.col-xs-1= smart_listing.sortable 'Numéro', 'id' - %th#sort-libelle.col-xs-5= smart_listing.sortable 'Procédure', 'procedure.libelle' - %th#sort-state.col-xs-2= smart_listing.sortable 'État', 'state' - %th#sort-updated.col-xs-2= smart_listing.sortable 'Date de mise à jour', 'updated_at' - - if @liste == "brouillon" - %th.col-xs-2= 'Action' - - @dossiers.each do |dossier| - - if dossier.kind_of? Invite - - invite = dossier - - dossier = invite.dossier.decorate - - else - - dossier = dossier.decorate - - - dossier_url = users_dossiers_invite_path(id: invite.id) if invite.present? - - if invite.nil? - - dossier_url = users_dossier_recapitulatif_path(dossier) if !dossier.brouillon? - - dossier_url = modifier_dossier_path(dossier) if dossier.brouillon? - - %tr{ id: "tr_dossier_#{dossier.id}", 'data-dossier_url' => dossier_url } - %td.center - = dossier.id - %td - = dossier.procedure.libelle - - %td{ id: "dossier_#{dossier.id}_state" }= dossier.display_state - %td= dossier.last_update - %td= link_to('X', url_for(controller: 'dossiers', action: :destroy, id: dossier.id), 'data-confirm' => "Voulez-vous supprimer le brouillon ?", 'data-method' => :delete, class: 'btn-sm btn-danger') if @liste == "brouillon" - - = smart_listing.paginate - = smart_listing.pagination_per_page_links - %br - -- else - %h4.center - Aucun dossier diff --git a/app/views/users/dossiers/_state_description.html.haml b/app/views/users/dossiers/_state_description.html.haml deleted file mode 100644 index 105ca1197..000000000 --- a/app/views/users/dossiers/_state_description.html.haml +++ /dev/null @@ -1,52 +0,0 @@ -#state_description.row{ style: 'width: 55%; margin-left: auto; margin-right: auto;' } - .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 - - case liste - - when 'brouillon' - Les dossiers présents dans cette liste - %b - n'ont pas encore été soumis aux services instructeurs. - Ils ne sont visibles que par vous. - - when 'nouveaux' - Les dossiers présents dans cette liste - %b - n'ont pas encore été ouverts - par les services instructeurs. Une notification vous sera envoyée quand votre demande aura été étudiée. - - when 'a_traiter' - Les dossiers présents dans cette liste sont - %b - visibles par les services instructeurs. - %br - Ces dossiers ne sont pas encore figés et peuvent être modifiés à souhait. - - when 'en_attente' - Les dossiers présents dans cette liste sont - %b - en cours de relecture par le service instructeur. - Il reviendra vers vous si des informations ou documents sont manquants pour le futur examen de votre dossier. - - when 'valides' - Les dossiers présents dans cette liste ont été - %b - relus et considérés comme complets - pour examen par les services instructeurs. Ceux-ci ne peuvent maintenant plus être modifiés. Il faut que vous procédiez à leur dépôt afin qu'une décision finale soit rendue. - - when 'en_instruction' - Les dossiers présents dans cette liste sont - %b - en cours de réception - ou - %b - en cours d'examen - par les services instructeurs. Une notification vous sera envoyée une fois qu'une décision aura été rendue. - - when 'termine' - Les dossiers présents dans cette liste sont ceux qui ont été instruits et pour lesquels - %b - une décision finale a été rendue. - Ils peuvent posséder trois états différents : Accepté, Refusé ou Sans Suite. - - when 'invite' - Les dossiers présents dans cette liste sont ceux - %b - auxquels vous avez été invités - à participer afin d'émettre un avis ou de fournir des documents complémentaires. diff --git a/app/views/users/dossiers/index.html.haml b/app/views/users/dossiers/index.html.haml deleted file mode 100644 index 77f085261..000000000 --- a/app/views/users/dossiers/index.html.haml +++ /dev/null @@ -1,15 +0,0 @@ -#users-index - .default-data-block.default_visible - .row.show-block#new_dossiers - .header - .col-lg-10.col-md-10.col-sm-10.col-xs-10.title - .carret-right - .carret-down - Dossiers - .col-lg-2.col-md-2.col-sm-2.col-xs-2.count - -# 0 - -# dossiers - .body - = smart_listing_render :dossiers - - = render partial: 'state_description', locals: { liste: @liste } diff --git a/app/views/users/dossiers/index.js.erb b/app/views/users/dossiers/index.js.erb deleted file mode 100644 index 5a2505268..000000000 --- a/app/views/users/dossiers/index.js.erb +++ /dev/null @@ -1,2 +0,0 @@ -<%= smart_listing_update :dossiers %> -link_init(); \ No newline at end of file diff --git a/spec/controllers/users/dossiers_controller_spec.rb b/spec/controllers/users/dossiers_controller_spec.rb index 1d2ff4572..47929d412 100644 --- a/spec/controllers/users/dossiers_controller_spec.rb +++ b/spec/controllers/users/dossiers_controller_spec.rb @@ -427,84 +427,6 @@ describe Users::DossiersController, type: :controller do end end - describe 'GET #a_traiter' do - context 'when user is connected' do - before do - sign_in user - end - - it 'returns http success' do - get :index, params: { liste: :a_traiter } - expect(response).to have_http_status(200) - end - end - end - - describe 'GET #en_instruction' do - context 'when user is connected' do - before do - sign_in user - end - - it 'returns http success' do - get :index, params: { liste: :en_instruction } - expect(response).to have_http_status(200) - end - end - end - - describe 'GET #brouillon' do - context 'when user is connected' do - before do - sign_in user - end - - it 'returns http success' do - get :index, params: { liste: :brouillon } - expect(response).to have_http_status(200) - end - end - end - - describe 'GET #termine' do - context 'when user is connected' do - before do - sign_in user - end - - it 'returns http success' do - get :index, params: { liste: :termine } - expect(response).to have_http_status(200) - end - end - end - - describe 'GET #invite' do - context 'when user is connected' do - before do - sign_in user - end - - it 'returns http success' do - get :index, params: { liste: :invite } - expect(response).to have_http_status(200) - end - end - end - - describe 'GET #list_fake' do - context 'when user is connected' do - before do - sign_in user - end - - it 'returns http success' do - get :index, params: { liste: :list_fake } - expect(response).to redirect_to(users_dossiers_path) - end - end - end - describe 'Get #text_summary' do let!(:dossier) { create(:dossier, procedure: procedure) } diff --git a/spec/features/users/dossier_index_spec.rb b/spec/features/users/dossier_index_spec.rb deleted file mode 100644 index c89385017..000000000 --- a/spec/features/users/dossier_index_spec.rb +++ /dev/null @@ -1,47 +0,0 @@ -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, ask_birthday: true) } - - before "Create dossier" do - login_as user, scope: :user - - 50.times do - Dossier.create(procedure_id: procedure_for_individual.id, user_id: user.id, state: "en_construction") - end - - visit root_path - end - - context 'After sign_in, I can see my 51 dossiers on the index' do - scenario 'Using sort' do - visit "/users/dossiers?dossiers_smart_listing[sort][id]=asc" - expect(page.all(:css, '#dossiers-list tr')[1].text.split(" ").first).to eq(user.dossiers.first.id.to_s) - expect(page.all(:css, '#dossiers-list tr')[2].text.split(" ").first).to eq(user.dossiers.second.id.to_s) - visit "/users/dossiers?dossiers_smart_listing[sort][id]=desc" - expect(page.all(:css, '#dossiers-list tr')[1].text.split(" ").first).to eq((user.dossiers.first.id + 49).to_s) - expect(page.all(:css, '#dossiers-list tr')[2].text.split(" ").first).to eq((user.dossiers.first.id + 48).to_s) - visit "/users/dossiers?dossiers_smart_listing[sort][id]=asc" - expect(page.all(:css, '#dossiers-list tr')[1].text.split(" ").first).to eq(user.dossiers.first.id.to_s) - expect(page.all(:css, '#dossiers-list tr')[2].text.split(" ").first).to eq(user.dossiers.second.id.to_s) - end - - # This test always fail with ajax timeout error... - # scenario 'Using pagination' do - # visit "/users/dossiers?dossiers_smart_listing[sort][id]=asc" - # expect(page.all(:css, '#dossiers-list tr')[1].text.split(" ").first).to eq(user.dossiers.first.id.to_s) - # page.find('.next_page a').click - # wait_for_ajax - # expect(page.all(:css, '#dossiers-list tr')[1].text.split(" ").first).to eq((user.dossiers.first.id + 10).to_s) - # page.find('.next_page a').click - # wait_for_ajax - # expect(page.all(:css, '#dossiers-list tr')[1].text.split(" ").first).to eq((user.dossiers.first.id + 20).to_s) - # 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((user.dossiers.first.id).to_s) - # end - end -end diff --git a/spec/features/users/onglets_link_spec.rb b/spec/features/users/onglets_link_spec.rb deleted file mode 100644 index 71404d8f4..000000000 --- a/spec/features/users/onglets_link_spec.rb +++ /dev/null @@ -1,65 +0,0 @@ -require 'spec_helper' - -feature 'on click on tabs button' do - let(:user) { create :user } - - let(:dossier_invite) { create(:dossier, :with_entreprise, user: create(:user), state: 'en_construction') } - - before do - create(:dossier, :with_entreprise, user: user, state: 'en_construction') - create(:dossier, :with_entreprise, user: user, state: 'en_instruction') - create(:dossier, :with_entreprise, user: user, state: 'accepte') - create(:dossier, :with_entreprise, user: user, state: 'refuse') - create(:dossier, :with_entreprise, user: user, state: 'sans_suite') - - create :invite, dossier: dossier_invite, user: user - - login_as user, scope: :user - end - - context 'when user is logged in' do - context 'when he click on tabs en construction' do - before do - visit users_dossiers_url(liste: :a_traiter) - page.click_on 'En construction 1' - end - - scenario 'it redirect to users dossier termine' do - expect(page).to have_css('#users-index') - end - end - - context 'when he click on tabs en examen' do - before do - visit users_dossiers_url(liste: :en_instruction) - page.click_on 'En instruction 1' - end - - scenario 'it redirect to users dossier termine' do - expect(page).to have_css('#users-index') - end - end - - context 'when he click on tabs termine' do - before do - visit users_dossiers_url(liste: :termine) - page.click_on 'Terminé 3' - end - - scenario 'it redirect to users dossier termine' do - expect(page).to have_css('#users-index') - end - end - - context 'when he click on tabs invitation' do - before do - visit users_dossiers_url(liste: :invite) - page.click_on 'Invitation 1' - end - - scenario 'it redirect to users dossier invites' do - expect(page).to have_css('#users-index') - end - end - end -end diff --git a/spec/views/users/dossiers/index_html.haml_spec.rb b/spec/views/users/dossiers/index_html.haml_spec.rb deleted file mode 100644 index 382248f3f..000000000 --- a/spec/views/users/dossiers/index_html.haml_spec.rb +++ /dev/null @@ -1,93 +0,0 @@ -require 'spec_helper' - -describe 'users/dossiers/index.html.haml', type: :view do - let(:user) { create(:user) } - - let!(:decorate_dossier_en_construction) { create(:dossier, :with_entreprise, user: user, state: 'en_construction').decorate } - let!(:decorate_dossier_en_instruction) { create(:dossier, :with_entreprise, user: user, state: 'en_instruction').decorate } - let!(:decorate_dossier_accepte) { create(:dossier, :with_entreprise, user: user, state: 'accepte').decorate } - let!(:decorate_dossier_refuse) { create(:dossier, :with_entreprise, user: user, state: 'refuse').decorate } - let!(:decorate_dossier_sans_suite) { create(:dossier, :with_entreprise, user: user, state: 'sans_suite').decorate } - let!(:decorate_dossier_invite) { create(:dossier, :with_entreprise, user: create(:user), state: 'en_construction').decorate } - - before do - create :invite, dossier: decorate_dossier_invite, user: user - end - - shared_examples 'check_tab_content' do - before do - sign_in user - - assign(:dossiers, (smart_listing_create :dossiers, - dossiers_to_display, - partial: "users/dossiers/list", - array: true)) - render - end - - subject { rendered } - - it 'displays the total count' do - expect(dossiers_to_display.count).to eq total_dossiers - end - - it 'displays data in columns' do - expect(rendered).to have_content(decorate_dossier_at_check.id) - expect(rendered).to have_content(decorate_dossier_at_check.procedure.libelle) - expect(rendered).to have_content(decorate_dossier_at_check.display_state) - expect(rendered).to have_content(decorate_dossier_at_check.last_update) - end - end - - describe 'on tab en construction' do - let(:total_dossiers) { 1 } - let(:active_class) { '.active .text-danger' } - let(:dossiers_to_display) { user.dossiers.state_en_construction } - let(:liste) { 'a_traiter' } - - it_behaves_like 'check_tab_content' do - let(:decorate_dossier_at_check) { decorate_dossier_en_construction } - end - end - - describe 'on tab etude en examen' do - let(:total_dossiers) { 1 } - let(:active_class) { '.active .text-default' } - let(:dossiers_to_display) { user.dossiers.state_en_instruction } - let(:liste) { 'en_instruction' } - - it_behaves_like 'check_tab_content' do - let(:decorate_dossier_at_check) { decorate_dossier_en_instruction } - end - end - - describe 'on tab etude termine' do - let(:total_dossiers) { 3 } - let(:active_class) { '.active .text-success' } - let(:dossiers_to_display) { user.dossiers.state_termine } - let(:liste) { 'termine' } - - it_behaves_like 'check_tab_content' do - let(:decorate_dossier_at_check) { decorate_dossier_accepte } - end - - it_behaves_like 'check_tab_content' do - let(:decorate_dossier_at_check) { decorate_dossier_refuse } - end - - it_behaves_like 'check_tab_content' do - let(:decorate_dossier_at_check) { decorate_dossier_sans_suite } - end - end - - describe 'on tab etude invite' do - let(:total_dossiers) { 1 } - let(:active_class) { '.active .text-warning' } - let(:dossiers_to_display) { user.invites } - let(:liste) { 'invite' } - - it_behaves_like 'check_tab_content' do - let(:decorate_dossier_at_check) { decorate_dossier_invite } - end - end -end