- Delete routes 'users/dossiers/a_traiter - en_attente - termine' for user

- Add routes 'uses/dossiers/?liste=xxx' to reach at file lists for user
This commit is contained in:
Xavier J 2015-12-02 18:03:52 +01:00
parent 5cebb5b621
commit 3e55d7ba3b
18 changed files with 126 additions and 135 deletions

View file

@ -1,34 +1,35 @@
class Backoffice::DossiersController < ApplicationController
before_action :authenticate_gestionnaire!
def index
if params[:liste] == 'a_traiter' || params[:liste].nil?
@dossiers = current_gestionnaire.dossiers.waiting_for_gestionnaire
@dossiers_a_traiter = @dossiers
@liste = 'a_traiter'
elsif params[:liste] == 'en_attente'
@dossiers = current_gestionnaire.dossiers.waiting_for_user
@dossiers_en_attente = @dossiers
@liste = 'en_attente'
elsif params[:liste] == 'termine'
@dossiers = current_gestionnaire.dossiers.termine
@dossiers_termine = @dossiers
@liste = 'termine'
end
@dossiers = @dossiers.paginate(:page => (params[:page] || 1)).decorate
total_dossiers_per_state
end
def show
initialize_instance_params params[:id]
end
def a_traiter
@dossiers = current_gestionnaire.dossiers.waiting_for_gestionnaire
.paginate(:page => params[:page]).decorate
@page = 'a_traiter'
total_dossiers_per_state
end
def en_attente
@dossiers = current_gestionnaire.dossiers.waiting_for_user()
.paginate(:page => params[:page]).decorate
@page = 'en_attente'
total_dossiers_per_state
end
def termine
@dossiers = current_gestionnaire.dossiers.termine()
.paginate(:page => params[:page]).decorate
@page = 'termine'
total_dossiers_per_state
end
def search
@search_terms = params[:q]

View file

@ -4,7 +4,7 @@ class BackofficeController < ApplicationController
if !gestionnaire_signed_in?
redirect_to(controller: '/gestionnaires/sessions', action: :new)
else
redirect_to(:backoffice_dossiers_a_traiter)
redirect_to(:backoffice_dossiers)
end
end
end

View file

@ -4,7 +4,7 @@ class RootController < ApplicationController
if user_signed_in?
redirect_to users_dossiers_path
elsif gestionnaire_signed_in?
redirect_to backoffice_path
redirect_to backoffice_dossiers_path
elsif administrateur_signed_in?
redirect_to admin_procedures_path
else

View file

@ -3,20 +3,20 @@
#onglets
%ul.nav.nav-tabs
%li{ class: (@dossiers.active_class_a_traiter(@page) unless @dossiers.nil?) }
%a{:href => "#{url_for :backoffice_dossiers_a_traiter}" }
%li{ class: (@dossiers.active_class_a_traiter(@liste) unless @dossiers.nil?) }
%a{:href => "#{url_for backoffice_dossiers_path(liste: 'a_traiter')}"}
%h5.text-danger
= "À traiter "
.badge.progress-bar-danger
=@dossiers_a_traiter_total
%li{ class: (@dossiers.active_class_en_attente(@page) unless @dossiers.nil?) }
%a{:href => "#{url_for :backoffice_dossiers_en_attente}" }
%li{ class: (@dossiers.active_class_en_attente(@liste) unless @dossiers.nil?) }
%a{:href => "#{url_for backoffice_dossiers_path(liste: 'en_attente')}"}
%h5.text-info
="En attente "
.badge.progress-bar-info
=@dossiers_en_attente_total
%li{ class: (@dossiers.active_class_termine(@page) unless @dossiers.nil?) }
%a{ :href => "#{url_for :backoffice_dossiers_termine}" }
%li{ class: (@dossiers.active_class_termine(@liste) unless @dossiers.nil?) }
%a{:href => "#{url_for backoffice_dossiers_path(liste: 'termine')}"}
%h5.text-success
= "Terminé"
.badge.progress-bar-success

View file

@ -1,4 +0,0 @@
#backoffice_a_traiter
= render partial: 'onglets'
= render partial: 'list'

View file

@ -1,4 +0,0 @@
#backoffice_en_attente
= render partial: 'onglets'
= render partial: 'list'

View file

@ -1,4 +1,4 @@
#backoffice_termine
#backoffice_index
= render partial: 'onglets'
= render partial: 'list'

View file

@ -69,9 +69,6 @@ Rails.application.routes.draw do
namespace :backoffice do
get 'sign_in' => '/gestionnaires/sessions#new'
get 'dossiers/a_traiter' => 'dossiers#a_traiter'
get 'dossiers/en_attente' => 'dossiers#en_attente'
get 'dossiers/termine' => 'dossiers#termine'
get 'dossiers/search' => 'dossiers#search'
resources :dossiers do

