mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-05 02:41:33 +00:00
Submit blank value if nothing selected
If a checkbox is not selected, the browser does not submit it at all.
This commit is contained in:
@@ -15,7 +15,7 @@ module Admin
|
||||
private
|
||||
|
||||
def connected_apps_enabled
|
||||
params.require(:preferences).require(:connected_apps_enabled).join(",")
|
||||
params.require(:preferences).require(:connected_apps_enabled).compact_blank.join(",")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -11,6 +11,9 @@
|
||||
= t('.info_html')
|
||||
|
||||
.field
|
||||
-# Blank value in case nothing is selected
|
||||
= hidden_field_tag("preferences[connected_apps_enabled][]", "")
|
||||
|
||||
- ConnectedApp::TYPES.each do |type|
|
||||
%label
|
||||
= check_box_tag("preferences[connected_apps_enabled][]", type,
|
||||
|
||||
@@ -22,5 +22,15 @@ RSpec.describe "Connected App Settings", feature: :connected_apps do
|
||||
expect{
|
||||
click_button "Update"
|
||||
}.to change{ Spree::Config.connected_apps_enabled }.to("discover_regen,affiliate_sales_data")
|
||||
|
||||
expect(page).to have_field "Discover Regenerative portal", checked: true
|
||||
expect(page).to have_field "DFC anonymised orders API for research purposes", checked: true
|
||||
|
||||
uncheck "Discover Regenerative portal"
|
||||
uncheck "DFC anonymised orders API for research purposes"
|
||||
|
||||
expect{
|
||||
click_button "Update"
|
||||
}.to change{ Spree::Config.connected_apps_enabled }.to("")
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user