Gestionnaire: refactor follow?
This commit is contained in:
parent
8fdc16d89f
commit
033f08524f
4 changed files with 5 additions and 7 deletions
|
@ -45,10 +45,8 @@ class Gestionnaire < ActiveRecord::Base
|
|||
nil
|
||||
end
|
||||
|
||||
def follow? dossier_id
|
||||
dossier_id = dossier_id.id if dossier_id.class == Dossier
|
||||
|
||||
Follow.where(gestionnaire_id: id, dossier_id: dossier_id).any?
|
||||
def follow?(dossier)
|
||||
followed_dossiers.include?(dossier)
|
||||
end
|
||||
|
||||
def assigned_on_procedure?(procedure_id)
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
= value
|
||||
|
||||
%td.center
|
||||
- if current_gestionnaire.follow?(dossier.id)
|
||||
- if current_gestionnaire.follow?(dossier)
|
||||
= link_to('Quitter', backoffice_dossier_follow_path(dossier_id: dossier.id), 'data-method' => :put, class: 'btn-sm btn-danger', id: "suivre_dossier_#{dossier.id}")
|
||||
- else
|
||||
= link_to('Suivre', backoffice_dossier_follow_path(dossier_id: dossier.id), 'data-method' => :put, class: 'btn-sm btn-primary', id: "suivre_dossier_#{dossier.id}")
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
- if current_gestionnaire.assigned_on_procedure?(@facade.dossier.procedure_id)
|
||||
.row
|
||||
.col-xs-12
|
||||
- if current_gestionnaire.follow?(@facade.dossier.id)
|
||||
- if current_gestionnaire.follow?(@facade.dossier)
|
||||
= link_to backoffice_dossier_follow_path(dossier_id: @facade.dossier.id), "data-method" => :put, class: "button-navbar-action", id: "suivre_dossier_#{@facade.dossier.id}" do
|
||||
%i.fa.fa-user-times
|
||||
Ne plus suivre
|
||||
|
|
|
@ -76,7 +76,7 @@ describe Gestionnaire, type: :model do
|
|||
describe '#follow?' do
|
||||
let!(:dossier) { create :dossier, procedure: procedure }
|
||||
|
||||
subject { gestionnaire.follow? dossier.id }
|
||||
subject { gestionnaire.follow?(dossier) }
|
||||
|
||||
context 'when gestionnaire follow a dossier' do
|
||||
before do
|
||||
|
|
Loading…
Reference in a new issue