Commit 2d284647 authored by Ash McKenzie's avatar Ash McKenzie

Merge branch...

Merge branch '209277-introduce-a-feature-flag-for-resolve-notifications-for-when-pipelines-are-fixed' into 'master'

Introduce a feature flag for fixed pipeline notifications

Closes #209277

See merge request gitlab-org/gitlab!26682
parents a6e7af1b 0c32fc96
...@@ -236,7 +236,11 @@ module Ci ...@@ -236,7 +236,11 @@ module Ci
after_transition any => [:success, :failed] do |pipeline| after_transition any => [:success, :failed] do |pipeline|
pipeline.run_after_commit do pipeline.run_after_commit do
PipelineUpdateCiRefStatusWorker.perform_async(pipeline.id) if Feature.enabled?(:ci_pipeline_fixed_notifications)
PipelineUpdateCiRefStatusWorker.perform_async(pipeline.id)
else
PipelineNotificationWorker.perform_async(pipeline.id)
end
end end
end end
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#{ paragraph.html_safe } #{ paragraph.html_safe }
.col-lg-8 .col-lg-8
- notification_setting.email_events.each_with_index do |event, index| - notification_setting.email_events.each_with_index do |event, index|
- next if event == :fixed_pipeline && Feature.disabled?(:ci_pipeline_fixed_notifications)
- field_id = "#{notifications_menu_identifier("modal", notification_setting)}_notification_setting[#{event}]" - field_id = "#{notifications_menu_identifier("modal", notification_setting)}_notification_setting[#{event}]"
.form-group .form-group
.form-check{ class: ("prepend-top-0" if index == 0) } .form-check{ class: ("prepend-top-0" if index == 0) }
......
---
title: Introduce a feature flag for Notifications for when pipelines are fixed
merge_request: 26682
author: Jacopo Beschi @jacopo-beschi
type: changed
...@@ -181,7 +181,7 @@ To minimize the number of notifications that do not require any action, from [Gi ...@@ -181,7 +181,7 @@ To minimize the number of notifications that do not require any action, from [Gi
| Remove milestone merge request | Subscribers, participants mentioned, and Custom notification level with this event selected | | Remove milestone merge request | Subscribers, participants mentioned, and Custom notification level with this event selected |
| New comment | The above, plus anyone mentioned by `@username` in the comment, with notification level "Mention" or higher | | New comment | The above, plus anyone mentioned by `@username` in the comment, with notification level "Mention" or higher |
| Failed pipeline | The author of the pipeline | | Failed pipeline | The author of the pipeline |
| Fixed pipeline | The author of the pipeline | | Fixed pipeline | The author of the pipeline. Disabled by default. To activate it you must [enable the `ci_pipeline_fixed_notifications` feature flag](../../development/feature_flags/development.md#enabling-a-feature-flag-in-development). |
| Successful pipeline | The author of the pipeline, if they have the custom notification setting for successful pipelines set. If the pipeline failed previously, a `Fixed pipeline` message will be sent for the first successful pipeline after the failure, then a `Successful pipeline` message for any further successful pipelines. | | Successful pipeline | The author of the pipeline, if they have the custom notification setting for successful pipelines set. If the pipeline failed previously, a `Fixed pipeline` message will be sent for the first successful pipeline after the failure, then a `Successful pipeline` message for any further successful pipelines. |
| New epic **(ULTIMATE)** | | | New epic **(ULTIMATE)** | |
| Close epic **(ULTIMATE)** | | | Close epic **(ULTIMATE)** | |
......
...@@ -7,7 +7,6 @@ describe 'Projects > Show > User manages notifications', :js do ...@@ -7,7 +7,6 @@ describe 'Projects > Show > User manages notifications', :js do
before do before do
sign_in(project.owner) sign_in(project.owner)
visit project_path(project)
end end
def click_notifications_button def click_notifications_button
...@@ -15,6 +14,7 @@ describe 'Projects > Show > User manages notifications', :js do ...@@ -15,6 +14,7 @@ describe 'Projects > Show > User manages notifications', :js do
end end
it 'changes the notification setting' do it 'changes the notification setting' do
visit project_path(project)
click_notifications_button click_notifications_button
click_link 'On mention' click_link 'On mention'
...@@ -26,6 +26,7 @@ describe 'Projects > Show > User manages notifications', :js do ...@@ -26,6 +26,7 @@ describe 'Projects > Show > User manages notifications', :js do
end end
it 'changes the notification setting to disabled' do it 'changes the notification setting to disabled' do
visit project_path(project)
click_notifications_button click_notifications_button
click_link 'Disabled' click_link 'Disabled'
...@@ -50,11 +51,13 @@ describe 'Projects > Show > User manages notifications', :js do ...@@ -50,11 +51,13 @@ describe 'Projects > Show > User manages notifications', :js do
:reassign_merge_request, :reassign_merge_request,
:merge_merge_request, :merge_merge_request,
:failed_pipeline, :failed_pipeline,
:fixed_pipeline,
:success_pipeline :success_pipeline
] ]
end end
it 'shows notification settings checkbox' do it 'shows notification settings checkbox' do
visit project_path(project)
click_notifications_button click_notifications_button
page.find('a[data-notification-level="custom"]').click page.find('a[data-notification-level="custom"]').click
...@@ -64,12 +67,27 @@ describe 'Projects > Show > User manages notifications', :js do ...@@ -64,12 +67,27 @@ describe 'Projects > Show > User manages notifications', :js do
end end
end end
end end
context 'when ci_pipeline_fixed_notifications is disabled' do
before do
stub_feature_flags(ci_pipeline_fixed_notifications: false)
end
it 'hides fixed_pipeline checkbox' do
visit project_path(project)
click_notifications_button
page.find('a[data-notification-level="custom"]').click
expect(page).not_to have_selector("input[name='notification_setting[fixed_pipeline]']")
end
end
end end
context 'when project emails are disabled' do context 'when project emails are disabled' do
let(:project) { create(:project, :public, :repository, emails_disabled: true) } let(:project) { create(:project, :public, :repository, emails_disabled: true) }
it 'is disabled' do it 'is disabled' do
visit project_path(project)
expect(page).to have_selector('.notifications-btn.disabled', visible: true) expect(page).to have_selector('.notifications-btn.disabled', visible: true)
end end
end end
......
...@@ -2509,27 +2509,53 @@ describe Ci::Pipeline, :mailer do ...@@ -2509,27 +2509,53 @@ describe Ci::Pipeline, :mailer do
end end
end end
context 'with success pipeline' do shared_examples 'enqueues the notification worker' do
before do it 'enqueues PipelineUpdateCiRefStatusWorker' do
perform_enqueued_jobs do expect(PipelineUpdateCiRefStatusWorker).to receive(:perform_async).with(pipeline.id)
expect(PipelineNotificationWorker).not_to receive(:perform_async).with(pipeline.id)
pipeline.succeed
end
context 'when ci_pipeline_fixed_notifications is disabled' do
before do
stub_feature_flags(ci_pipeline_fixed_notifications: false)
end
it 'enqueues PipelineNotificationWorker' do
expect(PipelineUpdateCiRefStatusWorker).not_to receive(:perform_async).with(pipeline.id)
expect(PipelineNotificationWorker).to receive(:perform_async).with(pipeline.id)
pipeline.succeed pipeline.succeed
end end
end end
end
it_behaves_like 'sending a notification' context 'with success pipeline' do
it_behaves_like 'sending a notification' do
before do
perform_enqueued_jobs do
pipeline.succeed
end
end
end
it_behaves_like 'enqueues the notification worker'
end end
context 'with failed pipeline' do context 'with failed pipeline' do
before do it_behaves_like 'sending a notification' do
perform_enqueued_jobs do before do
create(:ci_build, :failed, pipeline: pipeline) perform_enqueued_jobs do
create(:generic_commit_status, :failed, pipeline: pipeline) create(:ci_build, :failed, pipeline: pipeline)
create(:generic_commit_status, :failed, pipeline: pipeline)
pipeline.drop pipeline.drop
end
end end
end end
it_behaves_like 'sending a notification' it_behaves_like 'enqueues the notification worker'
end end
context 'with skipped pipeline' do context 'with skipped pipeline' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment