remove email_notifications_enabled column because of the new daily_email_notifications_enabled
This commit is contained in:
parent
4934a6359b
commit
4a70a7fcc8
9 changed files with 14 additions and 16 deletions
|
@ -232,7 +232,6 @@ module Instructeurs
|
|||
|
||||
def update_email_notifications
|
||||
assign_to.update!(assign_to_params)
|
||||
assign_to.update!(daily_email_notifications_enabled: params[:assign_to][:email_notifications_enabled])
|
||||
flash.notice = 'Vos notifications sont enregistrées.'
|
||||
redirect_to instructeur_procedure_path(procedure)
|
||||
end
|
||||
|
@ -247,7 +246,7 @@ module Instructeurs
|
|||
private
|
||||
|
||||
def assign_to_params
|
||||
params.require(:assign_to).permit(:email_notifications_enabled, :weekly_email_notifications_enabled)
|
||||
params.require(:assign_to).permit(:daily_email_notifications_enabled, :weekly_email_notifications_enabled)
|
||||
end
|
||||
|
||||
def assign_exports
|
||||
|
|
|
@ -3,13 +3,8 @@ class AssignTo < ApplicationRecord
|
|||
belongs_to :groupe_instructeur
|
||||
has_one :procedure_presentation, dependent: :destroy
|
||||
has_one :procedure, through: :groupe_instructeur
|
||||
before_save :save_to_new_daily_email_column
|
||||
|
||||
scope :with_email_notifications, -> { where(email_notifications_enabled: true) }
|
||||
|
||||
def save_to_new_daily_email_column
|
||||
self.daily_email_notifications_enabled = email_notifications_enabled
|
||||
end
|
||||
scope :with_email_notifications, -> { where(daily_email_notifications_enabled: true) }
|
||||
|
||||
def procedure_presentation_or_default_and_errors
|
||||
errors = reset_procedure_presentation_if_invalid
|
||||
|
|
|
@ -3,7 +3,7 @@ class NotificationService
|
|||
def send_instructeur_email_notification
|
||||
Instructeur
|
||||
.includes(assign_to: { procedure: :dossiers })
|
||||
.where(assign_tos: { email_notifications_enabled: true })
|
||||
.where(assign_tos: { daily_email_notifications_enabled: true })
|
||||
.find_in_batches { |instructeurs| send_batch_of_instructeurs_email_notification(instructeurs) }
|
||||
end
|
||||
|
||||
|
|
|
@ -20,11 +20,11 @@
|
|||
|
||||
.radios
|
||||
%label
|
||||
= form.radio_button :email_notifications_enabled, true
|
||||
= form.radio_button :daily_email_notifications_enabled, true
|
||||
Oui
|
||||
|
||||
%label
|
||||
= form.radio_button :email_notifications_enabled, false
|
||||
= form.radio_button :daily_email_notifications_enabled, false
|
||||
Non
|
||||
|
||||
= form.label :email_notification, "Recevoir un récapitulatif hebdomadaire"
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class RemoveEmailNotificationsEnabledFromAssignTos < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
remove_column :assign_tos, :email_notifications_enabled
|
||||
end
|
||||
end
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2020_02_18_144724) do
|
||||
ActiveRecord::Schema.define(version: 2020_02_27_100001) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -100,7 +100,6 @@ ActiveRecord::Schema.define(version: 2020_02_18_144724) do
|
|||
t.integer "procedure_id"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.boolean "email_notifications_enabled", default: false, null: false
|
||||
t.bigint "groupe_instructeur_id"
|
||||
t.boolean "weekly_email_notifications_enabled", default: true, null: false
|
||||
t.boolean "daily_email_notifications_enabled", default: false, null: false
|
||||
|
|
|
@ -424,7 +424,7 @@ describe Instructeurs::ProceduresController, type: :controller do
|
|||
let(:assign_to) { instructeur.assign_to.joins(:groupe_instructeur).find_by(groupe_instructeurs: { procedure: procedure }) }
|
||||
|
||||
before do
|
||||
patch :update_email_notifications, params: { procedure_id: procedure.id, assign_to: { id: assign_to.id, email_notifications_enabled: true } }
|
||||
patch :update_email_notifications, params: { procedure_id: procedure.id, assign_to: { id: assign_to.id, daily_email_notifications_enabled: true } }
|
||||
end
|
||||
|
||||
it { expect(instructeur.groupe_instructeur_with_email_notifications).to eq([procedure.defaut_groupe_instructeur]) }
|
||||
|
|
|
@ -384,7 +384,7 @@ describe Instructeur, type: :model do
|
|||
let(:procedure_to_assign) { create(:procedure) }
|
||||
|
||||
before do
|
||||
create(:assign_to, instructeur: instructeur, procedure: procedure_to_assign, email_notifications_enabled: true, groupe_instructeur: procedure_to_assign.defaut_groupe_instructeur)
|
||||
create(:assign_to, instructeur: instructeur, procedure: procedure_to_assign, daily_email_notifications_enabled: true, groupe_instructeur: procedure_to_assign.defaut_groupe_instructeur)
|
||||
end
|
||||
|
||||
context 'when a dossier in construction exists' do
|
||||
|
|
|
@ -28,7 +28,7 @@ describe NotificationService do
|
|||
create(:assign_to,
|
||||
instructeur: instructeur_with_email_notifications,
|
||||
procedure: procedure,
|
||||
email_notifications_enabled: true)
|
||||
daily_email_notifications_enabled: true)
|
||||
end
|
||||
|
||||
context "when there is no activity on the instructeur's procedures" do
|
||||
|
|
Loading…
Reference in a new issue