Fix POST `/api/v1/admin/domain_allows` returning 200 when no domain is specified (#24958)
parent
e328ab7e5a
commit
ce8b5899ae
|
@ -29,7 +29,7 @@ class Api::V1::Admin::DomainAllowsController < Api::BaseController
|
||||||
def create
|
def create
|
||||||
authorize :domain_allow, :create?
|
authorize :domain_allow, :create?
|
||||||
|
|
||||||
@domain_allow = DomainAllow.find_by(resource_params)
|
@domain_allow = DomainAllow.find_by(domain: resource_params[:domain])
|
||||||
|
|
||||||
if @domain_allow.nil?
|
if @domain_allow.nil?
|
||||||
@domain_allow = DomainAllow.create!(resource_params)
|
@domain_allow = DomainAllow.create!(resource_params)
|
||||||
|
|
|
@ -128,5 +128,13 @@ RSpec.describe Api::V1::Admin::DomainAllowsController do
|
||||||
expect(response).to have_http_status(422)
|
expect(response).to have_http_status(422)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when domain name is not specified' do
|
||||||
|
it 'returns http unprocessable entity' do
|
||||||
|
post :create
|
||||||
|
|
||||||
|
expect(response).to have_http_status(422)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Reference in New Issue