Commit d70c5dc7 authored by Vitali Tatarintev's avatar Vitali Tatarintev

Fetch payload body from params[:notification]

Fetch payload body from `params[:notification]` instead of slicing out
service params such as controller, and action names.

If the "Content-Type" header of your request is set
to "application/json", Rails will automatically load your parameters
into the params hash, which you can access as you would normally.

https://guides.rubyonrails.org/v5.2/
action_controller_overview.html#json-parameters
parent d9117a45
......@@ -19,8 +19,6 @@ module Projects
private
PARAMS_TO_EXCLUDE = %w(controller action namespace_id project_id).freeze
def project_without_auth
@project ||= Project
.find_by_full_path("#{params[:namespace_id]}/#{params[:project_id]}")
......@@ -36,7 +34,7 @@ module Projects
def notify_service
Projects::Alerting::NotifyService
.new(project, current_user, permitted_params)
.new(project, current_user, notification_payload)
end
def response_status(result)
......@@ -45,8 +43,8 @@ module Projects
result.http_status
end
def permitted_params
params.except(*PARAMS_TO_EXCLUDE).permit!
def notification_payload
params.permit![:notification]
end
end
end
......
......@@ -14,8 +14,8 @@ describe Projects::Alerting::NotificationsController do
allow(Projects::Alerting::NotifyService).to receive(:new).and_return(notify_service)
end
def make_request(opts = {})
post :create, params: project_params(opts), session: { as: :json }
def make_request(body = {})
post :create, params: project_params, body: body.to_json, as: :json
end
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