diff --git a/app/models/admin_menu.rb b/app/models/admin_menu.rb index 8b3c07223..d5ca12bc4 100644 --- a/app/models/admin_menu.rb +++ b/app/models/admin_menu.rb @@ -55,7 +55,7 @@ class AdminMenu scope :apps, "palette-line", [ item(name: "consumer apps", controller: "consumer_apps"), - item(name: "listings"), + item(name: "listings", visible: -> { Listing.feature_enabled? }), item(name: "welcome"), ] end.freeze diff --git a/spec/models/admin_menu_spec.rb b/spec/models/admin_menu_spec.rb index 0a147512e..375d8b9cf 100644 --- a/spec/models/admin_menu_spec.rb +++ b/spec/models/admin_menu_spec.rb @@ -97,4 +97,22 @@ RSpec.describe AdminMenu do it { is_expected.to be_visible } end end + + describe "scope :apps" do + subject(:listing) { apps.children.detect { |child| child.name == "listings" } } + + let(:apps) { described_class.navigation_items.fetch(:apps) } + + context "when Listing.feature_enabled? is true" do + before { allow(Listing).to receive(:feature_enabled?).and_return(true) } + + it { is_expected.to be_visible } + end + + context "when Listing.feature_enabled? is false" do + before { allow(Listing).to receive(:feature_enabled?).and_return(false) } + + it { is_expected.not_to be_visible } + end + end end