diff --git a/app/views/admin/customers/index.html.haml b/app/views/admin/customers/index.html.haml
index 18bf810ee8..1124120693 100644
--- a/app/views/admin/customers/index.html.haml
+++ b/app/views/admin/customers/index.html.haml
@@ -82,9 +82,9 @@
%span{ 'ng-bind' => '::customer.email' }
%span.guest-label{ 'ng-show' => 'customer.user_id == null' }= t('.guest_label')
%td.first_name{ 'ng-show' => 'columns.first_name.visible'}
- %input{ type: 'text', name: 'first_name', ng: { model: 'customer.first_name' }, 'obj-for-update' => 'customer', 'attr-for-update' => 'name'}
- %td.name{ 'ng-show' => 'columns.last_name.visible'}
- %input{ type: 'text', name: 'last_name', ng: { model: 'customer.last_name' }, 'obj-for-update' => 'customer', 'attr-for-update' => 'name'}
+ %input{ type: 'text', name: 'first_name', ng: { model: 'customer.first_name' }, 'obj-for-update' => 'customer', 'attr-for-update' => 'first_name'}
+ %td.last_name{ 'ng-show' => 'columns.last_name.visible'}
+ %input{ type: 'text', name: 'last_name', ng: { model: 'customer.last_name' }, 'obj-for-update' => 'customer', 'attr-for-update' => 'last_name'}
%td.code{ 'ng-show' => 'columns.code.visible' }
%input{ type: 'text', name: 'code', ng: {model: 'customer.code', change: 'checkForDuplicateCodes()'}, "obj-for-update" => "customer", "attr-for-update" => "code" }
%i.icon-warning-sign{ ng: {if: 'duplicate'} }
diff --git a/app/views/admin/subscriptions/_table.html.haml b/app/views/admin/subscriptions/_table.html.haml
index c4eb12b891..67dced6881 100644
--- a/app/views/admin/subscriptions/_table.html.haml
+++ b/app/views/admin/subscriptions/_table.html.haml
@@ -41,7 +41,7 @@
%td.customer.text-center{ ng: { show: 'columns.customer.visible'}}
%span{ "ng-bind": '::subscription.customer_email' }
%br
- %span{ "ng-bind": '::subscription.customer_name' }
+ %span{ "ng-bind": '::subscription.customer_full_name' }
%td.schedule.text-center{ ng: { show: 'columns.schedule.visible', bind: '::subscription.schedule_name' } }
%td.items.panel-toggle.text-center{ name: 'products', ng: { show: 'columns.items.visible' } }
%h5{ ng: { bind: 'itemCount(subscription)' } }
diff --git a/engines/order_management/app/services/order_management/reports/enterprise_fee_summary/scope.rb b/engines/order_management/app/services/order_management/reports/enterprise_fee_summary/scope.rb
index 59a5cd0470..0be3d77921 100644
--- a/engines/order_management/app/services/order_management/reports/enterprise_fee_summary/scope.rb
+++ b/engines/order_management/app/services/order_management/reports/enterprise_fee_summary/scope.rb
@@ -374,7 +374,7 @@ module OrderManagement
hubs.name AS hub_name,
enterprises.name AS enterprise_name,
enterprise_fees.fee_type AS fee_type,
- customers.name AS customer_name,
+ TRIM(CONCAT(customers.first_name, ' ', customers.last_name)) AS customer_name,
customers.email AS customer_email,
enterprise_fees.name AS fee_name,
spree_tax_categories.name AS tax_category_name,
diff --git a/engines/order_management/spec/services/order_management/reports/enterprise_fee_summary/report_service_spec.rb b/engines/order_management/spec/services/order_management/reports/enterprise_fee_summary/report_service_spec.rb
index 44cf80200d..28d240a296 100644
--- a/engines/order_management/spec/services/order_management/reports/enterprise_fee_summary/report_service_spec.rb
+++ b/engines/order_management/spec/services/order_management/reports/enterprise_fee_summary/report_service_spec.rb
@@ -36,8 +36,8 @@ describe OrderManagement::Reports::EnterpriseFeeSummary::ReportService do
let!(:variant) { prepare_variant }
# Create customers.
- let!(:customer) { create(:customer, name: "Sample Customer") }
- let!(:another_customer) { create(:customer, name: "Another Customer") }
+ let!(:customer) { create(:customer, first_name: "Sample", last_name: "Customer") }
+ let!(:another_customer) { create(:customer, first_name: "Another", last_name: "Customer") }
# Setup up permissions and report.
let!(:current_user) { create(:admin_user) }
@@ -438,9 +438,9 @@ describe OrderManagement::Reports::EnterpriseFeeSummary::ReportService do
context "filtering by completion date" do
let(:timestamp) { Time.zone.local(2018, 1, 5, 14, 30, 5) }
- let!(:customer_a) { create(:customer, name: "Customer A") }
- let!(:customer_b) { create(:customer, name: "Customer B") }
- let!(:customer_c) { create(:customer, name: "Customer C") }
+ let!(:customer_a) { create(:customer, first_name: "Customer", last_name: "A") }
+ let!(:customer_b) { create(:customer, first_name: "Customer", last_name: "B") }
+ let!(:customer_c) { create(:customer, first_name: "Customer", last_name: "C") }
let!(:order_placed_before_timestamp) do
prepare_order(customer: customer_a).tap do |order|
diff --git a/lib/open_food_network/column_preference_defaults.rb b/lib/open_food_network/column_preference_defaults.rb
index 4f3cc21f3f..cd162d2638 100644
--- a/lib/open_food_network/column_preference_defaults.rb
+++ b/lib/open_food_network/column_preference_defaults.rb
@@ -30,10 +30,10 @@ module OpenFoodNetwork
node = 'admin.customers.index'
{
email: { name: I18n.t("admin.email"), visible: true },
- first_name: { name: I18n.t("admin.first_name"), visible: true },
- last_name: { name: I18n.t("admin.last_name"), visible: true },
- code: { name: I18n.t("#{node}.code"), visible: true },
- tags: { name: I18n.t("admin.tags"), visible: true },
+ first_name: { name: I18n.t("admin.first_name"), visible: true },
+ last_name: { name: I18n.t("admin.last_name"), visible: true },
+ code: { name: I18n.t("#{node}.code"), visible: true },
+ tags: { name: I18n.t("admin.tags"), visible: true },
bill_address: { name: I18n.t("#{node}.bill_address"), visible: true },
ship_address: { name: I18n.t("#{node}.ship_address"), visible: true },
balance: { name: I18n.t("#{node}.balance"), visible: true }
diff --git a/spec/system/admin/customers_spec.rb b/spec/system/admin/customers_spec.rb
index b7e63e8e2c..eb4fca8363 100644
--- a/spec/system/admin/customers_spec.rb
+++ b/spec/system/admin/customers_spec.rb
@@ -14,7 +14,9 @@ describe 'Customers' do
let(:unmanaged_distributor) { create(:distributor_enterprise) }
describe "using the customers index" do
- let!(:customer1) { create(:customer, enterprise: managed_distributor1, code: nil) }
+ let!(:customer1) {
+ create(:customer, first_name: 'John', last_name: 'Doe', enterprise: managed_distributor1, code: nil)
+ }
let!(:customer2) { create(:customer, enterprise: managed_distributor1, code: nil) }
let!(:customer3) { create(:customer, enterprise: unmanaged_distributor) }
let!(:customer4) { create(:customer, enterprise: managed_distributor2) }
@@ -183,8 +185,8 @@ describe 'Customers' do
fill_in "code", with: "new-customer-code"
expect(page).to have_css "input[name=code].update-pending"
- fill_in "name", with: "customer abc"
- expect(page).to have_css "input[name=name].update-pending"
+ fill_in "first_name", with: "customer abc"
+ expect(page).to have_css "input[name=first_name].update-pending"
find(:css, "tags-input .tags input").set "awesome\n"
expect(page).to have_css ".tag_watcher.update-pending"
@@ -194,12 +196,12 @@ describe 'Customers' do
# Every says it updated
expect(page).to have_css "input[name=code].update-success"
- expect(page).to have_css "input[name=name].update-success"
+ expect(page).to have_css "input[name=first_name].update-success"
expect(page).to have_css ".tag_watcher.update-success"
# And it actually did
expect(customer1.reload.code).to eq "new-customer-code"
- expect(customer1.reload.name).to eq "customer abc"
+ expect(customer1.reload.first_name).to eq "customer abc"
expect(customer1.tag_list).to eq ["awesome"]
# Clearing attributes
@@ -207,8 +209,8 @@ describe 'Customers' do
fill_in "code", with: ""
expect(page).to have_css "input[name=code].update-pending"
- fill_in "name", with: ""
- expect(page).to have_css "input[name=name].update-pending"
+ fill_in "first_name", with: ""
+ expect(page).to have_css "input[name=first_name].update-pending"
find("tags-input li.tag-item a.remove-button").click
expect(page).to have_css ".tag_watcher.update-pending"
@@ -217,12 +219,12 @@ describe 'Customers' do
# Every says it updated
expect(page).to have_css "input[name=code].update-success"
- expect(page).to have_css "input[name=name].update-success"
+ expect(page).to have_css "input[name=first_name].update-success"
expect(page).to have_css ".tag_watcher.update-success"
# And it actually did
expect(customer1.reload.code).to be nil
- expect(customer1.reload.name).to eq ''
+ expect(customer1.reload.first_name).to eq ''
expect(customer1.tag_list).to eq []
end
diff --git a/spec/system/admin/order_spec.rb b/spec/system/admin/order_spec.rb
index dae71d2d86..7182da0851 100644
--- a/spec/system/admin/order_spec.rb
+++ b/spec/system/admin/order_spec.rb
@@ -239,7 +239,7 @@ describe '
new_customer = Customer.last
- expect(new_customer.name).to eq('Clark Kent')
+ expect(new_customer.full_name).to eq('Clark Kent')
expect(new_customer.bill_address.address1).to eq('Smallville')
expect(new_customer.bill_address.city).to eq('Kansas')
expect(new_customer.bill_address.zipcode).to eq('SP1 M11')
diff --git a/spec/system/admin/subscriptions_spec.rb b/spec/system/admin/subscriptions_spec.rb
index 41807ec0e4..6b74f7cd63 100644
--- a/spec/system/admin/subscriptions_spec.rb
+++ b/spec/system/admin/subscriptions_spec.rb
@@ -19,7 +19,7 @@ describe 'Subscriptions' do
let!(:subscription) {
create(:subscription, shop: shop, with_items: true, with_proxy_orders: true)
}
- let!(:customer) { create(:customer, name: "Customer A") }
+ let!(:customer) { create(:customer) }
let!(:other_subscription) {
create(:subscription, shop: shop, customer: customer, with_items: true,
with_proxy_orders: true)
@@ -81,8 +81,13 @@ describe 'Subscriptions' do
expect(page).to have_selector "tr#so_#{other_subscription.id}"
expect(page).to have_no_selector "tr#so_#{subscription.id}"
- # Using the Quick Search: filter by name
- fill_in 'query', with: other_subscription.customer.name
+ # Using the Quick Search: filter by first_name
+ fill_in 'query', with: other_subscription.customer.first_name
+ expect(page).to have_selector "tr#so_#{other_subscription.id}"
+ expect(page).to have_no_selector "tr#so_#{subscription.id}"
+
+ # Using the Quick Search: filter by last_name
+ fill_in 'query', with: other_subscription.customer.last_name
expect(page).to have_selector "tr#so_#{other_subscription.id}"
expect(page).to have_no_selector "tr#so_#{subscription.id}"