In admin, add form to set hide_groups_tab attribute

+ add specs
This commit is contained in:
Jean-Baptiste Bellet
2023-04-25 17:22:14 +02:00
parent 38cc8a89d1
commit 0d98ec8f4c
4 changed files with 30 additions and 1 deletions

View File

@@ -35,7 +35,8 @@ module PermittedAttributes
:show_customer_names_to_suppliers, :preferred_shopfront_product_sorting_method,
:preferred_invoice_order_by_supplier,
:preferred_product_low_stock_display,
:hide_ofn_navigation, :white_label_logo, :white_label_logo_link
:hide_ofn_navigation, :white_label_logo, :white_label_logo_link,
:hide_groups_tab
]
end
end

View File

@@ -29,3 +29,11 @@
= render ConfirmModalComponent.new(id: "remove_logo", confirm_reflexes: "click->WhiteLabel#remove_logo" ) do
.margin-bottom-30
= t('.remove_logo_confirm')
// Hide groups tab boolean attribute
.row
.three.columns.alpha
= f.label :hide_groups_tab, t('.hide_groups_tab')
.three.columns
= f.check_box :hide_groups_tab

View File

@@ -1185,6 +1185,7 @@ en:
remove_logo_confirm: "Are you sure you want to remove this logo?"
remove_logo_success: "Logo removed"
white_label_logo_link_label: "Link for the logo used in shopfront"
hide_groups_tab: "Hide groups tab in shopfront"
actions:
edit_profile: Settings
properties: Properties

View File

@@ -706,6 +706,25 @@ describe '
expect(distributor1.reload.white_label_logo_link).to eq("https://www.openfoodnetwork.org")
end
end
it "can check/uncheck the hide_groups_tab attribute" do
check "Hide groups tab in shopfront"
click_button 'Update'
expect(flash_message)
.to eq('Enterprise "First Distributor" has been successfully updated!')
expect(distributor1.reload.hide_groups_tab).to be true
visit edit_admin_enterprise_path(distributor1)
within(".side_menu") do
click_link "White Label"
end
uncheck "Hide groups tab in shopfront"
click_button 'Update'
expect(flash_message)
.to eq('Enterprise "First Distributor" has been successfully updated!')
expect(distributor1.reload.hide_groups_tab).to be false
end
end
end
end