Simplify customer code

The API endpoint merges the created_manually flag in the params already.
No need to write it separately.
This commit is contained in:
Maikel Linke
2023-06-15 11:42:32 +10:00
parent a655d3d787
commit 75cce8bc19
3 changed files with 3 additions and 8 deletions

View File

@@ -31,7 +31,6 @@ module Api
authorize! :update, Enterprise.find(customer_params[:enterprise_id])
customer = Customer.find_or_new(customer_params[:email], customer_params[:enterprise_id])
customer.assign_attributes(customer_params)
customer.set_created_manually_flag
if customer.save
render json: Api::V1::CustomerSerializer.new(customer), status: :created

View File

@@ -54,13 +54,6 @@ class Customer < ApplicationRecord
"#{first_name} #{last_name}".strip
end
def set_created_manually_flag
self.created_manually = true
return unless persisted?
update_attribute(:created_manually, true)
end
private
def downcase_email

View File

@@ -190,6 +190,9 @@ describe "Customers", type: :request do
allow_charges: false,
terms_and_conditions_accepted_at: nil,
)
customer = Customer.find(json_response[:data][:attributes][:id])
expect(customer.created_manually).to eq true
end
end