When hide_groups_tab is set to false, do not display group in shopfront

Co-Authored-By: Maikel <maikel@email.org.au>
This commit is contained in:
Jean-Baptiste Bellet
2023-04-25 17:22:42 +02:00
parent 0d98ec8f4c
commit 0bec7562a0
2 changed files with 37 additions and 1 deletions

View File

@@ -24,7 +24,7 @@ module ShopHelper
{ name: 'about', title: t(:shopping_tabs_about), show: true },
{ name: 'producers', title: t(:shopping_tabs_producers), show: true },
{ name: 'contact', title: t(:shopping_tabs_contact), show: true },
{ name: 'groups', title: t(:shopping_tabs_groups), show: current_distributor.groups.any? },
{ name: 'groups', title: t(:shopping_tabs_groups), show: show_groups_tabs? },
].select{ |tab| tab[:show] }
end
@@ -52,4 +52,10 @@ module ShopHelper
true
end
private
def show_groups_tabs?
!current_distributor.hide_groups_tab? && current_distributor.groups.any?
end
end

View File

@@ -157,6 +157,36 @@ describe 'White label setting' do
it_behaves_like "does not hide the OFN navigation"
end
context "manage hide_groups_tab preference when distributor belongs to a group" do
let(:group) { create(:enterprise_group) }
before do
distributor.groups << group
end
context "when the preference is set to true" do
before do
distributor.update_attribute(:hide_groups_tab, true)
end
it "hides the groups tab" do
visit main_app.enterprise_shop_path(distributor)
expect(page).to have_no_selector "a[href='#groups']"
end
end
context "when the preference is set to false" do
before do
distributor.update_attribute(:hide_groups_tab, false)
end
it "shows the groups tab" do
visit main_app.enterprise_shop_path(distributor)
expect(page).to have_selector "a[href='#groups']"
end
end
end
end
context "manage the white_label_logo preference" do