mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Permit more customer attributes for update
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -244,7 +244,7 @@ paths:
|
||||
parameters: []
|
||||
responses:
|
||||
'201':
|
||||
description: Customer created
|
||||
description: Example customer created
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
|
||||
Reference in New Issue
Block a user