Checkbox is correctly handled with null value (and not false)

- It's better to read the comment juste below the line... 😠 (https://github.com/openfoodfoundation/openfoodnetwork/pull/3076#issuecomment-440010498)
 - Add appropriate spec so it is now correctly tested!
This commit is contained in:
Jean-Baptiste Bellet
2021-06-17 21:40:25 +02:00
parent 7008b5ec7b
commit 89ea9913e6
2 changed files with 25 additions and 1 deletions

View File

@@ -49,7 +49,7 @@ angular.module("admin.orders").controller "ordersCtrl", ($scope, $timeout, Reque
'q[bill_address_firstname_start]': $scope.q?.bill_address_firstname_start,
'q[bill_address_lastname_start]': $scope.q?.bill_address_lastname_start,
# Set default checkbox values to null. See: https://github.com/openfoodfoundation/openfoodnetwork/pull/3076#issuecomment-440010498
'q[completed_at_not_null]': $scope.q?.completed_at_not_null,
'q[completed_at_not_null]': $scope.q?.completed_at_not_null || null,
'q[distributor_id_in][]': $scope.q?.distributor_id_in,
'q[order_cycle_id_in][]': $scope.q?.order_cycle_id_in,
'q[s]': $scope.sorting || 'completed_at desc',

View File

@@ -112,6 +112,30 @@ feature '
end
end
context "test the 'Only show the complete orders' checkbox" do
scenario "display or not incomplete order" do
incomplete_order = create(:order, distributor: distributor, order_cycle: order_cycle)
complete_order = create(
:order,
distributor: distributor,
order_cycle: order_cycle,
user: user,
state: 'complete',
payment_state: 'balance_due',
completed_at: 1.day.ago
)
login_as_admin_and_visit spree.admin_orders_path
expect(page).to have_content complete_order.number
expect(page).to have_no_content incomplete_order.number
uncheck 'Only show complete orders'
page.find('a.icon-search').click
expect(page).to have_content complete_order.number
expect(page).to have_content incomplete_order.number
end
end
context "save the filter params" do
let!(:shipping_method) { create(:shipping_method, name: "UPS Ground") }
let!(:user) { create(:user, email: 'an@email.com') }