Permit more customer attributes for update

This commit is contained in:
Maikel Linke
2022-03-07 11:05:43 +11:00
parent 41746459fa
commit 8d12c7a692
3 changed files with 27 additions and 3 deletions

View File

@@ -70,7 +70,10 @@ module Api
end
def customer_params
params.require(:customer).permit(:email, :enterprise_id)
params.require(:customer).permit(
:email, :enterprise_id,
:code, :first_name, :last_name,
)
end
def editable_enterprises

View File

@@ -105,7 +105,7 @@ describe "Customers", type: :request do
required: CustomerSchema.required_attributes
}
response "201", "Customer created" do
response "201", "Minimal customer created" do
param(:customer) do
{
email: "test@example.com",
@@ -121,6 +121,27 @@ describe "Customers", type: :request do
end
end
response "201", "Example customer created" do
param(:customer) do
CustomerSchema.writable_attributes.transform_values do |attribute|
attribute[:example]
end.merge(
enterprise_id: enterprise1.id,
)
end
schema "$ref": "#/components/schemas/resources/customer"
run_test! do
expect(json_response[:data][:attributes]).to include(
first_name: "Alice",
last_name: "Springs",
code: "BUYER1",
email: "alice@example.com",
enterprise_id: enterprise1.id,
)
end
end
response "422", "Unpermitted parameter" do
param(:customer) do
{

View File

@@ -244,7 +244,7 @@ paths:
parameters: []
responses:
'201':
description: Customer created
description: Example customer created
content:
application/json:
schema: