Commit 40e31aa0 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'refactor-generic-alerts-endpoint' into 'master'

Fetch payload body from params[:notification]

See merge request gitlab-org/gitlab!17673
parents 71126a2f d70c5dc7
...@@ -20,8 +20,6 @@ module Projects ...@@ -20,8 +20,6 @@ module Projects
private private
PARAMS_TO_EXCLUDE = %w(controller action namespace_id project_id).freeze
def project_without_auth def project_without_auth
@project ||= Project @project ||= Project
.find_by_full_path("#{params[:namespace_id]}/#{params[:project_id]}") .find_by_full_path("#{params[:namespace_id]}/#{params[:project_id]}")
...@@ -37,7 +35,7 @@ module Projects ...@@ -37,7 +35,7 @@ module Projects
def notify_service def notify_service
Projects::Alerting::NotifyService Projects::Alerting::NotifyService
.new(project, current_user, permitted_params) .new(project, current_user, notification_payload)
end end
def response_status(result) def response_status(result)
...@@ -46,8 +44,8 @@ module Projects ...@@ -46,8 +44,8 @@ module Projects
result.http_status result.http_status
end end
def permitted_params def notification_payload
params.except(*PARAMS_TO_EXCLUDE).permit! params.permit![:notification]
end end
end end
end end
......
...@@ -18,8 +18,8 @@ describe Projects::Alerting::NotificationsController do ...@@ -18,8 +18,8 @@ describe Projects::Alerting::NotificationsController do
allow(Projects::Alerting::NotifyService).to receive(:new).and_return(notify_service) allow(Projects::Alerting::NotifyService).to receive(:new).and_return(notify_service)
end end
def make_request(opts = {}) def make_request(body = {})
post :create, params: project_params(opts), session: { as: :json } post :create, params: project_params, body: body.to_json, as: :json
end end
context 'when feature flag is on' do context 'when feature flag is on' 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