diff options
author | Wei-Meng Lee <wlee@gitlab.com> | 2019-02-15 20:56:13 +0300 |
---|---|---|
committer | Wei-Meng Lee <wlee@gitlab.com> | 2019-05-31 15:49:27 +0300 |
commit | 1a402d888c05196212d1ba671368837e85246c9c (patch) | |
tree | fa4c4da1cc8eaf9268421448f7dd62a8b17ffffa /app/controllers/profiles | |
parent | 6d73ce696c02bc949b9e3e71b8c14554e43ab340 (diff) |
Send notifications to group-specific email address
- Select notification email by walking up group/subgroup path
- Add settings UI to set group email notification address
- Add tests
Diffstat (limited to 'app/controllers/profiles')
-rw-r--r-- | app/controllers/profiles/groups_controller.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/app/controllers/profiles/groups_controller.rb b/app/controllers/profiles/groups_controller.rb new file mode 100644 index 00000000000..c755bcb718a --- /dev/null +++ b/app/controllers/profiles/groups_controller.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +class Profiles::GroupsController < Profiles::ApplicationController + include RoutableActions + + def update + group = find_routable!(Group, params[:id]) + notification_setting = current_user.notification_settings.find_by(source: group) # rubocop: disable CodeReuse/ActiveRecord + + if notification_setting.update(update_params) + flash[:notice] = "Notification settings for #{group.name} saved" + else + flash[:alert] = "Failed to save new settings for #{group.name}" + end + + redirect_back_or_default(default: profile_notifications_path) + end + + private + + def update_params + params.require(:notification_setting).permit(:notification_email) + end +end |