Conditionally removing listing from Admin > Consumer Apps menu (#17182)
Related to forem/forem#16437
This commit is contained in:
parent
7f1fdc7324
commit
168698fe28
2 changed files with 19 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue