Fix more specs

This commit is contained in:
François Turbelin
2022-01-20 23:31:20 +01:00
committed by Maikel Linke
parent 75345a95af
commit 23776c7a3e
8 changed files with 34 additions and 27 deletions

View File

@@ -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'} }

View File

@@ -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)' } }

View File

@@ -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,

View File

@@ -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|

View File

@@ -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 }

View File

@@ -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

View File

@@ -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')

View File

@@ -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}"