mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
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:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user