mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-31 21:37:16 +00:00
Update belongs_to default in Customer model
This commit is contained in:
@@ -10,20 +10,22 @@
|
||||
class Customer < ApplicationRecord
|
||||
include SetUnusedAddressFields
|
||||
|
||||
self.belongs_to_required_by_default = true
|
||||
|
||||
acts_as_taggable
|
||||
|
||||
searchable_attributes :first_name, :last_name, :email, :code
|
||||
|
||||
belongs_to :enterprise, optional: false
|
||||
belongs_to :user, class_name: "Spree::User"
|
||||
belongs_to :enterprise
|
||||
belongs_to :user, class_name: "Spree::User", optional: true
|
||||
has_many :orders, class_name: "Spree::Order"
|
||||
before_destroy :update_orders_and_delete_canceled_subscriptions
|
||||
|
||||
belongs_to :bill_address, class_name: "Spree::Address"
|
||||
belongs_to :bill_address, class_name: "Spree::Address", optional: true
|
||||
alias_attribute :billing_address, :bill_address
|
||||
accepts_nested_attributes_for :bill_address
|
||||
|
||||
belongs_to :ship_address, class_name: "Spree::Address"
|
||||
belongs_to :ship_address, class_name: "Spree::Address", optional: true
|
||||
alias_attribute :shipping_address, :ship_address
|
||||
accepts_nested_attributes_for :ship_address
|
||||
|
||||
|
||||
@@ -3,6 +3,11 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe Customer, type: :model do
|
||||
it { is_expected.to belong_to(:enterprise).required }
|
||||
it { is_expected.to belong_to(:user).optional }
|
||||
it { is_expected.to belong_to(:bill_address).optional }
|
||||
it { is_expected.to belong_to(:ship_address).optional }
|
||||
|
||||
describe 'an existing customer' do
|
||||
let(:customer) { create(:customer) }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user