View file

@ -43,7 +43,7 @@ describe Backoffice::DossiersController, type: :controller do
end
it 'returns http success' do
get :a_traiter
get :index, liste: :a_traiter
expect(response).to have_http_status(200)
end
end
@ -56,7 +56,7 @@ describe Backoffice::DossiersController, type: :controller do
end
it 'returns http success' do
get :en_attente
get :index, liste: :en_attente
expect(response).to have_http_status(200)
end
end
@ -69,7 +69,7 @@ describe Backoffice::DossiersController, type: :controller do
end
it 'returns http success' do
get :termine
get :index, liste: :termine
expect(response).to have_http_status(200)
end
end

View file

@ -16,7 +16,7 @@ describe BackofficeController, type: :controller do
get :index
end
it { expect(response).to redirect_to :backoffice_dossiers_a_traiter }
it { expect(response).to redirect_to :backoffice_dossiers }
end
end
end

View file

@ -17,7 +17,7 @@ describe RootController, type: :controller do
sign_in create(:gestionnaire)
end
it { expect(subject).to redirect_to(backoffice_path) }
it { expect(subject).to redirect_to(backoffice_dossiers_path) }
end
context 'when Administrateur is connected' do

View file

@ -29,7 +29,7 @@ feature 'when gestionnaire come to /backoffice and is not authenticated' do
page.click_on 'Se connecter'
end
scenario 'he is redirected to /backoffice' do
expect(page).to have_css('#backoffice_a_traiter')
expect(page).to have_css('#backoffice_index')
end
end
end

View file

@ -11,34 +11,34 @@ feature 'on click on tabs button' do
context 'when gestionnaire is logged in' do
context 'when he click on tabs a traitee' do
before do
visit backoffice_dossiers_en_attente_url
visit backoffice_dossiers_url(liste: :a_traiter)
page.click_on 'À traiter 0'
end
scenario 'it redirect to backoffice dossier termine' do
expect(page).to have_css('#backoffice_a_traiter')
expect(page).to have_css('#backoffice_index')
end
end
context 'when he click on tabs en attente' do
before do
visit backoffice_dossiers_termine_url
visit backoffice_dossiers_url(liste: :en_attente)
page.click_on 'En attente 0'
end
scenario 'it redirect to backoffice dossier en attente' do
expect(page).to have_css('#backoffice_en_attente')
expect(page).to have_css('#backoffice_index')
end
end
context 'when he click on tabs termine' do
before do
visit backoffice_dossiers_a_traiter_url
visit backoffice_dossiers_url(liste: :termine)
page.click_on 'Terminé 0'
end
scenario 'it redirect to backoffice dossier termine' do
expect(page).to have_css('#backoffice_termine')
expect(page).to have_css('#backoffice_index')
end
end
end

View file

@ -13,7 +13,7 @@ feature 'search file on gestionnaire backoffice' do
let(:terms) { '' }
before do
visit backoffice_dossiers_a_traiter_url
visit backoffice_dossiers_url
page.find_by_id(:q).set terms
page.find_by_id(:search_button).click
end

View file

@ -1,26 +0,0 @@
require 'spec_helper'
describe 'backoffice/dossiers/a_traiter.html.haml', type: :view do
let(:administrateur) { create(:administrateur) }
let(:gestionnaire) { create(:gestionnaire, administrateur: administrateur) }
let!(:procedure) { create(:procedure, administrateur: administrateur) }
let!(:decorate_dossier) { create(:dossier, :with_user, state: 'initiated', procedure: procedure).decorate }
before do
assign(:dossiers, gestionnaire.dossiers.waiting_for_gestionnaire.paginate(:page => 1).decorate)
assign(:page, 'a_traiter')
render
end
subject { rendered }
it { is_expected.to have_css('#backoffice_a_traiter') }
it { is_expected.to have_content(procedure.libelle) }
it { is_expected.to have_content(decorate_dossier.nom_projet) }
it { is_expected.to have_content(decorate_dossier.state_fr) }
it { is_expected.to have_content(decorate_dossier.last_update) }
describe 'active tab' do
it { is_expected.to have_selector('.active .text-danger') }
end
end

View file

@ -1,26 +0,0 @@
require 'spec_helper'
describe 'backoffice/dossiers/en_attente.html.haml', type: :view do
let(:administrateur) { create(:administrateur) }
let(:gestionnaire) { create(:gestionnaire, administrateur: administrateur) }
let!(:procedure) { create(:procedure, administrateur: administrateur) }
let!(:decorate_dossier) { create(:dossier, :with_user, procedure: procedure, state: 'replied').decorate }
before do
assign(:dossiers, gestionnaire.dossiers.waiting_for_user.paginate(:page => 1).decorate)
assign(:page, 'en_attente')
render
end
subject { rendered }
it { is_expected.to have_css('#backoffice_en_attente') }
it { is_expected.to have_content(procedure.libelle) }
it { is_expected.to have_content(decorate_dossier.nom_projet) }
it { is_expected.to have_content(decorate_dossier.state_fr) }
it { is_expected.to have_content(decorate_dossier.last_update) }
describe 'active tab' do
it { is_expected.to have_selector('.active .text-info') }
end
end

