Past all notification to read when gestionnaire is on back office dossier show
This commit is contained in:
parent
cea14845d2
commit
4d765d3b46
3 changed files with 22 additions and 13 deletions
|
@ -19,6 +19,7 @@ class Backoffice::DossiersController < Backoffice::DossiersListController
|
||||||
|
|
||||||
def show
|
def show
|
||||||
create_dossier_facade params[:id]
|
create_dossier_facade params[:id]
|
||||||
|
|
||||||
unless @facade.nil?
|
unless @facade.nil?
|
||||||
@champs_private = @facade.champs_private
|
@champs_private = @facade.champs_private
|
||||||
|
|
||||||
|
@ -27,6 +28,8 @@ class Backoffice::DossiersController < Backoffice::DossiersListController
|
||||||
acc
|
acc
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Notification.where(dossier_id: params[:id].to_i).update_all already_read: true
|
||||||
end
|
end
|
||||||
|
|
||||||
def filter
|
def filter
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
%tr.dossier-row{id: "tr_dossier_#{dossier.id}", 'data-dossier_url' => backoffice_dossier_url(id: dossier.id)}
|
%tr.dossier-row{id: "tr_dossier_#{dossier.id}", 'data-dossier_url' => backoffice_dossier_url(id: dossier.id)}
|
||||||
- if smart_listing.name.to_s == 'follow_dossiers'
|
- if smart_listing.name.to_s == 'follow_dossiers'
|
||||||
%td.center
|
%td.center
|
||||||
- total_notif = dossier.notifications.count
|
- total_notif = dossier.notifications.where(already_read: false).count
|
||||||
- if total_notif == 0
|
- if total_notif == 0
|
||||||
.badge.progress-bar-default
|
.badge.progress-bar-default
|
||||||
= total_notif
|
= total_notif
|
||||||
|
|
|
@ -38,34 +38,40 @@ describe Backoffice::DossiersController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'GET #show' do
|
describe 'GET #show' do
|
||||||
|
subject { get :show, params: {id: dossier_id} }
|
||||||
|
|
||||||
context 'gestionnaire is connected' do
|
context 'gestionnaire is connected' do
|
||||||
before do
|
before do
|
||||||
sign_in gestionnaire
|
sign_in gestionnaire
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns http success' do
|
it 'returns http success' do
|
||||||
get :show, params: {id: dossier_id}
|
expect(subject).to have_http_status(200)
|
||||||
expect(response).to have_http_status(200)
|
end
|
||||||
|
|
||||||
|
describe 'all notifications unread are changed' do
|
||||||
|
it do
|
||||||
|
expect(Notification).to receive(:where).with(dossier_id: dossier_id).and_return(Notification::ActiveRecord_Relation)
|
||||||
|
expect(Notification::ActiveRecord_Relation).to receive(:update_all).with(already_read: true).and_return(true)
|
||||||
|
|
||||||
|
subject
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context ' when dossier is archived' do
|
context ' when dossier is archived' do
|
||||||
before do
|
let(:dossier_id) { dossier_archived }
|
||||||
get :show, params: {id: dossier_archived.id}
|
|
||||||
end
|
it { expect(subject).to redirect_to('/backoffice') }
|
||||||
it { expect(response).to redirect_to('/backoffice') }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when dossier id does not exist' do
|
context 'when dossier id does not exist' do
|
||||||
before do
|
let(:dossier_id) { bad_dossier_id }
|
||||||
get :show, params: {id: bad_dossier_id}
|
|
||||||
end
|
it { expect(subject).to redirect_to('/backoffice') }
|
||||||
it { expect(response).to redirect_to('/backoffice') }
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'gestionnaire does not connected but dossier id is correct' do
|
context 'gestionnaire does not connected but dossier id is correct' do
|
||||||
subject { get :show, params: {id: dossier_id} }
|
|
||||||
|
|
||||||
it { is_expected.to redirect_to('/gestionnaires/sign_in') }
|
it { is_expected.to redirect_to('/gestionnaires/sign_in') }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue