commit
09dbc82919
10 changed files with 73 additions and 76 deletions
119
Gemfile.lock
119
Gemfile.lock
|
@ -20,25 +20,25 @@ GEM
|
||||||
specs:
|
specs:
|
||||||
aasm (5.0.1)
|
aasm (5.0.1)
|
||||||
concurrent-ruby (~> 1.0)
|
concurrent-ruby (~> 1.0)
|
||||||
actioncable (5.2.4.1)
|
actioncable (5.2.3)
|
||||||
actionpack (= 5.2.4.1)
|
actionpack (= 5.2.3)
|
||||||
nio4r (~> 2.0)
|
nio4r (~> 2.0)
|
||||||
websocket-driver (>= 0.6.1)
|
websocket-driver (>= 0.6.1)
|
||||||
actionmailer (5.2.4.1)
|
actionmailer (5.2.3)
|
||||||
actionpack (= 5.2.4.1)
|
actionpack (= 5.2.3)
|
||||||
actionview (= 5.2.4.1)
|
actionview (= 5.2.3)
|
||||||
activejob (= 5.2.4.1)
|
activejob (= 5.2.3)
|
||||||
mail (~> 2.5, >= 2.5.4)
|
mail (~> 2.5, >= 2.5.4)
|
||||||
rails-dom-testing (~> 2.0)
|
rails-dom-testing (~> 2.0)
|
||||||
actionpack (5.2.4.1)
|
actionpack (5.2.3)
|
||||||
actionview (= 5.2.4.1)
|
actionview (= 5.2.3)
|
||||||
activesupport (= 5.2.4.1)
|
activesupport (= 5.2.3)
|
||||||
rack (~> 2.0, >= 2.0.8)
|
rack (~> 2.0)
|
||||||
rack-test (>= 0.6.3)
|
rack-test (>= 0.6.3)
|
||||||
rails-dom-testing (~> 2.0)
|
rails-dom-testing (~> 2.0)
|
||||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||||
actionview (5.2.4.1)
|
actionview (5.2.3)
|
||||||
activesupport (= 5.2.4.1)
|
activesupport (= 5.2.3)
|
||||||
builder (~> 3.1)
|
builder (~> 3.1)
|
||||||
erubi (~> 1.4)
|
erubi (~> 1.4)
|
||||||
rails-dom-testing (~> 2.0)
|
rails-dom-testing (~> 2.0)
|
||||||
|
@ -46,9 +46,9 @@ GEM
|
||||||
active_link_to (1.0.5)
|
active_link_to (1.0.5)
|
||||||
actionpack
|
actionpack
|
||||||
addressable
|
addressable
|
||||||
active_model_serializers (0.10.10)
|
active_model_serializers (0.10.8)
|
||||||
actionpack (>= 4.1, < 6.1)
|
actionpack (>= 4.1, < 6)
|
||||||
activemodel (>= 4.1, < 6.1)
|
activemodel (>= 4.1, < 6)
|
||||||
case_transform (>= 0.2)
|
case_transform (>= 0.2)
|
||||||
jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
|
jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
|
||||||
active_storage_validations (0.8.7)
|
active_storage_validations (0.8.7)
|
||||||
|
@ -56,22 +56,22 @@ GEM
|
||||||
activejob (5.2.3)
|
activejob (5.2.3)
|
||||||
activesupport (= 5.2.3)
|
activesupport (= 5.2.3)
|
||||||
globalid (>= 0.3.6)
|
globalid (>= 0.3.6)
|
||||||
activemodel (5.2.4.1)
|
activemodel (5.2.3)
|
||||||
activesupport (= 5.2.4.1)
|
activesupport (= 5.2.3)
|
||||||
activerecord (5.2.4.1)
|
activerecord (5.2.3)
|
||||||
activemodel (= 5.2.4.1)
|
activemodel (= 5.2.3)
|
||||||
activesupport (= 5.2.4.1)
|
activesupport (= 5.2.3)
|
||||||
arel (>= 9.0)
|
arel (>= 9.0)
|
||||||
activestorage (5.2.4.1)
|
activestorage (5.2.3)
|
||||||
actionpack (= 5.2.4.1)
|
actionpack (= 5.2.3)
|
||||||
activerecord (= 5.2.4.1)
|
activerecord (= 5.2.3)
|
||||||
marcel (~> 0.3.1)
|
marcel (~> 0.3.1)
|
||||||
activestorage-openstack (1.3.0)
|
activestorage-openstack (1.2.0)
|
||||||
fog-openstack (~> 1.0)
|
fog-openstack (~> 1.0)
|
||||||
marcel
|
marcel
|
||||||
mime-types
|
mime-types
|
||||||
rails (>= 5.2.2)
|
rails (>= 5.2.2)
|
||||||
activesupport (5.2.4.1)
|
activesupport (5.2.3)
|
||||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||||
i18n (>= 0.7, < 2)
|
i18n (>= 0.7, < 2)
|
||||||
minitest (~> 5.1)
|
minitest (~> 5.1)
|
||||||
|
@ -205,7 +205,7 @@ GEM
|
||||||
ethon (0.11.0)
|
ethon (0.11.0)
|
||||||
ffi (>= 1.3.0)
|
ffi (>= 1.3.0)
|
||||||
eventmachine (1.2.7)
|
eventmachine (1.2.7)
|
||||||
excon (0.72.0)
|
excon (0.71.0)
|
||||||
execjs (2.7.0)
|
execjs (2.7.0)
|
||||||
factory_bot (4.11.1)
|
factory_bot (4.11.1)
|
||||||
activesupport (>= 3.0.0)
|
activesupport (>= 3.0.0)
|
||||||
|
@ -221,9 +221,9 @@ GEM
|
||||||
flipper (~> 0.17.2)
|
flipper (~> 0.17.2)
|
||||||
rack (>= 1.4, < 3)
|
rack (>= 1.4, < 3)
|
||||||
rack-protection (>= 1.5.3, < 2.1.0)
|
rack-protection (>= 1.5.3, < 2.1.0)
|
||||||
fog-core (2.2.0)
|
fog-core (2.1.2)
|
||||||
builder
|
builder
|
||||||
excon (~> 0.71)
|
excon (~> 0.58)
|
||||||
formatador (~> 0.2)
|
formatador (~> 0.2)
|
||||||
mime-types
|
mime-types
|
||||||
fog-json (1.2.0)
|
fog-json (1.2.0)
|
||||||
|
@ -239,9 +239,8 @@ GEM
|
||||||
geocoder (1.6.0)
|
geocoder (1.6.0)
|
||||||
globalid (0.4.2)
|
globalid (0.4.2)
|
||||||
activesupport (>= 4.2.0)
|
activesupport (>= 4.2.0)
|
||||||
gon (6.3.2)
|
gon (6.2.1)
|
||||||
actionpack (>= 3.0.20)
|
actionpack (>= 3.0)
|
||||||
i18n (>= 0.7)
|
|
||||||
multi_json
|
multi_json
|
||||||
request_store (>= 1.0)
|
request_store (>= 1.0)
|
||||||
graphiql-rails (1.7.0)
|
graphiql-rails (1.7.0)
|
||||||
|
@ -323,25 +322,25 @@ GEM
|
||||||
activesupport (>= 4.2)
|
activesupport (>= 4.2)
|
||||||
aes_key_wrap
|
aes_key_wrap
|
||||||
bindata
|
bindata
|
||||||
jsonapi-renderer (0.2.2)
|
jsonapi-renderer (0.2.0)
|
||||||
jwt (2.1.0)
|
jwt (2.1.0)
|
||||||
kaminari (1.2.0)
|
kaminari (1.1.1)
|
||||||
activesupport (>= 4.1.0)
|
activesupport (>= 4.1.0)
|
||||||
kaminari-actionview (= 1.2.0)
|
kaminari-actionview (= 1.1.1)
|
||||||
kaminari-activerecord (= 1.2.0)
|
kaminari-activerecord (= 1.1.1)
|
||||||
kaminari-core (= 1.2.0)
|
kaminari-core (= 1.1.1)
|
||||||
kaminari-actionview (1.2.0)
|
kaminari-actionview (1.1.1)
|
||||||
actionview
|
actionview
|
||||||
kaminari-core (= 1.2.0)
|
kaminari-core (= 1.1.1)
|
||||||
kaminari-activerecord (1.2.0)
|
kaminari-activerecord (1.1.1)
|
||||||
activerecord
|
activerecord
|
||||||
kaminari-core (= 1.2.0)
|
kaminari-core (= 1.1.1)
|
||||||
kaminari-core (1.2.0)
|
kaminari-core (1.1.1)
|
||||||
launchy (2.4.3)
|
launchy (2.4.3)
|
||||||
addressable (~> 2.3)
|
addressable (~> 2.3)
|
||||||
letter_opener (1.7.0)
|
letter_opener (1.7.0)
|
||||||
launchy (~> 2.2)
|
launchy (~> 2.2)
|
||||||
letter_opener_web (1.4.0)
|
letter_opener_web (1.3.4)
|
||||||
actionmailer (>= 3.2)
|
actionmailer (>= 3.2)
|
||||||
letter_opener (~> 1.0)
|
letter_opener (~> 1.0)
|
||||||
railties (>= 3.2)
|
railties (>= 3.2)
|
||||||
|
@ -368,10 +367,10 @@ GEM
|
||||||
marcel (0.3.3)
|
marcel (0.3.3)
|
||||||
mimemagic (~> 0.3.2)
|
mimemagic (~> 0.3.2)
|
||||||
method_source (0.9.2)
|
method_source (0.9.2)
|
||||||
mime-types (3.3.1)
|
mime-types (3.3)
|
||||||
mime-types-data (~> 3.2015)
|
mime-types-data (~> 3.2015)
|
||||||
mime-types-data (3.2019.1009)
|
mime-types-data (3.2019.1009)
|
||||||
mimemagic (0.3.4)
|
mimemagic (0.3.3)
|
||||||
mini_mime (1.0.2)
|
mini_mime (1.0.2)
|
||||||
mini_portile2 (2.4.0)
|
mini_portile2 (2.4.0)
|
||||||
minitest (5.14.0)
|
minitest (5.14.0)
|
||||||
|
@ -451,7 +450,7 @@ GEM
|
||||||
pry-byebug (3.6.0)
|
pry-byebug (3.6.0)
|
||||||
byebug (~> 10.0)
|
byebug (~> 10.0)
|
||||||
pry (~> 0.10)
|
pry (~> 0.10)
|
||||||
public_suffix (4.0.3)
|
public_suffix (4.0.1)
|
||||||
puma (3.12.2)
|
puma (3.12.2)
|
||||||
pundit (2.0.1)
|
pundit (2.0.1)
|
||||||
activesupport (>= 3.0.0)
|
activesupport (>= 3.0.0)
|
||||||
|
@ -472,18 +471,18 @@ GEM
|
||||||
rack
|
rack
|
||||||
rack-test (1.1.0)
|
rack-test (1.1.0)
|
||||||
rack (>= 1.0, < 3)
|
rack (>= 1.0, < 3)
|
||||||
rails (5.2.4.1)
|
rails (5.2.3)
|
||||||
actioncable (= 5.2.4.1)
|
actioncable (= 5.2.3)
|
||||||
actionmailer (= 5.2.4.1)
|
actionmailer (= 5.2.3)
|
||||||
actionpack (= 5.2.4.1)
|
actionpack (= 5.2.3)
|
||||||
actionview (= 5.2.4.1)
|
actionview (= 5.2.3)
|
||||||
activejob (= 5.2.4.1)
|
activejob (= 5.2.3)
|
||||||
activemodel (= 5.2.4.1)
|
activemodel (= 5.2.3)
|
||||||
activerecord (= 5.2.4.1)
|
activerecord (= 5.2.3)
|
||||||
activestorage (= 5.2.4.1)
|
activestorage (= 5.2.3)
|
||||||
activesupport (= 5.2.4.1)
|
activesupport (= 5.2.3)
|
||||||
bundler (>= 1.3.0)
|
bundler (>= 1.3.0)
|
||||||
railties (= 5.2.4.1)
|
railties (= 5.2.3)
|
||||||
sprockets-rails (>= 2.0.0)
|
sprockets-rails (>= 2.0.0)
|
||||||
rails-controller-testing (1.0.4)
|
rails-controller-testing (1.0.4)
|
||||||
actionpack (>= 5.0.1.x)
|
actionpack (>= 5.0.1.x)
|
||||||
|
@ -497,9 +496,9 @@ GEM
|
||||||
rails-i18n (5.1.2)
|
rails-i18n (5.1.2)
|
||||||
i18n (>= 0.7, < 2)
|
i18n (>= 0.7, < 2)
|
||||||
railties (>= 5.0, < 6)
|
railties (>= 5.0, < 6)
|
||||||
railties (5.2.4.1)
|
railties (5.2.3)
|
||||||
actionpack (= 5.2.4.1)
|
actionpack (= 5.2.3)
|
||||||
activesupport (= 5.2.4.1)
|
activesupport (= 5.2.3)
|
||||||
method_source
|
method_source
|
||||||
rake (>= 0.8.7)
|
rake (>= 0.8.7)
|
||||||
thor (>= 0.19.0, < 2.0)
|
thor (>= 0.19.0, < 2.0)
|
||||||
|
@ -516,7 +515,7 @@ GEM
|
||||||
railties (>= 3.2)
|
railties (>= 3.2)
|
||||||
tilt
|
tilt
|
||||||
regexp_parser (1.6.0)
|
regexp_parser (1.6.0)
|
||||||
request_store (1.5.0)
|
request_store (1.4.1)
|
||||||
rack (>= 1.4)
|
rack (>= 1.4)
|
||||||
responders (3.0.0)
|
responders (3.0.0)
|
||||||
actionpack (>= 5.0)
|
actionpack (>= 5.0)
|
||||||
|
|
|
@ -232,7 +232,6 @@ module Instructeurs
|
||||||
|
|
||||||
def update_email_notifications
|
def update_email_notifications
|
||||||
assign_to.update!(assign_to_params)
|
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.'
|
flash.notice = 'Vos notifications sont enregistrées.'
|
||||||
redirect_to instructeur_procedure_path(procedure)
|
redirect_to instructeur_procedure_path(procedure)
|
||||||
end
|
end
|
||||||
|
@ -247,7 +246,7 @@ module Instructeurs
|
||||||
private
|
private
|
||||||
|
|
||||||
def assign_to_params
|
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
|
end
|
||||||
|
|
||||||
def assign_exports
|
def assign_exports
|
||||||
|
|
|
@ -3,13 +3,8 @@ class AssignTo < ApplicationRecord
|
||||||
belongs_to :groupe_instructeur
|
belongs_to :groupe_instructeur
|
||||||
has_one :procedure_presentation, dependent: :destroy
|
has_one :procedure_presentation, dependent: :destroy
|
||||||
has_one :procedure, through: :groupe_instructeur
|
has_one :procedure, through: :groupe_instructeur
|
||||||
before_save :save_to_new_daily_email_column
|
|
||||||
|
|
||||||
scope :with_email_notifications, -> { where(email_notifications_enabled: true) }
|
scope :with_email_notifications, -> { where(daily_email_notifications_enabled: true) }
|
||||||
|
|
||||||
def save_to_new_daily_email_column
|
|
||||||
self.daily_email_notifications_enabled = email_notifications_enabled
|
|
||||||
end
|
|
||||||
|
|
||||||
def procedure_presentation_or_default_and_errors
|
def procedure_presentation_or_default_and_errors
|
||||||
errors = reset_procedure_presentation_if_invalid
|
errors = reset_procedure_presentation_if_invalid
|
||||||
|
|
|
@ -3,7 +3,7 @@ class NotificationService
|
||||||
def send_instructeur_email_notification
|
def send_instructeur_email_notification
|
||||||
Instructeur
|
Instructeur
|
||||||
.includes(assign_to: { procedure: :dossiers })
|
.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) }
|
.find_in_batches { |instructeurs| send_batch_of_instructeurs_email_notification(instructeurs) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -20,11 +20,11 @@
|
||||||
|
|
||||||
.radios
|
.radios
|
||||||
%label
|
%label
|
||||||
= form.radio_button :email_notifications_enabled, true
|
= form.radio_button :daily_email_notifications_enabled, true
|
||||||
Oui
|
Oui
|
||||||
|
|
||||||
%label
|
%label
|
||||||
= form.radio_button :email_notifications_enabled, false
|
= form.radio_button :daily_email_notifications_enabled, false
|
||||||
Non
|
Non
|
||||||
|
|
||||||
= form.label :email_notification, "Recevoir un récapitulatif hebdomadaire"
|
= 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.
|
# 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
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
@ -100,7 +100,6 @@ ActiveRecord::Schema.define(version: 2020_02_18_144724) do
|
||||||
t.integer "procedure_id"
|
t.integer "procedure_id"
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
t.boolean "email_notifications_enabled", default: false, null: false
|
|
||||||
t.bigint "groupe_instructeur_id"
|
t.bigint "groupe_instructeur_id"
|
||||||
t.boolean "weekly_email_notifications_enabled", default: true, null: false
|
t.boolean "weekly_email_notifications_enabled", default: true, null: false
|
||||||
t.boolean "daily_email_notifications_enabled", default: false, 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 }) }
|
let(:assign_to) { instructeur.assign_to.joins(:groupe_instructeur).find_by(groupe_instructeurs: { procedure: procedure }) }
|
||||||
|
|
||||||
before do
|
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
|
end
|
||||||
|
|
||||||
it { expect(instructeur.groupe_instructeur_with_email_notifications).to eq([procedure.defaut_groupe_instructeur]) }
|
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) }
|
let(:procedure_to_assign) { create(:procedure) }
|
||||||
|
|
||||||
before do
|
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
|
end
|
||||||
|
|
||||||
context 'when a dossier in construction exists' do
|
context 'when a dossier in construction exists' do
|
||||||
|
|
|
@ -28,7 +28,7 @@ describe NotificationService do
|
||||||
create(:assign_to,
|
create(:assign_to,
|
||||||
instructeur: instructeur_with_email_notifications,
|
instructeur: instructeur_with_email_notifications,
|
||||||
procedure: procedure,
|
procedure: procedure,
|
||||||
email_notifications_enabled: true)
|
daily_email_notifications_enabled: true)
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when there is no activity on the instructeur's procedures" do
|
context "when there is no activity on the instructeur's procedures" do
|
||||||
|
|
Loading…
Reference in a new issue