View file

@ -0,0 +1,79 @@
require 'spec_helper'
describe 'backoffice/dossiers/index.html.haml', type: :view do
let(:administrateur) { create(:administrateur) }
let(:gestionnaire) { create(:gestionnaire, administrateur: administrateur) }
let!(:procedure) { create(:procedure, administrateur: administrateur) }
let!(:decorate_dossier_initiated) { create(:dossier, :with_user, procedure: procedure, nom_projet: 'projet initiated', state: 'initiated').decorate }
let!(:decorate_dossier_replied) { create(:dossier, :with_user, procedure: procedure, nom_projet: 'projet replied', state: 'replied').decorate }
let!(:decorate_dossier_closed) { create(:dossier, :with_user, procedure: procedure, nom_projet: 'projet closed', state: 'closed').decorate }
describe 'on tab a_traiter' do
before do
assign(:dossiers, gestionnaire.dossiers.waiting_for_gestionnaire.paginate(:page => 1).decorate)
assign(:liste, 'a_traiter')
render
end
subject { rendered }
it { is_expected.to have_css('#backoffice_index') }
it { is_expected.to have_content(procedure.libelle) }
it { is_expected.to have_content(decorate_dossier_initiated.nom_projet) }
it { is_expected.to have_content(decorate_dossier_initiated.state_fr) }
it { is_expected.to have_content(decorate_dossier_initiated.last_update) }
it { is_expected.not_to have_content(decorate_dossier_replied.nom_projet) }
it { is_expected.not_to have_content(decorate_dossier_closed.nom_projet) }
describe 'active tab' do
it { is_expected.to have_selector('.active .text-danger') }
end
end
describe 'on tab en_attente' do
before do
assign(:dossiers, gestionnaire.dossiers.waiting_for_user.paginate(:page => 1).decorate)
assign(:liste, 'en_attente')
render
end
subject { rendered }
it { is_expected.to have_css('#backoffice_index') }
it { is_expected.to have_content(procedure.libelle) }
it { is_expected.to have_content(decorate_dossier_replied.nom_projet) }
it { is_expected.to have_content(decorate_dossier_replied.state_fr) }
it { is_expected.to have_content(decorate_dossier_replied.last_update) }
it { is_expected.not_to have_content(decorate_dossier_initiated.nom_projet) }
it { is_expected.not_to have_content(decorate_dossier_closed.nom_projet) }
describe 'active tab' do
it { is_expected.to have_selector('.active .text-info') }
end
end
describe 'on tab termine' do
before do
assign(:dossiers, gestionnaire.dossiers.termine.paginate(:page => 1).decorate)
assign(:liste, 'termine')
render
end
subject { rendered }
it { is_expected.to have_css('#backoffice_index') }
it { is_expected.to have_content(procedure.libelle) }
it { is_expected.to have_content(decorate_dossier_closed.nom_projet) }
it { is_expected.to have_content(decorate_dossier_closed.state_fr) }
it { is_expected.to have_content(decorate_dossier_closed.last_update) }
it { is_expected.not_to have_content(decorate_dossier_initiated.nom_projet) }
it { is_expected.not_to have_content(decorate_dossier_replied.nom_projet) }
describe 'active tab' do
it { is_expected.to have_selector('.active .text-success') }
end
end
end

View file

@ -1,26 +0,0 @@
require 'spec_helper'
describe 'backoffice/dossiers/termine.html.haml', type: :view do
let(:administrateur) { create(:administrateur) }
let(:gestionnaire) { create(:gestionnaire, administrateur: administrateur) }
let!(:procedure) { create(:procedure, administrateur: administrateur) }
let!(:decorate_dossier) { create(:dossier, :with_user, procedure: procedure, state: 'closed').decorate }
before do
assign(:dossiers, gestionnaire.dossiers.termine.paginate(:page => 1).decorate)
assign(:page, 'termine')
render
end
subject { rendered }
it { is_expected.to have_css('#backoffice_termine') }
it { is_expected.to have_content(procedure.libelle) }
it { is_expected.to have_content(decorate_dossier.nom_projet) }
it { is_expected.to have_content(decorate_dossier.state_fr) }
it { is_expected.to have_content(decorate_dossier.last_update) }
describe 'active tab' do
it { is_expected.to have_selector('.active .text-success') }
end
end